-
Notifications
You must be signed in to change notification settings - Fork 5k
test(TestGenerateProcessorList): close processor before return #47663
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
base: main
Are you sure you want to change the base?
test(TestGenerateProcessorList): close processor before return #47663
Conversation
close the processors to ensure graceful shutdown and avoid goroutine leak. use logptest logger in test
🤖 GitHub commentsJust comment with:
|
|
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
|
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still seeing some failures due to testing.T being used after the test has ended:
% git log -1
commit 947320cd4d1e281c9b2811876d65b6bf67da87e1 (HEAD, kruskall/test/TestGenerateProcessorList-flaky)
Merge: d067abef80 c2fc36f800
Author: kruskall <99559985+kruskall@users.noreply.github.com>
Date: Sat Nov 22 15:08:20 2025 +0100
Merge branch 'main' into test/TestGenerateProcessorList-flaky
tiago@millennium-falcon beats/libbeat/publisher/processing v1.25.1 HEAD [$?]
% go test -count=500 -run=TestGenerateProcessorList
panic: Log in goroutine after TestGenerateProcessorList has completed: 2025-11-24T09:40:43.746-0500 DEBUG add_cloud_metadata add_cloud_metadata: received disposition for azure after 4.235739ms. result=[provider:azure, error=failed requesting azure metadata: Get "http://169.254.169.254/metadata/instance/compute?api-version=2021-02-01": dial tcp 169.254.169.254:80: connect: network is unreachable, metadata={}]
panic: Log in goroutine after TestGenerateProcessorList has completed: 2025-11-24T09:40:43.746-0500 DEBUG add_cloud_metadata add_cloud_metadata: fetchMetadata ran for 4.263064ms
goroutine 543 [running]:
testing.(*common).log(0xc000a90fc0, {0xc000d29260?, 0x6a?})
/usr/local/go/src/testing/testing.go:1030 +0x1ac
testing.(*common).Logf(0xc000a90fc0, {0x525cab3?, 0x400?}, {0xc000e00700?, 0xff?, 0x2?})
/usr/local/go/src/testing/testing.go:1191 +0x4f
go.uber.org/zap/zaptest.TestingWriter.Write({{0x7f797875cd20?, 0xc000a90fc0?}, 0xc0?}, {0xc000995000?, 0x6b, 0xc000995000?})
/home/tiago/go/pkg/mod/go.uber.org/zap@v1.27.0/zaptest/logger.go:146 +0xdb
go.uber.org/zap/zapcore.(*ioCore).Write(0xc0006cff20, {0xff, {0xc241397aec8374ef, 0x439011c, 0x7552d00}, {0x527f9b6, 0x12}, {0xc000540540, 0x34}, {0x0, ...}, ...}, ...)
/home/tiago/go/pkg/mod/go.uber.org/zap@v1.27.0/zapcore/core.go:99 +0xb5
go.uber.org/zap/zapcore.(*CheckedEntry).Write(0xc000cbe750, {0x0, 0x0, 0x0})
/home/tiago/go/pkg/mod/go.uber.org/zap@v1.27.0/zapcore/entry.go:253 +0x119
go.uber.org/zap.(*SugaredLogger).log(0xc000cb2148, 0xff, {0x52ccb0d?, 0x2c?}, {0xc000671680?, 0x1?, 0x1?}, {0x0, 0x0, 0x0})
/home/tiago/go/pkg/mod/go.uber.org/zap@v1.27.0/sugar.go:355 +0xec
go.uber.org/zap.(*SugaredLogger).Debugf(...)
/home/tiago/go/pkg/mod/go.uber.org/zap@v1.27.0/sugar.go:198
github.com/elastic/elastic-agent-libs/logp.(*Logger).Debugf(...)
/home/tiago/go/pkg/mod/github.com/elastic/elastic-agent-libs@v0.26.0/logp/logger.go:227
github.com/elastic/beats/v7/libbeat/processors/add_cloud_metadata.(*addCloudMetadata).fetchMetadata.func1()
/home/tiago/devel/beats/libbeat/processors/add_cloud_metadata/providers.go:160 +0x91
panic({0x4af3f80?, 0xc000e006c0?})
/usr/local/go/src/runtime/panic.go:783 +0x132
testing.(*common).log(0xc000a90fc0, {0xc000112c60?, 0x154?})
/usr/local/go/src/testing/testing.go:1030 +0x1ac
testing.(*common).Logf(0xc000a90fc0, {0x525cab3?, 0x400?}, {0xc000e006a0?, 0xff?, 0x2?})
/usr/local/go/src/testing/testing.go:1191 +0x4f
go.uber.org/zap/zaptest.TestingWriter.Write({{0x7f797875cd20?, 0xc000a90fc0?}, 0xc0?}, {0xc0006af000?, 0x155, 0xc0006af000?})
/home/tiago/go/pkg/mod/go.uber.org/zap@v1.27.0/zaptest/logger.go:146 +0xdb
go.uber.org/zap/zapcore.(*ioCore).Write(0xc0006cff20, {0xff, {0xc241397aec8349a3, 0x438d5d2, 0x7552d00}, {0x527f9b6, 0x12}, {0xc000a18480, 0x11e}, {0x0, ...}, ...}, ...)
/home/tiago/go/pkg/mod/go.uber.org/zap@v1.27.0/zapcore/core.go:99 +0xb5
go.uber.org/zap/zapcore.(*CheckedEntry).Write(0xc00080ac30, {0x0, 0x0, 0x0})
/home/tiago/go/pkg/mod/go.uber.org/zap@v1.27.0/zapcore/entry.go:253 +0x119
go.uber.org/zap.(*SugaredLogger).log(0xc000cb2148, 0xff, {0x52fcb88?, 0x3c?}, {0xc000671c68?, 0x3?, 0x3?}, {0x0, 0x0, 0x0})
/home/tiago/go/pkg/mod/go.uber.org/zap@v1.27.0/sugar.go:355 +0xec
go.uber.org/zap.(*SugaredLogger).Debugf(...)
/home/tiago/go/pkg/mod/go.uber.org/zap@v1.27.0/sugar.go:198
github.com/elastic/elastic-agent-libs/logp.(*Logger).Debugf(...)
/home/tiago/go/pkg/mod/github.com/elastic/elastic-agent-libs@v0.26.0/logp/logger.go:227
github.com/elastic/beats/v7/libbeat/processors/add_cloud_metadata.acceptFirstPriorityResult({0x5827df0, 0xc00028e310}, 0xc00071a6d8, {0xc000cb2148?, 0xc00071a3ff?, 0x7552d00?}, 0xc00078ddc0)
/home/tiago/devel/beats/libbeat/processors/add_cloud_metadata/providers.go:206 +0x29d
github.com/elastic/beats/v7/libbeat/processors/add_cloud_metadata.(*addCloudMetadata).fetchMetadata(0xc00040ede0)
/home/tiago/devel/beats/libbeat/processors/add_cloud_metadata/providers.go:191 +0x445
github.com/elastic/beats/v7/libbeat/processors/add_cloud_metadata.(*addCloudMetadata).init.func1()
/home/tiago/devel/beats/libbeat/processors/add_cloud_metadata/add_cloud_metadata.go:101 +0x67
sync.(*Once).doSlow(0xc000a90fc0?, 0xc0009b2f90?)
/usr/local/go/src/sync/once.go:78 +0xac
sync.(*Once).Do(...)
/usr/local/go/src/sync/once.go:69
github.com/elastic/beats/v7/libbeat/processors/add_cloud_metadata.(*addCloudMetadata).init(0x53adb50?)
/home/tiago/devel/beats/libbeat/processors/add_cloud_metadata/add_cloud_metadata.go:99 +0x31
created by github.com/elastic/beats/v7/libbeat/processors/add_cloud_metadata.New in goroutine 542
/home/tiago/devel/beats/libbeat/processors/add_cloud_metadata/add_cloud_metadata.go:89 +0x2ae
exit status 2
FAIL github.com/elastic/beats/v7/libbeat/publisher/processing 0.080s
tiago@millennium-falcon beats/libbeat/publisher/processing v1.25.1 HEAD [$?]
%
|
I accidentally dismissed @mauri870's review 🙈. Sorry for that. |
Interesting, I did test it with |
Proposed commit message
close the processors to ensure graceful shutdown and avoid goroutine leak.
use logptest logger in test
Checklist
stresstest.shscript to run them under stress conditions and race detector to verify their stability../changelog/fragmentsusing the changelog tool.Disruptive User Impact
Author's Checklist
How to test this PR locally
panic: Log in goroutine after TestGenerateProcessorList has completed#47528Use cases
Screenshots
Logs