package integration
import "tailscale.com/tstest/integration"
Package integration contains Tailscale integration tests.
This package is considered internal and the public API is subject to change without notice.
Index ¶
- Variables
- func RunDERPAndSTUN(t testing.TB, logf logger.Logf, ipAddress string) (derpMap *tailcfg.DERPMap)
- type Binaries
- type BinaryInfo
- type ConfigureControl
- type Daemon
- type LogCatcher
- func (lc *LogCatcher) Reset()
- func (lc *LogCatcher) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (lc *LogCatcher) StoreRawJSON()
- func (lc *LogCatcher) UseLogf(fn logger.Logf)
- type TestEnv
- type TestEnvOpt
- type TestNode
- func NewTestNode(t *testing.T, env *TestEnv) *TestNode
- func (n *TestNode) AwaitBackendState(state string)
- func (n *TestNode) AwaitIP4() netip.Addr
- func (n *TestNode) AwaitIP6() netip.Addr
- func (n *TestNode) AwaitIPs() []netip.Addr
- func (n *TestNode) AwaitListening()
- func (n *TestNode) AwaitNeedsLogin()
- func (n *TestNode) AwaitResponding()
- func (n *TestNode) AwaitRunning()
- func (n *TestNode) AwaitSocksAddr(ch <-chan string) string
- func (n *TestNode) LocalClient() *local.Client
- func (n *TestNode) MustDown()
- func (n *TestNode) MustLogOut()
- func (n *TestNode) MustStatus() *ipnstate.Status
- func (n *TestNode) MustUp(extraArgs ...string)
- func (n *TestNode) Ping(otherNode *TestNode) error
- func (n *TestNode) StartDaemon() *Daemon
- func (n *TestNode) StartDaemonAsIPNGOOS(ipnGOOS string) *Daemon
- func (n *TestNode) Status() (*ipnstate.Status, error)
- func (n *TestNode) Tailscale(arg ...string) *exec.Cmd
- func (n *TestNode) TailscaleForOutput(arg ...string) *exec.Cmd
Variables ¶
var MainError syncs.AtomicValue[error]
MainError is an error that's set if an error conditions happens outside of a context where a testing.TB is available. The caller can check it in its TestMain as a last ditch place to report errors.
Functions ¶
func RunDERPAndSTUN ¶
RunDERPAndSTUN runs a local DERP and STUN server for tests, returning the derpMap that clients should use. This creates resources that must be cleaned up with the returned cleanup function.
Types ¶
type Binaries ¶
type Binaries struct { Dir string Tailscale BinaryInfo Tailscaled BinaryInfo }
Binaries contains the paths to the tailscale and tailscaled binaries.
func GetBinaries ¶
GetBinaries create a temp directory using tb and builds (or copies previously built) cmd/tailscale and cmd/tailscaled binaries into that directory.
It fails tb if the build or binary copies fail.
type BinaryInfo ¶
type BinaryInfo struct { Path string // abs path to tailscale or tailscaled binary Size int64 // FD and FDmu are set on Unix to efficiently copy the binary to a new // test's automatically-cleaned-up temp directory. FD *os.File // for Unix (macOS, Linux, ...) FDMu sync.Locker // Contents is used on Windows instead of FD to copy the binary between // test directories. (On Windows you can't keep an FD open while an earlier // test's temp directories are deleted.) // This burns some memory and costs more in I/O, but oh well. Contents []byte }
BinaryInfo describes a tailscale or tailscaled binary.
func (BinaryInfo) CopyTo ¶
func (b BinaryInfo) CopyTo(dir string) (BinaryInfo, error)
type ConfigureControl ¶
type ConfigureControl func(*testcontrol.Server)
ConfigureControl is a test option that configures the test control server.
func (ConfigureControl) ModifyTestEnv ¶
func (f ConfigureControl) ModifyTestEnv(te *TestEnv)
type Daemon ¶
func (*Daemon) MustCleanShutdown ¶
type LogCatcher ¶
type LogCatcher struct {
// contains filtered or unexported fields
}
LogCatcher is a minimal logcatcher for the logtail upload client.
func (*LogCatcher) Reset ¶
func (lc *LogCatcher) Reset()
Reset clears the buffered logs from memory.
func (*LogCatcher) ServeHTTP ¶
func (lc *LogCatcher) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*LogCatcher) StoreRawJSON ¶
func (lc *LogCatcher) StoreRawJSON()
StoreRawJSON instructs lc to save the raw JSON uploads, rather than just the text.
func (*LogCatcher) UseLogf ¶
func (lc *LogCatcher) UseLogf(fn logger.Logf)
UseLogf makes the logcatcher implementation use a given logf function to dump all logs to.
type TestEnv ¶
type TestEnv struct { LogCatcher *LogCatcher LogCatcherServer *httptest.Server Control *testcontrol.Server ControlServer *httptest.Server TrafficTrap *trafficTrap TrafficTrapServer *httptest.Server // contains filtered or unexported fields }
TestEnv contains the test environment (set of servers) used by one or more nodes.
func NewTestEnv ¶
func NewTestEnv(t testing.TB, opts ...TestEnvOpt) *TestEnv
NewTestEnv starts a bunch of services and returns a new test environment. NewTestEnv arranges for the environment's resources to be cleaned up on exit.
func (*TestEnv) ControlURL ¶
ControlURL returns e.ControlServer.URL, panicking if it's the empty string, which it should never be in tests.
type TestEnvOpt ¶
type TestEnvOpt interface { ModifyTestEnv(*TestEnv) }
TestEnvOpt represents an option that can be passed to NewTestEnv.
type TestNode ¶
type TestNode struct {
// contains filtered or unexported fields
}
TestNode is a machine with a tailscale & tailscaled. Currently, the test is simplistic and user==node==machine. That may grow complexity later to test more.
func NewTestNode ¶
NewTestNode allocates a temp directory for a new test node. The node is not started automatically.
func (*TestNode) AwaitBackendState ¶
func (*TestNode) AwaitIP4 ¶
AwaitIP4 returns the IPv4 address of n.
func (*TestNode) AwaitIP6 ¶
AwaitIP6 returns the IPv6 address of n.
func (*TestNode) AwaitIPs ¶
func (*TestNode) AwaitListening ¶
func (n *TestNode) AwaitListening()
AwaitListening waits for the tailscaled to be serving local clients over its localhost IPC mechanism. (Unix socket, etc)
func (*TestNode) AwaitNeedsLogin ¶
func (n *TestNode) AwaitNeedsLogin()
AwaitNeedsLogin waits for n to reach the IPN state "NeedsLogin".
func (*TestNode) AwaitResponding ¶
func (n *TestNode) AwaitResponding()
AwaitResponding waits for n's tailscaled to be up enough to be responding, but doesn't wait for any particular state.
func (*TestNode) AwaitRunning ¶
func (n *TestNode) AwaitRunning()
AwaitRunning waits for n to reach the IPN state "Running".
func (*TestNode) AwaitSocksAddr ¶
func (*TestNode) LocalClient ¶
func (*TestNode) MustDown ¶
func (n *TestNode) MustDown()
func (*TestNode) MustLogOut ¶
func (n *TestNode) MustLogOut()
func (*TestNode) MustStatus ¶
func (*TestNode) MustUp ¶
func (*TestNode) Ping ¶
func (*TestNode) StartDaemon ¶
StartDaemon starts the node's tailscaled, failing if it fails to start. StartDaemon ensures that the process will exit when the test completes.
func (*TestNode) StartDaemonAsIPNGOOS ¶
func (*TestNode) Status ¶
func (*TestNode) Tailscale ¶
Tailscale returns a command that runs the tailscale CLI with the provided arguments. It does not start the process.
func (*TestNode) TailscaleForOutput ¶
Source Files ¶
integration.go tailscaled_deps_test_linux.go
Directories ¶
Path | Synopsis |
---|---|
tstest/integration/nat | |
tstest/integration/testcontrol | Package testcontrol contains a minimal control plane server for testing purposes. |
tstest/integration/vms | Package vms does VM-based integration/functional tests by using qemu and a bank of pre-made VM images. |
- Version
- v1.84.0 (latest)
- Published
- May 21, 2025
- Platform
- linux/amd64
- Imports
- 78 packages
- Last checked
- 2 hours ago –
Tools for package owners.