integration

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 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
	CreateUser(user string) error
	CreateAuthKey(user string, reusable bool, ephemeral bool) (*v1.PreAuthKey, error)
	ListMachinesInUser(user string) ([]*v1.Machine, error)
	GetCert() []byte
	GetHostname() string
	GetIP() string
}

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(
	users 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 users.

func (*Scenario) CreatePreAuthKey

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

func (*Scenario) CreateTailscaleNodesInUser added in v0.19.0

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

func (*Scenario) CreateUser added in v0.19.0

func (s *Scenario) CreateUser(user string) error

func (*Scenario) GetClients

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

func (*Scenario) GetIPs

func (s *Scenario) GetIPs(user 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(users ...string) ([]TailscaleClient, error)

func (*Scenario) ListTailscaleClientsFQDNs

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

func (*Scenario) ListTailscaleClientsIPs

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

func (*Scenario) RunTailscaleUp

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

func (*Scenario) Shutdown

func (s *Scenario) Shutdown() error

func (*Scenario) Users added in v0.19.0

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

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

type User added in v0.19.0

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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