Documentation
¶
Index ¶
- Variables
- func ExecBackground(t *testing.T, processName string, netNS *os.File, name string, args []string) (<-chan error, func() error)
- func StartClientDERP(t *testing.T, logger slog.Logger, serverURL *url.URL, derpMap *tailcfg.DERPMap, ...) *tailnet.Conn
- func StartClientDERPWebSockets(t *testing.T, logger slog.Logger, serverURL *url.URL, derpMap *tailcfg.DERPMap, ...) *tailnet.Conn
- func StartClientDirect(t *testing.T, logger slog.Logger, serverURL *url.URL, derpMap *tailcfg.DERPMap, ...) *tailnet.Conn
- func TestSuite(t *testing.T, _ slog.Logger, serverURL *url.URL, conn *tailnet.Conn, ...)
- type Client
- type ClientNumber
- type ClientStarter
- type NGINXServerOptions
- type ServerStarter
- type SimpleServerOptions
- type TestNetworking
- func SetupNetworkingEasyNAT(t *testing.T, _ slog.Logger) TestNetworking
- func SetupNetworkingEasyNATWithSTUN(t *testing.T, _ slog.Logger) TestNetworking
- func SetupNetworkingHardNATEasyNATDirect(t *testing.T, _ slog.Logger) TestNetworking
- func SetupNetworkingLoopback(t *testing.T, _ slog.Logger) TestNetworking
- type TestNetworkingClient
- type TestNetworkingProcess
- type TestNetworkingSTUN
- type TestNetworkingServer
- type TestTopology
Constants ¶
This section is empty.
Variables ¶
var Client1 = Client{ Number: ClientNumber1, ID: uuid.MustParse("00000000-0000-0000-0000-000000000001"), ListenPort: client1Port, ShouldRunTests: true, }
var Client2 = Client{ Number: ClientNumber2, ID: uuid.MustParse("00000000-0000-0000-0000-000000000002"), ListenPort: client2Port, ShouldRunTests: false, }
Functions ¶
func ExecBackground ¶ added in v2.12.0
func ExecBackground(t *testing.T, processName string, netNS *os.File, name string, args []string) (<-chan error, func() error)
ExecBackground starts a subprocess with the given flags and returns a channel that will receive the error when the subprocess exits. The returned function can be used to close the subprocess.
processName is used to identify the subprocess in logs.
Optionally, a network namespace can be passed to run the subprocess in.
Do not call close then wait on the channel. Use the returned value from the function instead in this case.
Cleanup is handled automatically if you don't care about monitoring the process manually.
func StartClientDERP ¶ added in v2.12.0
func StartClientDERP(t *testing.T, logger slog.Logger, serverURL *url.URL, derpMap *tailcfg.DERPMap, me, peer Client) *tailnet.Conn
StartClientDERP creates a client connection to the server for coordination and creates a tailnet.Conn which will only use DERP to connect to the peer.
func StartClientDERPWebSockets ¶ added in v2.12.0
func StartClientDERPWebSockets(t *testing.T, logger slog.Logger, serverURL *url.URL, derpMap *tailcfg.DERPMap, me, peer Client) *tailnet.Conn
StartClientDERPWebSockets does the same thing as StartClientDERP but will only use DERP WebSocket fallback.
func StartClientDirect ¶ added in v2.12.0
func StartClientDirect(t *testing.T, logger slog.Logger, serverURL *url.URL, derpMap *tailcfg.DERPMap, me, peer Client) *tailnet.Conn
StartClientDirect does the same thing as StartClientDERP but disables BlockEndpoints (which enables Direct connections), and waits for a direct connection to be established between the two peers.
Types ¶
type Client ¶ added in v2.12.0
type Client struct { Number ClientNumber ID uuid.UUID ListenPort uint16 ShouldRunTests bool }
type ClientNumber ¶ added in v2.12.0
type ClientNumber int
const ( ClientNumber1 ClientNumber = 1 ClientNumber2 ClientNumber = 2 )
type ClientStarter ¶ added in v2.12.0
type NGINXServerOptions ¶ added in v2.12.0
type NGINXServerOptions struct {
SimpleServerOptions
}
func (NGINXServerOptions) StartServer ¶ added in v2.12.0
type ServerStarter ¶ added in v2.12.0
type SimpleServerOptions ¶ added in v2.12.0
type SimpleServerOptions struct { // FailUpgradeDERP will make the DERP server fail to handle the initial DERP // upgrade in a way that causes the client to fallback to // DERP-over-WebSocket fallback automatically. // Incompatible with DERPWebsocketOnly. FailUpgradeDERP bool // DERPWebsocketOnly will make the DERP server only accept WebSocket // connections. If a DERP request is received that is not using WebSocket // fallback, the test will fail. // Incompatible with FailUpgradeDERP. DERPWebsocketOnly bool }
func (SimpleServerOptions) Router ¶ added in v2.12.0
func (o SimpleServerOptions) Router(t *testing.T, logger slog.Logger) *chi.Mux
func (SimpleServerOptions) StartServer ¶ added in v2.12.0
type TestNetworking ¶
type TestNetworking struct { Server TestNetworkingServer STUNs []TestNetworkingSTUN Client1 TestNetworkingClient Client2 TestNetworkingClient }
func SetupNetworkingEasyNAT ¶ added in v2.12.0
func SetupNetworkingEasyNAT(t *testing.T, _ slog.Logger) TestNetworking
SetupNetworkingEasyNAT creates a fake internet and sets up "easy NAT" forwarding rules. See createFakeInternet. NAT is achieved through a single iptables masquerade rule.
func SetupNetworkingEasyNATWithSTUN ¶ added in v2.12.0
func SetupNetworkingEasyNATWithSTUN(t *testing.T, _ slog.Logger) TestNetworking
SetupNetworkingEasyNATWithSTUN does the same as SetupNetworkingEasyNAT, but also creates a namespace and bridge address for a STUN server.
func SetupNetworkingHardNATEasyNATDirect ¶ added in v2.12.0
func SetupNetworkingHardNATEasyNATDirect(t *testing.T, _ slog.Logger) TestNetworking
func SetupNetworkingLoopback ¶
func SetupNetworkingLoopback(t *testing.T, _ slog.Logger) TestNetworking
SetupNetworkingLoopback creates a network namespace with a loopback interface for all tests to share. This is the simplest networking setup. The network namespace only exists for isolation on the host and doesn't serve any routing purpose.
type TestNetworkingClient ¶ added in v2.12.0
type TestNetworkingClient struct { Process TestNetworkingProcess // ServerAccessURL is the hostname and port that the client uses to access // the server over HTTP for coordination. ServerAccessURL string // DERPMap is the DERP map that the client uses. If nil, a basic DERP map // containing only a single DERP with `ServerAccessURL` is used with no // STUN servers. DERPMap *tailcfg.DERPMap }
func (TestNetworkingClient) ResolveDERPMap ¶ added in v2.12.0
func (c TestNetworkingClient) ResolveDERPMap() (*tailcfg.DERPMap, error)
type TestNetworkingProcess ¶
type TestNetworkingSTUN ¶ added in v2.12.0
type TestNetworkingSTUN struct { Process TestNetworkingProcess IP string ListenAddr string }
type TestNetworkingServer ¶ added in v2.12.0
type TestNetworkingServer struct { Process TestNetworkingProcess ListenAddr string }
type TestTopology ¶
type TestTopology struct { Name string // SetupNetworking creates interfaces and network namespaces for the test. // The most simple implementation is NetworkSetupDefault, which only creates // a network namespace shared for all tests. SetupNetworking func(t *testing.T, logger slog.Logger) TestNetworking // Server is the server starter for the test. It is executed in the server // subprocess. Server ServerStarter // StartClient gets called in each client subprocess. It's expected to // create the tailnet.Conn and ensure connectivity to it's peer. StartClient func(t *testing.T, logger slog.Logger, serverURL *url.URL, derpMap *tailcfg.DERPMap, me Client, peer Client) *tailnet.Conn // RunTests is the main test function. It's called in each of the client // subprocesses. If tests can only run once, they should check the client ID // and return early if it's not the expected one. RunTests func(t *testing.T, logger slog.Logger, serverURL *url.URL, conn *tailnet.Conn, me Client, peer Client) }