fix(test): prevent data race in TestReadme #7769
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
1. Why is this pull request needed and what does it do?
Affects the QUIC integration test originally from #7680.
Replace "reload 2s" with "quic" in
quicReloadCorefileto avoid spawning a background goroutine that readsdnsserver.PortwhileTestReadmemodifies it. The testTestQUICReloadDoesNotPanicstill verifies the QUIC reload panic fix via explicitinst.Restart()call.I also ran the test with the proposed config against a commit pre-dating #7680. I was able to reproduce the panic, without the
reload 2s.2. Which issues (if any) are related?
See a failed CI run here.
Details
WARNING: DATA RACE Read at 0x0000068eb120 by goroutine 325060: github.com/coredns/coredns/core/dnsserver.init.0.func2() /home/runner/work/coredns/coredns/core/dnsserver/register.go:25 +0x2a github.com/coredns/caddy.DefaultInput() /home/runner/go/pkg/mod/github.com/coredns/[email protected]/caddy.go:1009 +0xf6 github.com/coredns/caddy.LoadCaddyfile() /home/runner/go/pkg/mod/github.com/coredns/[email protected]/caddy.go:417 +0x124 github.com/coredns/coredns/plugin/reload.hook.func1() /home/runner/work/coredns/coredns/plugin/reload/reload.go:91 +0x1c6Previous write at 0x0000068eb120 by goroutine 325145:
github.com/coredns/coredns/test.TestReadme()
/home/runner/work/coredns/coredns/test/readme_test.go:85 +0x6eb
testing.tRunner()
/opt/hostedtoolcache/go/1.25.5/x64/src/testing/testing.go:1934 +0x21c
testing.(*T).Run.gowrap1()
/opt/hostedtoolcache/go/1.25.5/x64/src/testing/testing.go:1997 +0x44
3. Which documentation changes (if any) need to be made?
None, tests only.
4. Does this introduce a backward incompatible change or deprecation?
No.