integration

package
v0.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2023 License: BSD-3-Clause Imports: 16 Imported by: 0

README

Integration testing

Headscale relies on integration testing to ensure we remain compatible with Tailscale.

This is typically performed by starting a Headscale server and running a test "scenario" with an array of Tailscale clients and versions.

Headscale's test framework and the current set of scenarios are defined in this directory.

Tests are located in files ending with _test.go and the framework are located in the rest.

Running integration tests on GitHub Actions

Each test currently runs as a separate workflows in GitHub actions, to add new test, add the new test to the list in ../cmd/gh-action-integration-generator/main.go and run go generate inside ../cmd/gh-action-integration-generator/ and commit the result.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TailscaleVersions = append(
		tailscaleVersions2021,
		tailscaleVersions2019...,
	)
)

Functions

This section is empty.

Types

type ControlServer

type ControlServer interface {
	Shutdown() error
	Execute(command []string) (string, error)
	GetHealthEndpoint() string
	GetEndpoint() string
	WaitForReady() error
	CreateNamespace(namespace string) error
	CreateAuthKey(namespace string, reusable bool, ephemeral bool) (*v1.PreAuthKey, error)
	ListMachinesInNamespace(namespace string) ([]*v1.Machine, error)
	GetCert() []byte
	GetHostname() string
	GetIP() string
}

type Namespace

type Namespace struct {
	Clients map[string]TailscaleClient
	// contains filtered or unexported fields
}

type Scenario

type Scenario struct {
	// contains filtered or unexported fields
}

TODO(kradalby): make control server configurable, test correctness with Tailscale SaaS.

func NewScenario

func NewScenario() (*Scenario, error)

func (*Scenario) CountTailscale

func (s *Scenario) CountTailscale() int

func (*Scenario) CreateHeadscaleEnv

func (s *Scenario) CreateHeadscaleEnv(
	namespaces map[string]int,
	tsOpts []tsic.Option,
	opts ...hsic.Option,
) error

CreateHeadscaleEnv is a conventient method returning a set up Headcale test environment with nodes of all versions, joined to the server with X namespaces.

func (*Scenario) CreateNamespace

func (s *Scenario) CreateNamespace(namespace string) error

func (*Scenario) CreatePreAuthKey

func (s *Scenario) CreatePreAuthKey(namespace string, reusable bool, ephemeral bool) (*v1.PreAuthKey, error)

func (*Scenario) CreateTailscaleNodesInNamespace

func (s *Scenario) CreateTailscaleNodesInNamespace(
	namespaceStr string,
	requestedVersion string,
	count int,
	opts ...tsic.Option,
) error

func (*Scenario) GetClients

func (s *Scenario) GetClients(namespace string) ([]TailscaleClient, error)

func (*Scenario) GetIPs

func (s *Scenario) GetIPs(namespace string) ([]netip.Addr, error)

func (*Scenario) Headscale

func (s *Scenario) Headscale(opts ...hsic.Option) (ControlServer, error)

TODO(kradalby): make port and headscale configurable, multiple instances support?

func (*Scenario) ListTailscaleClients

func (s *Scenario) ListTailscaleClients(namespaces ...string) ([]TailscaleClient, error)

func (*Scenario) ListTailscaleClientsFQDNs

func (s *Scenario) ListTailscaleClientsFQDNs(namespaces ...string) ([]string, error)

func (*Scenario) ListTailscaleClientsIPs

func (s *Scenario) ListTailscaleClientsIPs(namespaces ...string) ([]netip.Addr, error)

func (*Scenario) Namespaces

func (s *Scenario) Namespaces() []string

func (*Scenario) RunTailscaleUp

func (s *Scenario) RunTailscaleUp(
	namespaceStr, loginServer, authKey string,
) error

func (*Scenario) Shutdown

func (s *Scenario) Shutdown() error

func (*Scenario) WaitForTailscaleLogout added in v0.18.0

func (s *Scenario) WaitForTailscaleLogout()

func (*Scenario) WaitForTailscaleSync

func (s *Scenario) WaitForTailscaleSync() error

type TailscaleClient

type TailscaleClient interface {
	Hostname() string
	Shutdown() error
	Version() string
	Execute(command []string) (string, string, error)
	Up(loginServer, authKey string) error
	UpWithLoginURL(loginServer string) (*url.URL, error)
	Logout() error
	IPs() ([]netip.Addr, error)
	FQDN() (string, error)
	Status() (*ipnstate.Status, error)
	WaitForReady() error
	WaitForLogout() error
	WaitForPeers(expected int) error
	Ping(hostnameOrIP string) error
	ID() string
}

nolint

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL