Documentation
¶
Index ¶
- Constants
- func MachineIds(nodeId string) []string
- func RunDbMirrorSuite(t *testing.T, f *MachineGraph, db amtypes.DbGraph)
- func TreeSpec(depth, fanout int) string
- type DiscoveryOpts
- type Graph
- type GraphOpts
- type MachineGraph
- func (f *MachineGraph) AddState(state string)
- func (f *MachineGraph) AssertSinkGraph()
- func (f *MachineGraph) StartDiscovery(opts ...DiscoveryOpts)
- func (f *MachineGraph) WaitClients(g *amgraph.Graph, machines []*am.Machine)
- func (f *MachineGraph) WaitDiscovery(timeout time.Duration)
- func (f *MachineGraph) WaitGraph(g *amgraph.Graph, machines []*am.Machine)
- func (f *MachineGraph) WaitParents()
- func (f *MachineGraph) WaitSink()
- func (f *MachineGraph) WaitTags(machID string, tags []string)
- type NetNode
- type Node
Constants ¶
const DefaultGraphSpec = `` /* 183-byte string literal not displayed */
const MachinesPerNode = 4
MachinesPerNode is the number of source machines per graph node.
const NetworkGraphPushInterval = 10 * time.Millisecond
NetworkGraphPushInterval is the graph sync interval used by the simulation.
Variables ¶
This section is empty.
Functions ¶
func MachineIds ¶
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.
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 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.