You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tailscale/wgengine/magicsock
Alex Chan 7953592f40 tstest/integration: get TestOneNodeUpAuth to pass when offline
How TestOneNodeUpAuth works:

* it starts a test version of tailscaled
* it runs `tailscale up`
* it checks that tailscaled becomes "Running"

However, if the network is down, the test either fails or times out,
because tailscaled never becomes Running.

## Why does the test fail?

ipn only becomes Running when it sees at least one live peer or DERP
connection:
0cc1b2ff76/ipn/ipnlocal/local.go (L5861-L5866)

The test only uses a single node, so it's never going to see a peer --
it has to wait to see a DERP server.  The test environment does have
a DERP map of in-memory DERP nodes, but we aren't connecting to them.

magicsock sets the preferred DERP server in `updateNetInfo()`, but this
function returns early if the network is down.
0cc1b2ff76/wgengine/magicsock/magicsock.go (L1053-L1106)

Because we're checking the real network, this prevents ipn from entering
"Running" and causes the test to fail.

## What's the fix?

In tests, we can assume the network is up unless we're explicitly testing
the behaviour of tailscaled when the network is down.

We do something similar in magicsock/derp.go, where we assume we're
connected to control unless explicitly testing otherwise:
7d2101f352/wgengine/magicsock/derp.go (L166-L177)

This is the template for the changes to `networkDown()`.

Additionally, the `testenv.InTest()` function currently checks for the
`-test.v` flag, but this isn't visible to the version of tailscaled
running in the test environment.  Instead, we add a new `TEST` env var
so this process knows it's inside a test.

Fixes #17122

Signed-off-by: Alex Chan <alexc@tailscale.com>
3 months ago
..
blockforever_conn.go wgengine/magicsock: improve don't fragment bit set/get support 2 years ago
cloudinfo.go wgengine/magicsock: use cloud metadata to get public IPs 1 year ago
cloudinfo_nocloud.go wgengine/magicsock: use cloud metadata to get public IPs 1 year ago
cloudinfo_test.go wgengine/magicsock: use cloud metadata to get public IPs 1 year ago
debughttp.go net/{batching,packet},wgengine/magicsock: export batchingConn (#16848) 4 months ago
debugknobs.go wgengine/magicsock: add TS_DEBUG_NEVER_DIRECT_UDP debug knob (#17094) 3 months ago
debugknobs_stubs.go wgengine/magicsock: add TS_DEBUG_NEVER_DIRECT_UDP debug knob (#17094) 3 months ago
derp.go wgengine/magicsock: drop DERP queue from head rather than tail 3 months ago
derp_test.go net/netcheck,wgengine/magicsock: align DERP frame receive time heuristics 2 years ago
discopingpurpose_string.go wgengine/magicsock: implement probing of UDP path lifetime (#10844) 2 years ago
endpoint.go wgengine/magicsock: add TS_DEBUG_NEVER_DIRECT_UDP debug knob (#17094) 3 months ago
endpoint_default.go all: adjust some build tags for plan9 2 years ago
endpoint_stub.go all: adjust some build tags for plan9 2 years ago
endpoint_test.go net/{batching,packet},wgengine/magicsock: export batchingConn (#16848) 4 months ago
endpoint_tracker.go wgengine/magicsock: only cache N most recent endpoints per-Addr 2 years ago
endpoint_tracker_test.go all: use Go 1.22 range-over-int 2 years ago
magicsock.go tstest/integration: get TestOneNodeUpAuth to pass when offline 3 months ago
magicsock_default.go net/sockopts,wgengine/magicsock: export socket buffer sizing logic (#16909) 4 months ago
magicsock_linux.go net/sockopts,wgengine/magicsock: export socket buffer sizing logic (#16909) 4 months ago
magicsock_linux_test.go wgengine/magicsock: fix bpf fragmentation jump offsets (#16204) 6 months ago
magicsock_notplan9.go wgengine/magicsock: refactor maybeRebindOnError 11 months ago
magicsock_plan9.go wgengine/magicsock: refactor maybeRebindOnError 11 months ago
magicsock_test.go tstest/integration: get TestOneNodeUpAuth to pass when offline 3 months ago
peermap.go net/{batching,packet},wgengine/magicsock: export batchingConn (#16848) 4 months ago
peermap_test.go net/{batching,packet},wgengine/magicsock: export batchingConn (#16848) 4 months ago
peermtu.go magicsock: mute noisy expected peer mtu related error (#10870) 2 years ago
peermtu_darwin.go wgengine/magicsock: improve don't fragment bit set/get support 2 years ago
peermtu_linux.go wgengine/magicsock: improve don't fragment bit set/get support 2 years ago
peermtu_stubs.go magicsock: mute noisy expected peer mtu related error (#10870) 2 years ago
peermtu_unix.go wgengine/magicsock: replace CanPMTUD() with ShouldPMTUD() 2 years ago
rebinding_conn.go net/{batching,packet},wgengine/magicsock: export batchingConn (#16848) 4 months ago
relaymanager.go wgengine/magicsock: add relayManager event logs (#17091) 3 months ago
relaymanager_test.go wgengine/magicsock,all: allocate peer relay over disco instead of PeerAPI (#16603) 5 months ago