Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore][pkg/stanza/operator/transformer/recombine] Enable goleak check #31095

Merged
merged 4 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions pkg/stanza/operator/transformer/recombine/package_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package recombine

import (
"testing"

"go.uber.org/goleak"
)

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
}
14 changes: 12 additions & 2 deletions pkg/stanza/operator/transformer/recombine/recombine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ func TestTransformer(t *testing.T) {
op, err := tc.config.Build(testutil.Logger(t))
require.NoError(t, err)
require.NoError(t, op.Start(testutil.NewUnscopedMockPersister()))
defer func() { require.NoError(t, op.Stop()) }()
recombine := op.(*Transformer)

fake := testutil.NewFakeOutput(t)
Expand Down Expand Up @@ -709,13 +710,21 @@ func TestTimeoutWhenAggregationKeepHappen(t *testing.T) {
require.NoError(t, recombine.Start(nil))
require.NoError(t, recombine.Process(ctx, e))

done := make(chan struct{})
ticker := time.NewTicker(cfg.ForceFlushTimeout / 2)
go func() {
next := entry.New()
next.Timestamp = time.Now()
next.Body = "next"
for {
time.Sleep(cfg.ForceFlushTimeout / 2)
require.NoError(t, recombine.Process(ctx, next))
select {
case <-done:
ticker.Stop()
return
case <-ticker.C:
require.NoError(t, recombine.Process(ctx, next))

}
}
}()

Expand All @@ -726,6 +735,7 @@ func TestTimeoutWhenAggregationKeepHappen(t *testing.T) {
t.FailNow()
}
require.NoError(t, recombine.Stop())
close(done)
}

func TestSourceBatchDelete(t *testing.T) {
Expand Down
Loading