Skip to content

test(multisocket): deflake restart by using a fresh port and coordinated cleanup#7438

Merged
yongtang merged 1 commit intocoredns:masterfrom
syedazeez337:fix/multisocket-flaky-restart
Aug 11, 2025
Merged

test(multisocket): deflake restart by using a fresh port and coordinated cleanup#7438
yongtang merged 1 commit intocoredns:masterfrom
syedazeez337:fix/multisocket-flaky-restart

Conversation

@syedazeez337
Copy link
Copy Markdown
Contributor

What
Deflake multisocket restart tests by:

  • Restarting onto a different free port (eliminates brief EADDRINUSE windows while old TCP/UDP sockets are still tearing down).
  • Not calling Stop() around Restart() (avoids the negative WaitGroup panic seen before).
  • Coordinating Stop() of the new instance via channels to avoid leaks/races.
  • Keeping assertions on expected server counts.

Why
CI frequently hit flakes in TestMultisocket_Restart (issue #7311). Root causes were socket linger and overlapping Stop/Restart sequencing on the same port.

How

  • pickPort(t) probes a free port.
  • Restart uses port1 → port2 (commented rationale in test).
  • Result + cleanup synchronized with channels.
  • Test-only change; no prod code.

Testing
go clean -testcache
go test ./test -run '^TestMultisocket(_Restart|_WhoAmI)?$' -count=200 -shuffle=on -p=1 -race -v
go test ./... -race -shuffle=on -count=1 -p=1

Risk
Low (tests only).

DCO
Signed-off-by: syedazeez337@gmail.com

Fixes
Fixes #7311

Release note
None.

…ted cleanup

Avoid transient EADDRINUSE and a previous negative WaitGroup panic:
- restart onto a different free port
- no Stop() around Restart()
- channel-coordinated Stop of the new instance

Fixes coredns#7311

Signed-off-by: Syed Azeez <syedazeez337@gmail.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.74%. Comparing base (93c57b6) to head (21a9de4).
⚠️ Report is 1550 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7438      +/-   ##
==========================================
+ Coverage   55.70%   59.74%   +4.04%     
==========================================
  Files         224      274      +50     
  Lines       10016    18095    +8079     
==========================================
+ Hits         5579    10811    +5232     
- Misses       3978     6651    +2673     
- Partials      459      633     +174     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@yongtang yongtang merged commit bc0467d into coredns:master Aug 11, 2025
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

plugin/multisocket: flaky tests

2 participants