stressagent

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package stressagent runs a fleet of fake nodes against a real control plane. Each node enrolls and holds a session through the production agent client, backed by an in-memory container runtime.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Addr is the control plane agent listener (host:port).
	Addr       string
	Count      int
	NamePrefix string
	Token      TokenSource
	// HeartbeatInterval of zero keeps the agent default.
	HeartbeatInterval time.Duration
	Logger            *slog.Logger
}

Config describes the fleet.

type Fleet

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

Fleet is a set of enrolled, connected fake nodes.

func Start

func Start(ctx context.Context, cfg Config) (*Fleet, error)

Start enrolls Count nodes and keeps a session open for each until Stop.

func (*Fleet) Containers

func (f *Fleet) Containers() int

Containers counts containers across the fleet.

func (*Fleet) NodeIDs

func (f *Fleet) NodeIDs() []string

NodeIDs returns the control plane's ids for the enrolled nodes, in enrollment order.

func (*Fleet) Sessions

func (f *Fleet) Sessions() int64

Sessions counts session attempts across the fleet, so reconnect churn is visible.

func (*Fleet) Stop

func (f *Fleet) Stop()

Stop ends every session and waits for the nodes to return.

type Runtime

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

Runtime is an in-memory container runtime: created containers start instantly and stay running.

func NewRuntime

func NewRuntime() *Runtime

NewRuntime returns an empty runtime.

func (*Runtime) Count

func (r *Runtime) Count() int

Count reports how many containers exist.

func (*Runtime) Create

func (r *Runtime) Create(_ context.Context, spec docker.ContainerSpec) (string, error)

Create records a stopped container.

func (*Runtime) EnsureNetwork

func (r *Runtime) EnsureNetwork(_ context.Context, name string) (string, error)

EnsureNetwork records the network and returns a stable id.

func (*Runtime) EnsureVolume

func (r *Runtime) EnsureVolume(context.Context, string) error

EnsureVolume is accepted and ignored.

func (*Runtime) Events

func (r *Runtime) Events(ctx context.Context) (<-chan docker.Event, <-chan error)

Events never emits; it only closes when ctx ends.

func (*Runtime) Exec

Exec is not supported: stress nodes run no processes.

func (*Runtime) ExecWithInput

func (r *Runtime) ExecWithInput(context.Context, string, []string, io.Reader) (io.ReadCloser, error)

ExecWithInput is not supported: stress nodes run no processes.

func (*Runtime) InspectByName

func (r *Runtime) InspectByName(_ context.Context, name string) (*docker.ContainerState, error)

InspectByName returns a copy of the container, or nil when absent.

func (*Runtime) ListByPrefix

func (r *Runtime) ListByPrefix(_ context.Context, prefix string) ([]docker.ContainerState, error)

ListByPrefix returns containers whose name starts with prefix, sorted by name.

func (*Runtime) ListImages

func (r *Runtime) ListImages(context.Context, string) ([]docker.ImageInfo, error)

ListImages reports no local images.

func (*Runtime) ListNetworksByPrefix

func (r *Runtime) ListNetworksByPrefix(_ context.Context, prefix string) ([]docker.NetworkInfo, error)

ListNetworksByPrefix returns networks whose name starts with prefix.

func (*Runtime) NetworkConnect

func (r *Runtime) NetworkConnect(context.Context, string, string) error

NetworkConnect is accepted and ignored.

func (*Runtime) NetworkDisconnect

func (r *Runtime) NetworkDisconnect(context.Context, string, string, bool) error

NetworkDisconnect is accepted and ignored.

func (*Runtime) Remove

func (r *Runtime) Remove(_ context.Context, id string, _ bool) error

Remove deletes the container.

func (*Runtime) RemoveNetwork

func (r *Runtime) RemoveNetwork(_ context.Context, name string) error

RemoveNetwork forgets the network.

func (*Runtime) Start

func (r *Runtime) Start(_ context.Context, id string) error

Start marks the container running.

func (*Runtime) Stop

func (r *Runtime) Stop(_ context.Context, id string, _ time.Duration) error

Stop marks the container not running.

func (*Runtime) UpdateResources

func (r *Runtime) UpdateResources(context.Context, string, docker.Resources) error

UpdateResources is accepted and ignored.

type TokenSource

type TokenSource func(ctx context.Context, nodeName string) (string, error)

TokenSource returns a fresh join token for the named node.

Jump to

Keyboard shortcuts

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