Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
juliaElastic committed Nov 23, 2023
1 parent 96bdb42 commit 053fbed
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
7 changes: 3 additions & 4 deletions internal/pkg/api/handleAck.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ func (ack *AckT) updateAPIKey(ctx context.Context,
outputBulk := ack.bulk.GetBulker(outputName)
if outputBulk != nil {
zlog.Debug().Str("outputName", outputName).Msg("Using output bulker in updateAPIKey")
bulk = *outputBulk
bulk = outputBulk
}
}
if apiKeyID != "" {
Expand Down Expand Up @@ -598,15 +598,14 @@ func (ack *AckT) invalidateAPIKeys(ctx context.Context, zlog zerolog.Logger, toR
if err != nil || policy == nil {
zlog.Debug().Str("outputName", outputName).Msg("Output policy not found")
} else {
blk, _, err := ack.bulk.CreateAndGetBulker(ctx, zlog, outputName, policy.Data.Outputs)
outputBulk = &blk
outputBulk, _, err = ack.bulk.CreateAndGetBulker(ctx, zlog, outputName, policy.Data.Outputs)
if err != nil {
zlog.Debug().Str("outputName", outputName).Msg("Failed to recreate output bulker")
}
}
}
if outputBulk != nil {
if err := (*outputBulk).APIKeyInvalidate(ctx, outputIds...); err != nil {
if err := outputBulk.APIKeyInvalidate(ctx, outputIds...); err != nil {
zlog.Info().Err(err).Strs("ids", outputIds).Str("outputName", outputName).Msg("Failed to invalidate API keys")
}
}
Expand Down
7 changes: 3 additions & 4 deletions internal/pkg/bulk/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ type Bulk interface {
Client() *elasticsearch.Client

CreateAndGetBulker(ctx context.Context, zlog zerolog.Logger, outputName string, outputMap map[string]map[string]interface{}) (Bulk, bool, error)
GetBulker(outputName string) *Bulk
GetBulker(outputName string) Bulk
GetBulkerMap() map[string]Bulk
CancelFn() context.CancelFunc

Expand Down Expand Up @@ -123,9 +123,8 @@ func NewBulker(es esapi.Transport, tracer *apm.Tracer, opts ...BulkOpt) *Bulker
}
}

func (b *Bulker) GetBulker(outputName string) *Bulk {
blk := b.bulkerMap[outputName]
return &blk
func (b *Bulker) GetBulker(outputName string) Bulk {
return b.bulkerMap[outputName]
}

func (b *Bulker) GetBulkerMap() map[string]Bulk {
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/testing/bulk.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ func (m *MockBulk) Client() *elasticsearch.Client {
return args.Get(0).(*elasticsearch.Client)
}

func (m *MockBulk) GetBulker(outputName string) *bulk.Bulk {
func (m *MockBulk) GetBulker(outputName string) bulk.Bulk {
args := m.Called(outputName)
if args.Get(0) == nil {
return nil
}
return args.Get(0).(*bulk.Bulk)
return args.Get(0).(bulk.Bulk)
}

func (m *MockBulk) GetBulkerMap() map[string]bulk.Bulk {
Expand Down

0 comments on commit 053fbed

Please sign in to comment.