Files
tailscale/tstest/natlab/vmtest/connectivity.go
Claus Lensbøl 1e3097c9f2 tstest/natlab/{vnet,vmtest},cmd/tta: add roaming test to natlab (#21695)
To faciliate roaming a few things had to happen as tta communicated over
the same links as tailscaled communicates over, meaning that the
connection to tta gets cut when cutting the interface.

 - Whenever we have connected to the client after waiting for it to come
   up, clean up idle connections.
 - Have tta use keepalives to reconnect.
 - Delete default route on just via, not the interface.
 - Add capabilities to QMP for setting the interface state.
 - Implement the test.

Fixes tailscale/corp#49639

Signed-off-by: Claus Lensbøl <[email protected]>
2026-10-09 13:05:45 -04:00

58 lines
1.5 KiB
Go

// Copyright (c) Tailscale Inc & contributors
// SPDX-License-Identifier: BSD-3-Clause
package vmtest
import (
"fmt"
"time"
)
// AddNodeFunc is used to describe a func passed to [RunConnectivityTestExpect].
type AddNodeFunc func(*Env) *Node
// RunConnectivityTestExpect adds the specified nodes to the network and then
// verifies that a Disco ping from n1 to n2 completes within 30 seconds.
func (e *Env) RunConnectivityTestExpect(name string, pingRoute PingRoute, n1, n2 AddNodeFunc) {
node1 := n1(e)
node2 := n2(e)
discoPingStep := e.AddStep(
fmt.Sprintf("[%s] Ping a → b Disco (want %s)", name, pingRoute))
e.Start()
discoPingStep.Begin()
if _, err := e.PingExpect(node1, node2, pingRoute, 30*time.Second); err != nil {
discoPingStep.End(err)
e.t.Error(err)
return
}
discoPingStep.End(nil)
}
// RunConnectivityTest adds the specified nodes to the network and then
// verifies that a Disco ping from n1 to n2 completes within 30 seconds.
func (e *Env) RunConnectivityTest(name string, n1, n2 AddNodeFunc) PingRoute {
e.t.Helper()
node1 := n1(e)
node2 := n2(e)
if node1 == nil || node2 == nil {
e.t.Skip("skipping test; not applicable combination")
}
discoPingStep := e.AddStep(
fmt.Sprintf("[%s] Ping a → b Disco", name))
e.Start()
discoPingStep.Begin()
pRes, err := e.PingSettle(node1, node2, 10*time.Second)
if err != nil {
discoPingStep.End(err)
e.t.Error(err)
return PingRouteNil
}
pRoute := classifyPing(pRes)
discoPingStep.End(nil)
return pRoute
}