Documentation
¶
Overview ¶
Package testenv is what the two live suites share: the servers .scripts/testenv.sh started for them, and which of the three ways technitium-mcp is used they stand for - one server, two that know nothing of each other, or two that are a cluster. The machinery for reading the environment is go-kt's (test/env).
The SDK suite (acceptance/technitium) drives the client in sdk/technitium and the tool suite (acceptance/tools) drives the tools over MCP. Each runs three times on the same servers, in order: on one server, then with a second started beside it, then with the two made a cluster - which this package does, through the client, as part of opening the third.
It is also where a machine asks the servers for a lease (Lease): the one thing the suites need that no API makes.
Index ¶
- Constants
- func Configured() bool
- type Pool
- type Topology
- type World
- func (w *World) Address(name string) string
- func (w *World) Client(name string) (*technitium.Client, error)
- func (w *World) Domain(name string) string
- func (w *World) Join(ctx context.Context, joiner, primary string) error
- func (w *World) Lease(ctx context.Context, hardwareAddress, hostName string) error
- func (w *World) Names() []string
- func (*World) Password() string
- func (*World) Pool() (Pool, bool)
- func (w *World) Secrets() []string
- func (w *World) Settled(ctx context.Context, name string) (*technitium.Cluster, bool)
- func (w *World) TakingApart() bool
Constants ¶
const ( // NS1 and NS2 are the two servers .scripts/testenv.sh starts, by the // names it gives them when there are two. NS1 = "ns1" NS2 = "ns2" // ClusterDomain is the domain the suites' cluster is made under, and // ClusterCatalog the catalog zone a cluster makes for itself there: a // zone made a member of it on the primary is given to every node. ClusterDomain = "cluster.test" ClusterCatalog = "cluster-catalog." + ClusterDomain // NotConfigured is why a live test skips when the environment names no // servers. NotConfigured = `TECHNITIUM_SERVER and TECHNITIUM_TOKEN are not set: run "make testacc", or eval "$(.scripts/testenv.sh up)" first` )
Variables ¶
This section is empty.
Functions ¶
func Configured ¶
func Configured() bool
Configured reports whether the environment names servers and tokens for them.
Types ¶
type Pool ¶
type Pool struct {
// Subnet is the whole network, and Mask its mask as a DHCP scope takes
// one
Subnet netip.Prefix
Mask string
// First and Last are the range to lease from
First, Last netip.Addr
}
Pool is the part of the network the servers share that the suites lease from: its last addresses, all in one /24, far from the ones Docker gives the containers from the other end.
func (Pool) ReverseZone ¶
ReverseZone is the reverse zone the whole range falls in.
type Topology ¶
type Topology string
Topology is one of the ways the servers under test are arranged.
const ( // Single is one server, configured as one is: an address and a token, // with no name. Single Topology = "single" // Pair is two servers that know nothing of each other. Pair Topology = "pair" // Cluster is two servers in a cluster, the first its primary node. Cluster Topology = "cluster" )
type World ¶
type World struct {
Topology Topology
Set *servers.Set
// First is the name of the server the suites make their zones on: the
// only one, or the first of two, which in a cluster is its primary node
First string
// Second is the other server's name, "" when there is one
Second string
// contains filtered or unexported fields
}
World is the servers a live suite runs against and how they are arranged.
func Open ¶
Open reads the environment and returns the servers arranged as it asks (TECHNITIUM_TEST_TOPOLOGY: single, pair or cluster; with none, single for one server and pair for two). The arrangement asked for is checked against what is there, and for cluster it is made: the first server is made the primary node of a new cluster and the second joins it, both through the client, unless they already are one.
func (*World) Address ¶
Address is a server's address on the network the servers share, which is where another server reaches its DNS.
func (*World) Client ¶
func (w *World) Client(name string) (*technitium.Client, error)
Client is the client for one of the servers by name.
func (*World) Domain ¶
Domain is the domain name a server calls itself: the name the script gave it, under the cluster's domain once it is a node of one.
func (*World) Join ¶
Join has one of the two servers join the cluster the other is the primary of, and waits until it holds the cluster's zones. Both are asked with the cluster's token, which a server that has left a cluster still takes.
func (*World) Lease ¶
Lease has a machine ask the servers for an address: a DHCP client run for a moment in a container of its own on the network they share, with the hardware address given and, when one is given, a host name to tell the server. It takes whatever lease it is offered, sets nothing by it, and is gone; the server goes on holding the lease. The address it was given is the server's to say.
func (*World) Password ¶
Password is the administrator's password on the servers .scripts/testenv.sh started, which signing in to one takes.
func (*World) Pool ¶
Pool is the range the suites lease from, and whether the environment gave what leasing needs: the network's name and range and a DHCP client's image, as .scripts/testenv.sh prints them. Servers started some other way lease nothing, and the tests that need a lease skip.
func (*World) Secrets ¶ added in v0.2.0
Secrets are the servers' own credentials, for a suite to watch every tool's answer for: the administrator's password and each API token.
func (*World) Settled ¶
Settled asks a server how it stands in a cluster, waiting out a console that is restarting, as one does when it joins or leaves. It reports false when the server never answers.
func (*World) TakingApart ¶
TakingApart reports whether this run is the one that ends a suite by taking its cluster apart, which nothing can run after: make starts it last, alone (see the makefile's testacc-sdk).