coordinator

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAgentNotFound = errors.New("agent not found")

Functions

This section is empty.

Types

type AgentCommandRunningPayload

type AgentCommandRunningPayload struct {
	Command     string    `json:"command"`
	Params      []string  `json:"params"`
	Environment []string  `json:"env"`
	Started     time.Time `json:"started"`
	AgentID     int32     `json:"agentID"`
	CommandID   string    `json:"commandID"`
}

type ConnectedAgent

type ConnectedAgent struct {
	// The ID for the connected agent
	ID int32 `json:"id"`

	// Most recently received system information for this agent
	SystemInfo common.AgentSystemInfo `json:"systemInfo"`
	// The binary version of the agent binary that connected
	AgentVersion string `json:"agentVersion"`
	// The current ping roundtrip time as measured from the coordinator
	PingRTT float64 `json:"pingRTT"`
	// contains filtered or unexported fields
}

ConnectedAgent holds the information for a currently connected test agent

type ConnectedAgentCountChangedPayload

type ConnectedAgentCountChangedPayload struct {
	Count     int `json:"count"`
	Debounced bool
}

type ConnectedUsersChangedPayload

type ConnectedUsersChangedPayload struct {
	Count int `json:"count"`
}

type Coordinator

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

Coordinator is the main type that manages the connections to the test agents

func NewCoordinator

func NewCoordinator(ev chan Event, port int) (*Coordinator, error)

NewCoordinator creates a new instance of the Coordinator type, listening on the port identified by the `port` argument, and using the `ev` argument to send real-time updates to. Returns an error if unable to listen for new connections

func (*Coordinator) GetAgent

func (c *Coordinator) GetAgent(agentID int32) (*ConnectedAgent, error)

GetAgent returns the ConnectedAgent instance referenced by the passed agentID Returns ErrAgentNotFound if there is no agent with the given agentID

func (*Coordinator) GetAgentCount

func (c *Coordinator) GetAgentCount() int

GetAgentCount returns the currently connected number of agents

func (*Coordinator) GetAgents

func (c *Coordinator) GetAgents() []*ConnectedAgent

GetAgents returns a copy of the slice of all agents that are currently connected

func (*Coordinator) GetMaintenance

func (c *Coordinator) GetMaintenance() bool

GetMaintenance returns the current maintenance mode status of the system

func (*Coordinator) RegisterCommandStatusCallback

func (c *Coordinator) RegisterCommandStatusCallback(
	agentID int32,
	commandID []byte,
	replyChan chan wire.Msg,
) error

RegisterCommandStatusCallback will register a listener for all update messages that pertain to the command specified by commandID, running on the agent specified by agentID and will deliver those updates to replyChan

func (*Coordinator) RunServer

func (c *Coordinator) RunServer() error

RunServer is the main loop for the endpoint that agents connect to - it will wait for new connections and then handle those in a separate goroutine.

func (*Coordinator) SendToAgent

func (c *Coordinator) SendToAgent(
	agentID int32,
	msg wire.Msg,
	replyChan chan wire.Msg,
) error

SendToAgent send a wire message to an agent, and registers a listener for the reply to that message's ID that will deliver the response to replyChan

func (*Coordinator) SetMaintenance

func (c *Coordinator) SetMaintenance(maint bool)

SetMaintenance sets the current maintenance mode state of the system. If the system is in maintenance mode, test runs will not be executed. You can queue new tests, but they will not be run until the maintenance mode is turned off. Maintenance mode can be handy when deploying new versions of the test controller through the build pipeline, as (re)deploying the controller in the middle of a test run will terminate and invalidate that testrun.

type Event

type Event struct {
	Type    EventType    `json:"type"`
	Payload EventPayload `json:"payload"`
}

Event describes real-time updates sent by the coordinator to the frontend through a web socket. These events are used to update the client-side state in real time when test runs are updated

type EventPayload

type EventPayload interface{}

type EventType

type EventType string
const EventTypeConnectedAgentCountChanged EventType = "agentCountChanged"

EventTypeConnectedAgentCountChanged is fired when the number of connected agent changes by connecting or disconnecting agents

const EventTypeConnectedUsersChanged EventType = "connectedUsersChanged"

EventTypeConnectedUsersChanged is fired when a new user connects to the frontend or disconnects from it, and updated the number of active connected users

const EventTypeMaintenanceModeChanged EventType = "maintenanceModeChanged"

EventTypeMaintenanceModeChanged is fired when the system goes in or out of maintenance mode

const EventTypeRedownloadComplete EventType = "redownloadComplete"

EventTypeRedownloadComplete is fired when re-downloading the outputs from S3 for a particular test run has been completed

const EventTypeSystemStateChange EventType = "systemStateChange"

EventTypeSystemStateChange is fired when the system state changes. When the systems starts up, it is loading test runs from disk and signals this event when its done loading. The client is supposed to show a "System is starting up" notice when the system state is "loading" and only switch to the full UI when it's done loading

const EventTypeTestRunCreated EventType = "testRunCreated"

EventTypeTestRunCreated is fired when a new test run has been created

const EventTypeTestRunLogAppended EventType = "testRunLogAppended"

EventTypeTestRunLogAppended is fired when a test run's log has been appended to, but is not broadcasted to all users; only the ones that are actively looking at the details of the given test

const EventTypeTestRunManagerConfigUpdated EventType = "testRunManagerConfigUpdated"

EventTypeTestRunManagerConfigUpdated is fired when the coordinator's config has changed. Right now this config only consists of the maximum number of parallel agents

const EventTypeTestRunResultAvailable EventType = "testRunResultAvailable"

EventTypeTestRunResultAvailable is fired when the result calculation for a test run completes

const EventTypeTestRunStatusChanged EventType = "testRunStatusChanged"

EventTypeTestRunStatusChanged is fired when a test run's status changes

type MaintenanceModeChangedPayload

type MaintenanceModeChangedPayload struct {
	MaintenanceMode bool `json:"maintenanceMode"`
}

type RedownloadCompletePayload

type RedownloadCompletePayload struct {
	Success   bool   `json:"success"`
	TestRunID string `json:"testRunID"`
	Error     string `json:"error"`
}

type SystemStateChangePayload

type SystemStateChangePayload struct {
	State string `json:"state"`
}

type TestRunCreatedPayload

type TestRunCreatedPayload struct {
	Data interface{} `json:"data"`
}

type TestRunLogAppendedPayload

type TestRunLogAppendedPayload struct {
	TestRunID string `json:"id"`
	Log       string `json:"log"`
}

type TestRunManagerConfigUpdatedPayload

type TestRunManagerConfigUpdatedPayload struct {
	Config interface{} `json:"config"`
}

type TestRunResultAvailablePayload

type TestRunResultAvailablePayload struct {
	TestRunID string             `json:"testRunID"`
	Result    *common.TestResult `json:"result"`
}

type TestRunStatusChangePayload

type TestRunStatusChangePayload struct {
	TestRunID string    `json:"testRunID"`
	Status    string    `json:"status"`
	Started   time.Time `json:"started"`
	Completed time.Time `json:"completed"`
	Details   string    `json:"details"`
	Debounced bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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