testnetwork

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package testnetwork holds the e2e labs: nodes booted through the node's own assembly, services.BootApp, on the loopback hosts the labs draw, beside the fixtures every lab package shares — the nodes' boots, the bubbles, the address draws, and the polls; the test WebPKI standing in for the core's certificate authority comes from pkg/core/webpki/webpkitest. The labs import the node's assembly, so no package under pkg can host them.

Beside the brake's labs, which check that a link brakes under a load past its line, and only then, and lets go once the load leaves, the brake's benchmarks grade how well a braked link serves: what its line drops and carries, what its flows deliver, and how long a link holds a rate under jitter or after a step in its round trip. They are skipped unless CION_BENCH is set, and each prints a benchmark result line on standard output for benchstat:

CION_BENCH=1 go test -run Bench -count=5 -timeout 60m -v ./internal/testnetwork/

Index

Constants

View Source
const (
	Propagation  = 100 * time.Millisecond
	Registration = 200 * time.Millisecond
	EnrollRetry  = 100 * time.Millisecond
	TestTimeout  = 20 * time.Second
	// RestartTimeout budgets the restart lab's convergence: the reboot puts
	// the joiner's loop through serial stages — re-rendezvous, a fresh
	// prompt, the press, the chain — whose wall-clock pacing stretches
	// several-fold on a loaded runner under the race detector, where the
	// fixed TestTimeout missed a pipeline still progressing.
	RestartTimeout = 3 * TestTimeout
	// OnboardTimeout budgets a core's onboarding the same way: its
	// enrollment, the submission the founder decides, the pin, the issuer's
	// anchoring, and the renewal that first issues under its own root run in
	// series.
	OnboardTimeout = 3 * TestTimeout
	// PathTimeout budgets the first path across a line of nodes the same
	// way: the beacons each hop propagates, the registrations, and the
	// lookup that composes the path run in series.
	PathTimeout = 3 * TestTimeout
)

Test intervals, fast enough for the integration tests to watch the loops.

Variables

This section is empty.

Functions

func FreeUDPAddrOn

func FreeUDPAddrOn(t *testing.T, ip netip.Addr) string

FreeUDPAddrOn returns a free UDP address on the given host.

func HostSlot added in v0.0.10

func HostSlot(t *testing.T) netip.Addr

HostSlot draws the next loopback host of the pool the process's labs share, so two labs overlap freely, a repeated run draws fresh hosts, and no two draws name one host. The pool starts at 127.0.1.1, above 127.0.0.0/24 — that /24 belongs to the other packages' fixed loopback mounts, and go test runs the packages' processes in parallel — and a draw past the pool's end refuses instead of wrapping. The behavior labs' process draws the same hosts as names on fabrics, where no kernel socket binds them.

func InBubble added in v0.0.10

func InBubble(t *testing.T, body func(t *testing.T, f *fabric.Fabric, wpki *webpkitest.CA))

InBubble runs a lab's body inside a synctest bubble, on virtual time: the fabric, its stacks UDP-only, and the test CA are made inside the bubble, for the fabric's clock and the CA's validity window both read the time at their creation — the CA's twenty-four hours then bound the lab's virtual run. Every cleanup the body registers runs inside the bubble before the bubble drains, so a goroutine the lab leaks fails the lab at its exit. A lab that needs a process of its own re-executes before it enters: the re-execution cannot run inside a bubble.

func PinnedTCPAddrOn

func PinnedTCPAddrOn(t *testing.T, ip netip.Addr) string

PinnedTCPAddrOn returns a TCP address on the given host for a listener to bind: the band's next free port, probed by listening on it and released for the listener's own bind, safe for the same reason as PinnedUDPAddrOn.

func PinnedUDPAddrOn

func PinnedUDPAddrOn(t *testing.T, ip netip.Addr) string

PinnedUDPAddrOn returns a UDP address on the given host for the node to rebind: the band's next free port, probed by binding it and released for the node's own bind. The release is safe — nothing that binds :0 draws from the band.

func Poll

func Poll(t *testing.T, what string, cond func() bool)

Poll waits for cond to hold, failing the test at the timeout.

func PollErr

func PollErr(t *testing.T, what string, attempt func() error)

PollErr waits for attempt to return nil, failing the test at the timeout with the last error attempt returned.

func PollFor

func PollFor(t *testing.T, budget time.Duration, what string, cond func() bool)

PollFor is Poll under an explicit budget, for labs whose convergence outgrows TestTimeout on a loaded runner.

func PollVirtual added in v0.0.10

func PollVirtual(t *testing.T, budget time.Duration, what string, cond func() bool)

PollVirtual is PollFor inside a synctest bubble: the budget is virtual time, spent at no wall-clock cost but the work it carries, and each check runs once every other goroutine in the bubble has parked.

func Wildcard added in v0.0.10

func Wildcard(addr string) string

Wildcard returns the address's port on the IPv4 wildcard: the bind that receives at every host the node's stack holds, the daemon's default.

Types

type Flow added in v0.0.10

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

Flow is a stream of datagrams one node sends another at a rate, over the path the sender's path library leases: the sender's conn rides the node's internal link and marks no control class, so its packets cross every transit as data. The receiver counts what arrives and reads each datagram's one-way delay on the clock both ends share.

func StartFlow added in v0.0.10

func StartFlow(t *testing.T, from, to *Node, port uint16, rate int64, size int) *Flow

StartFlow starts a flow of rate bits per second of datagrams of size bytes from one node to the port of another, until Stop or the test ends. The sender awaits its lease's first path to the receiver, asking again each flowRetry, then offers a datagram at random times, a mean of size bytes at the rate apart — the arrivals of a Poisson process, so that flows never lock in step with each other or with a queue — and reads the lease's path for each: one with no path counts as offered and unsent.

func (*Flow) Stop added in v0.0.10

func (fl *Flow) Stop()

Stop ends the flow, returning once its sender and receiver have; a window read after it counts what arrived before.

func (*Flow) Window added in v0.0.10

func (fl *Flow) Window() FlowWindow

Window returns what the flow carried since the window before, or since it started, and starts the next.

type FlowWindow added in v0.0.10

type FlowWindow struct {
	Offered int
	Delays  []time.Duration
}

FlowWindow is what a flow carried over a window: the datagrams offered, and the one-way delays of those received, ascending.

func (FlowWindow) Add added in v0.0.10

func (w FlowWindow) Add(o FlowWindow) FlowWindow

Add returns the window of both flows' datagrams: the offered summed, the delays merged.

func (FlowWindow) DeliveredShare added in v0.0.10

func (w FlowWindow) DeliveredShare() float64

DeliveredShare returns the share of the window's offered datagrams that arrived; zero for none offered. A datagram sent at a window's end and received in the next counts there, so a share may pass one.

func (FlowWindow) Quantile added in v0.0.10

func (w FlowWindow) Quantile(q float64) time.Duration

Quantile returns the delay at the quantile q of those received, by nearest rank; zero for none received.

func (FlowWindow) Received added in v0.0.10

func (w FlowWindow) Received() int

Received returns how many of the window's datagrams arrived.

type Node added in v0.0.10

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

Node is a node booted through the run command's own assembly.

func BootInBubble added in v0.0.10

func BootInBubble(
	t *testing.T, f *fabric.Fabric, host netip.Addr,
	mutate func(*services.NodeConfig),
) *Node

BootInBubble boots a node on a bubble's fabric at the daemon's own pacing: under virtual time a lab's cost is the work each virtual second carries, so the production intervals are the cheap ones, and they are the ratios the node runs at.

func (*Node) App added in v0.0.10

func (n *Node) App() *services.App

App returns the node's assembly.

func (*Node) Host added in v0.0.10

func (n *Node) Host() netip.Addr

Host returns the address the labs name the node by: the control address's host, or the fabric's host it booted on under a wildcard bind.

func (*Node) StateDir added in v0.0.10

func (n *Node) StateDir() string

StateDir returns the node's state directory: a node booted on it again returns with the identity, chain, and links it held.

func (*Node) Stop added in v0.0.10

func (n *Node) Stop(t *testing.T)

Stop stops the node, its loops returned and its resources released when Stop returns, and fails the test on the node's stop result.

Directories

Path Synopsis
Package behavior holds the behavior labs: whole networks booted through the node's own assembly on the userspace fabric, run inside synctest bubbles at the daemon's own pacing, each asserting what the selection policy makes of the network across many windows — that a cut heals, that the link set settles, that every pair then reaches over its chosen path, the path the source's lease of the destination holds.
Package behavior holds the behavior labs: whole networks booted through the node's own assembly on the userspace fabric, run inside synctest bubbles at the daemon's own pacing, each asserting what the selection policy makes of the network across many windows — that a cut heals, that the link set settles, that every pair then reaches over its chosen path, the path the source's lease of the destination holds.
Package fabric is the integration labs' userspace network: one gVisor netstack per node — the egress application's own recipe — connected by a forwarder the harness owns, so a lab's nodes hold no kernel port at all and the network's behaviors are taps the lab draws: delay, loss, blackhole, cut, and the NAT, on whose router a node may run.
Package fabric is the integration labs' userspace network: one gVisor netstack per node — the egress application's own recipe — connected by a forwarder the harness owns, so a lab's nodes hold no kernel port at all and the network's behaviors are taps the lab draws: delay, loss, blackhole, cut, and the NAT, on whose router a node may run.

Jump to

Keyboard shortcuts

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