mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
tstest/integration/nat: annotate test 'want' values, fail on mismatch
Updates #13038 Change-Id: Id711ee19e52a7051a2273c806b184c5571c6e24f Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
67df9abdc6
commit
10662c4282
@ -44,6 +44,8 @@ type natTest struct {
|
||||
tempDir string // for qcow2 images
|
||||
vnet *vnet.Server
|
||||
kernel string // linux kernel path
|
||||
|
||||
gotRoute pingRoute
|
||||
}
|
||||
|
||||
func newNatTest(tb testing.TB) *natTest {
|
||||
@ -328,9 +330,10 @@ func (nt *natTest) runTest(node1, node2 addNodeFunc) pingRoute {
|
||||
if err != nil {
|
||||
t.Fatalf("ping failure: %v", err)
|
||||
}
|
||||
route := classifyPing(pingRes)
|
||||
t.Logf("ping route: %v", route)
|
||||
return route
|
||||
nt.gotRoute = classifyPing(pingRes)
|
||||
t.Logf("ping route: %v", nt.gotRoute)
|
||||
|
||||
return nt.gotRoute
|
||||
}
|
||||
|
||||
func classifyPing(pr *ipnstate.PingResult) pingRoute {
|
||||
@ -450,34 +453,51 @@ type nodeType struct {
|
||||
{"sameLAN", sameLAN},
|
||||
}
|
||||
|
||||
// want sets the expected ping route for the test.
|
||||
func (nt *natTest) want(r pingRoute) {
|
||||
if nt.gotRoute != r {
|
||||
nt.tb.Errorf("ping route = %v; want %v", nt.gotRoute, r)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEasyEasy(t *testing.T) {
|
||||
nt := newNatTest(t)
|
||||
nt.runTest(easy, easy)
|
||||
nt.want(routeDirect)
|
||||
}
|
||||
|
||||
// Tests https://github.com/tailscale/tailscale/issues/3824 ...
|
||||
func TestSameLAN(t *testing.T) {
|
||||
nt := newNatTest(t)
|
||||
nt.runTest(easy, sameLAN)
|
||||
nt.want(routeLocal)
|
||||
}
|
||||
|
||||
// TestBPFDisco tests https://github.com/tailscale/tailscale/issues/3824 ...
|
||||
// * server behind a Hard NAT
|
||||
// * client behind a NAT with UPnP support
|
||||
// * client machine has a stateful host firewall (e.g. ufw)
|
||||
|
||||
func TestBPFDisco(t *testing.T) {
|
||||
nt := newNatTest(t)
|
||||
nt.runTest(easyPMPFW, hard)
|
||||
nt.want(routeDirect)
|
||||
}
|
||||
|
||||
func TestHostFWNoBPF(t *testing.T) {
|
||||
nt := newNatTest(t)
|
||||
nt.runTest(easyPMPFWNoBPF, hard)
|
||||
nt.want(routeDERP)
|
||||
}
|
||||
|
||||
func TestHostFWPair(t *testing.T) {
|
||||
nt := newNatTest(t)
|
||||
nt.runTest(easyFW, easyFW)
|
||||
nt.want(routeDirect)
|
||||
}
|
||||
|
||||
func TestOneHostFW(t *testing.T) {
|
||||
nt := newNatTest(t)
|
||||
nt.runTest(easy, easyFW)
|
||||
nt.want(routeDirect)
|
||||
}
|
||||
|
||||
var pair = flag.String("pair", "", "comma-separated pair of types to test (easy, easyAF, hard, easyPMP, hardPMP, one2one, sameLAN)")
|
||||
|
Loading…
Reference in New Issue
Block a user