Repository navigation
test(netgw): Make the forward tests survive the shared CI Mac #116
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -129,16 +129,30 @@ func (m *member) arpReplyTo(frame []byte) []byte { | |
|
|
||
| func (m *member) send(t *testing.T, frame []byte) { | ||
| t.Helper() | ||
| _ = m.conn.SetWriteDeadline(time.Now().Add(2 * time.Second)) | ||
| // A pipe write completes when the gateway reads the frame, which is the | ||
| // same in-process answer await waits for, under the same load. | ||
| _ = m.conn.SetWriteDeadline(time.Now().Add(replyWait)) | ||
| if _, err := m.conn.Write(frame); err != nil { | ||
| t.Fatalf("send frame: %v", err) | ||
| } | ||
| } | ||
|
|
||
| // await returns the first frame matching pred, or fails after the deadline. | ||
| // replyWait bounds how long a test waits for the gateway to answer. | ||
| // | ||
| // Every answer is computed in-process -- the netstack's ICMP reply, an ARP | ||
| // exchange with the member, a dial the forwarder makes, a counter it bumps, | ||
| // the read that completes a pipe write, a resolver tick -- so this is a | ||
| // liveness bound, not a budget the gateway is held to. It only has to be | ||
| // wide enough that a slow machine cannot cross it: the CI Mac runs these | ||
| // under the race detector beside the e2e job's VMs and the other runners' | ||
| // work, and three seconds was crossed there once, by an echo reply that | ||
| // arrived late rather than not at all. | ||
| const replyWait = 10 * time.Second | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Failure: on the same loaded Mac under Evidence: egress_test.go:399 and egress_test.go:418 still hold Fix: use |
||
|
|
||
| // await returns the first frame matching pred, or fails after replyWait. | ||
| func (m *member) await(t *testing.T, what string, pred func([]byte) bool) []byte { | ||
| t.Helper() | ||
| deadline := time.After(3 * time.Second) | ||
| deadline := time.After(replyWait) | ||
| for { | ||
| select { | ||
| case frame := <-m.frames: | ||
|
|
||
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.
nit:
exposeFreshretries only on a refusal that carriesEADDRINUSE, but the doc invites a caller whose refusal will not carry it. The comment at forward_test.go:107 says each Local is "a host with no port -- "127.0.0.1", "0.0.0.0", or """, so a later caller may pass two same-protocol forwards on different hosts.Failure:
exposeFresh(t, n, Forward{Local: "0.0.0.0", ...}, Forward{Local: "127.0.0.1", ...})on Linux. The first bind takes the wildcard; the second refuses withEADDRINUSE,holderOfPortfinds the gateway's owntcp/0.0.0.0:P, and forward.go:266-267 returns anErrForwardExiststhat does not wrap the syscall error.errors.Is(err, syscall.EADDRINUSE)is false, the loop breaks on the first attempt, and the test dies withExpose on a fresh port: ...-- a message that blames the port draw when the real answer is that the two addresses cannot share a port on this kernel, which is a fact about the gateway rather than a flake.Evidence: forward.go:265-270 (the own-holder branch returns
ErrForwardExistsalone, the outside-holder branch at :269 wrapserras well); forward_test.go:141. The two current call sites are unaffected -- the only multi-forward call pairs tcp with udp (forward_test.go:340-342), andholderOfPortfilters by protocol (forward.go:292-294).Fix: say in the helper's doc that the forwards must differ in protocol, or treat
ErrForwardExistsfrom a bind the wayEADDRINUSEis treated and let the caller's own assertion rule on it.