test

package
v0.19.8 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 19 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

Index

Constants

View Source
const DefaultGraphSpec = `` /* 183-byte string literal not displayed */
View Source
const MachinesPerNode = 4

MachinesPerNode is the number of source machines per graph node.

View Source
const NetworkGraphPushInterval = 10 * time.Millisecond

NetworkGraphPushInterval is the graph sync interval used by the simulation.

Variables

This section is empty.

Functions

func MachineIds

func MachineIds(nodeId string) []string

MachineIds returns the machine IDs owned by a graph node.

func RunDbMirrorSuite

func RunDbMirrorSuite(t *testing.T, f *MachineGraph, db amtypes.DbGraph)

RunDbMirrorSuite attaches db to f's sink, serves it over HTTP+JSON, triggers a fresh update burst, and asserts the mirrored model against the fixture. It's backend-agnostic, so any amtypes.DbGraph implementation can run it.

func TreeSpec added in v0.19.8

func TreeSpec(depth, fanout int) string

TreeSpec returns a deterministic tree spec with the given depth and fanout. The root is "sink"; children are IDs like "node-1", "node-1-2", which [parseSpec] links by trimming the last "-" segment.

Types

type DiscoveryOpts added in v0.19.8

type DiscoveryOpts struct {
	// SinkOnly runs discovery only on the sink, dialing every source machine
	// visible to it.
	SinkOnly bool
}

DiscoveryOpts configures MachineGraph.StartDiscovery.

type Graph

type Graph struct {
	Root     string
	Nodes    []Node
	ByID     map[string]*Node
	Children map[string][]string
}

Graph is a parsed Graph specification.

type GraphOpts added in v0.19.8

type GraphOpts struct {
	// SinkDb mirrors the sink's graph into a DB from the start.
	SinkDb amtypes.DbGraph
	// MachinesPerNode is the number of source machines per node. Defaults to
	// [MachinesPerNode].
	MachinesPerNode int
	// Quiet disables printing the topology for large graphs.
	Quiet bool
	// NoRandomTags disables random src-id tags on source machines.
	NoRandomTags bool
	// WaitTimeout is the graph sync wait timeout. Defaults to 3s.
	WaitTimeout time.Duration
	// NetOpts are extra [amgraph.NetworkGraphOpts] applied to every node
	// (tests). Only Listener and Dial are honored.
	NetOpts amgraph.NetworkGraphOpts
}

GraphOpts configures NewMachineGraph.

type MachineGraph

type MachineGraph struct {
	T             *testing.T
	Nodes         []*NetNode
	ByID          map[string]*NetNode
	Sink          *NetNode
	Parents       []string
	Children      map[string][]*NetNode
	RelayExpected map[string][]*am.Machine
	NodeMachines  map[string][]*am.Machine
	Machines      []*am.Machine
	Idx           int

	Servers map[string]*arpc.Server
	Clients []*arpc.Client
	// contains filtered or unexported fields
}

MachineGraph is a reusable multi-node NetworkGraph test fixture.

func NewMachineGraph

func NewMachineGraph(
	t *testing.T, ctx context.Context, specText string, opts ...GraphOpts,
) *MachineGraph

NewMachineGraph creates the supplied machine topology over UDP.

func (*MachineGraph) AddState

func (f *MachineGraph) AddState(state string)

AddState applies a state to every traced machine.

func (*MachineGraph) AssertSinkGraph

func (f *MachineGraph) AssertSinkGraph()

AssertSinkGraph validates the sink graph's machines, clocks, and relations.

func (*MachineGraph) StartDiscovery added in v0.19.8

func (f *MachineGraph) StartDiscovery(opts ...DiscoveryOpts)

StartDiscovery starts one RPC server per node, advertises it as an #addr tag, and dials every #addr discovered through the local NetworkGraph. Every connection is a real TCP RPC client, mirrored as a CONNECTED_TO edge.

func (*MachineGraph) WaitClients

func (f *MachineGraph) WaitClients(g *amgraph.Graph, machines []*am.Machine)

WaitClients waits until all machines have any clock data in a graph.

func (*MachineGraph) WaitDiscovery added in v0.19.8

func (f *MachineGraph) WaitDiscovery(timeout time.Duration)

WaitDiscovery waits until the configured scope dialed all its descendants.

func (*MachineGraph) WaitGraph

func (f *MachineGraph) WaitGraph(g *amgraph.Graph, machines []*am.Machine)

WaitGraph waits until all machines are present in a graph.

func (*MachineGraph) WaitParents

func (f *MachineGraph) WaitParents()

WaitParents waits until every forwarding node mirrors its children.

func (*MachineGraph) WaitSink

func (f *MachineGraph) WaitSink()

WaitSink waits until the sink mirrors all machines.

func (*MachineGraph) WaitTags

func (f *MachineGraph) WaitTags(machID string, tags []string)

WaitTags waits until a sink client reflects the expected tags.

type NetNode

type NetNode struct {
	ID       string
	ParentID string
	Machines []*am.Machine
	Server   *am.Machine
	Graph    *amgraph.Graph
	Net      *amgraph.NetworkGraph
	// contains filtered or unexported fields
}

NetNode is one NetworkGraph node with locally traced machines.

type Node

type Node struct {
	ID       string
	Parent   string
	Children []string
}

Node is a parsed Graph node.

Jump to

Keyboard shortcuts

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