mirror of
https://github.com/tailscale/tailscale.git
synced 2026-12-06 23:36:34 +09:00
tstest/integration: deflake TestClientSideJailing
TestClientSideJailing waited only for each node's netmap to show the
peer with the expected IsJailed bit, then made a single 1s DialTCP for
each direction. But a peer's endpoints, DERP home, and disco key reach
the other node via separate map updates that can land after the peer
first appears in the netmap. If the first dial's WireGuard handshake
initiation is sent before then, magicsock drops it ("Failed to send
handshake initiation: no UDP or DERP addr") and wireguard-go does not
retry for 5s, so every "should succeed" dial in that window fails.
That matches the CI failures on the race-root-integration job: both
dials in not_jailed, and sometimes the uni_jailed n2-to-n1 dial too,
failed with exactly 1s/2s subtest durations.
This is a test bug, not a jail propagation bug: the jailed state and
the data plane peer routes and jailed filter are installed under the
same LocalBackend lock as the netmap the test polls.
Retry the dials that should succeed until they connect (up to 20s).
The dials that should fail still get a single attempt, since a late
path can only make them fail more. Also drop the flakytest.Mark.
The flake didn't reproduce unaided locally (0/192 runs; 0/95 with
-race and 2 CPUs). Delaying testcontrol's processing of endpoint
updates by 200ms reproduces it deterministically:
before: 95/95 runs failed (with 200ms injected delay)
after: 0/136 runs failed (with 200ms injected delay)
after: 0/71 runs failed (-race, taskset 0-1, no injection)
Fixes #17419
Change-Id: I779d173d5d6c01fe878848cdfe049e7f29d20775
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Signed-off-by: Guy J Grigsby <guy@tailscale.com>
This commit is contained in:
1 parent
7c1f8115f1
commit
30a37b4c5f
1 file changed
+20
-8
@@ -1490,7 +1490,6 @@ func startUnattendedModeNode(t *testing.T) (*TestEnv, *TestNode, *Daemon) {
|
||||
// jailed node cannot initiate connections to the other node however the other
|
||||
// node can initiate connections to the jailed node.
|
||||
func TestClientSideJailing(t *testing.T) {
|
||||
flakytest.Mark(t, "https://github.com/tailscale/tailscale/issues/17419")
|
||||
tstest.Parallel(t)
|
||||
env := NewTestEnv(t)
|
||||
registerNode := func() (*TestNode, key.NodePublic) {
|
||||
@@ -1547,17 +1546,30 @@ func TestClientSideJailing(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
testDial := func(t *testing.T, lc *local.Client, ip netip.Addr, port uint16, shouldFail bool) {
|
||||
t.Helper()
|
||||
dialOnce := func(lc *local.Client, ip netip.Addr, port uint16) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
c, err := lc.DialTCP(ctx, ip.String(), port)
|
||||
failed := err != nil
|
||||
if failed != shouldFail {
|
||||
t.Errorf("failed = %v; want %v", failed, shouldFail)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if c != nil {
|
||||
c.Close()
|
||||
c.Close()
|
||||
return nil
|
||||
}
|
||||
testDial := func(t *testing.T, lc *local.Client, ip netip.Addr, port uint16, shouldFail bool) {
|
||||
t.Helper()
|
||||
if shouldFail {
|
||||
if err := dialOnce(lc, ip, port); err == nil {
|
||||
t.Errorf("dial %v succeeded; want failure", ip)
|
||||
}
|
||||
return
|
||||
}
|
||||
// Peer paths arrive asynchronously and WireGuard only retries
|
||||
// a dropped handshake after 5s, so retry.
|
||||
if err := tstest.WaitFor(20*time.Second, func() error {
|
||||
return dialOnce(lc, ip, port)
|
||||
}); err != nil {
|
||||
t.Errorf("dial %v: %v; want success", ip, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user