Flaky test: TestEventServer fails with connection refused due to startup race
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 86/100
Hướng nghiên cứu
Đọc internal/server/event_server_test.go, đặc biệt là phần khởi động máy chủ quanh dòng 143, POST đầu tiên quanh dòng 309 và kiểm tra trạng thái sẵn sàng hiện có quanh các dòng 412–418. Thêm bước chờ máy chủ sẵn sàng sau khi khởi chạy goroutine của máy chủ, rồi chạy TestEventServer trong các điều kiện được báo cáo là dễ xảy ra race; hoàn tất khi POST đầu tiên không còn race với quá trình khởi động máy chủ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Go
- Star
- 182
- Fork
- 183
- Merge trung bình
- 9 giờ 20 phút
- Pull request đã merge (30 ngày)
- 26
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của fluxcd/notification-controller
-
area/alerting area/api enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
fluxcd/notification-controller#1155 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Improve documentation on debugging the controller locallyCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởarea/docs good first issue help wanted
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 72/100
fluxcd/notification-controller#362 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Commit status: opt-in event message as description (spec.commitStatusDescriptionExpr)Có thể đã có người làm @schdief đã nhận 2 ngày trước. Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 38/100
fluxcd/notification-controller#1436 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
fluxcd/notification-controller#1386 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 42/100
fluxcd/notification-controller#1371 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của fluxcd/notification-controller
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
OneBusAway/maglev#2145 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
priority/medium status/ready type/chore
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
discobox-ai/discobox#1357 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
TestPseudoLocaleRemote fails now and then: it types the code before the laptop asks for itCó thể đã có người làm @fzn0x đã nhận hôm nay. Đang mởbug priority: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
edit_file diff rendering panics on invalid UTF-8 textCó thể đã có người làm @TDnorthgarden đã nhận hôm nay. Đang mởarea/tui
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
docker/docker-agent#4955 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement ui/ux
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
jbigler/railswitch#243 ·
Maintainer thường phản hồi trong vòng 1 ngày