Skip to content

Commit

Permalink
try to fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
juliaElastic committed Nov 27, 2023
1 parent aa7bf11 commit d1ffe3f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion internal/pkg/bulk/bulk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,15 @@ func TestCancelCtxChildBulkerReplaced(t *testing.T) {
t.Fatal(err)
}

var waitBulker sync.WaitGroup
waitBulker.Add(1)
go func() {

Check failure on line 335 in internal/pkg/bulk/bulk_test.go

View workflow job for this annotation

GitHub Actions / lint (linux)

SA2002: the goroutine calls T.Fatal, which must be called in the same goroutine as the test (staticcheck)
defer waitBulker.Done()
if err := (childBulker.(*Bulker)).Run(ctx); !errors.Is(err, context.Canceled) {
t.Fatal(err)

Check failure on line 338 in internal/pkg/bulk/bulk_test.go

View workflow job for this annotation

GitHub Actions / lint (linux)

testinggoroutine: call to (*T).Fatal from a non-test goroutine (govet)
}
}()

// output cfg changed
outputMap["remote"] = map[string]interface{}{
"type": "remote_elasticsearch",
Expand All @@ -349,12 +358,16 @@ func TestCancelCtxChildBulkerReplaced(t *testing.T) {
err := childBulker.APIKeyUpdate(ctx, "", "", make([]byte, 0))

t.Log(err)
// TODO dial tcp: lookup remote-es: no such host
if !errors.Is(err, context.Canceled) {
t.Error("Expected context cancel err: ", err)
t.Fatal("Expected context cancel err: ", err)

Check failure on line 363 in internal/pkg/bulk/bulk_test.go

View workflow job for this annotation

GitHub Actions / lint (linux)

testinggoroutine: call to (*T).Fatal from a non-test goroutine (govet)
}
ctx.Done()
}()

wg.Wait()
cancel()
waitBulker.Wait()
}

func benchmarkMockBulk(b *testing.B, samples [][]byte) {
Expand Down

0 comments on commit d1ffe3f

Please sign in to comment.