Flaky test: TestEventServer fails with connection refused due to startup race
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
internal/server/event_server_test.goを読み、特に143行目付近のサーバー起動、309行目付近の最初のPOST、412~418行目付近の既存の準備完了チェックを確認してください。サーバーのgoroutineを起動した後に準備完了を待つ処理を追加し、報告されている競合が起きやすい条件でTestEventServerを実行してください。最初のPOSTがサーバー起動と競合しなくなれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Environment: main at d4eaa7a, Go 1.27.4, Ubuntu on WSL2
What I saw
During a full make test run, I hit a failure on the forwards_when_source_is_a_match subtest in TestEventServer with this exact error:
Post "http://localhost:<port>": dial tcp 127.0.0.1:<port>: connect: connection refused
It passed on a re-run. I ran it 30 separate times in a loop and they all passed, so it's a rare timing flake.
Cause
The server is started in a background goroutine (internal/server/event_server_test.go:143), but there is no readiness wait before the first http.Post executes (around line 309). If the Go scheduler delays the goroutine slightly, which is more likely under heavy load, such as during a full parallel make test with -race, the POST request fires before the server is actually listening.
Proof
I added a temporary time.Sleep(200 * time.Millisecond) at the top of EventServer.ListenAndServe in internal/server/event_server.go. With that delay, all 13 subtests instantly fail with connection refused (because the tests execute quickly enough that all of them run and fail inside that 200ms window).
Proposed fix
Add a readiness wait immediately after the server goroutine starts. We can use the exact same g.Eventually(net.Dial...) block that is already used elsewhere in the file (internal/server/event_server_test.go lines 412–418). Adding this check makes the test pass reliably, even with the artificial 200ms delay injected.
I can open a PR with this fix if you'd like.
- 主要言語
- Go
- スター
- 182
- フォーク
- 183
- 平均マージ
- 9時間 20分
- マージ済み PR(30日)
- 26
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
fluxcd/notification-controller のほかの issue
-
area/alerting area/api enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
fluxcd/notification-controller#1155 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Improve documentation on debugging the controller locally再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンarea/docs good first issue help wanted
難易度 2/5 半日 初心者へのやさしさ 72/100
fluxcd/notification-controller#362 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Commit status: opt-in event message as description (spec.commitStatusDescriptionExpr)対応中かも @schdief が 2 日前に担当しました。 オープン
難易度 5/5 1週間以上 初心者へのやさしさ 38/100
fluxcd/notification-controller#1436 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
fluxcd/notification-controller#1386 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 42/100
fluxcd/notification-controller#1371 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
fluxcd/notification-controller の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
OneBusAway/maglev#2145 ·
メンテナーはふだん 2 日以内に返信
-
priority/medium status/ready type/chore
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
discobox-ai/discobox#1357 ·
メンテナーはふだん 1 日以内に返信
-
TestPseudoLocaleRemote fails now and then: it types the code before the laptop asks for it対応中かも @fzn0x が今日担当しました。 オープンbug priority: low
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
edit_file diff rendering panics on invalid UTF-8 text対応中かも @TDnorthgarden が今日担当しました。 オープンarea/tui
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
docker/docker-agent#4955 ·
メンテナーはふだん 1 日以内に返信
-
enhancement ui/ux
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
jbigler/railswitch#243 ·
メンテナーはふだん 1 日以内に返信