machine

package
Version: v0.0.0-...-35859e7 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2022 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DimID                     = "id"
	DimOS                     = "os"
	DimQuarantined            = "quarantined"
	DimDeviceType             = "device_type"
	DimAndroidDevices         = "android_devices"
	DimChromeOSChannel        = "chromeos_channel"
	DimChromeOSMilestone      = "chromeos_milestone"
	DimChromeOSReleaseVersion = "release_version"
	DimCores                  = "cores"
	DimCPU                    = "cpu"
	DimGPU                    = "gpu"

	BadBatteryLevel = -99
)

Well-known swarming dimensions:

Variables

View Source
var AllPowerCycleStates = []PowerCycleState{NotAvailable, Available, InError}

Functions

func SetSwarmingQuarantinedMessage

func SetSwarmingQuarantinedMessage(d *Description) bool

SetSwarmingQuarantinedMessage sets the Swarming Dimensions to reflect the full quarantined state. Returns true if the machine is quarantined.

Types

type Android

type Android struct {
	GetProp               string `json:"getprop"`
	DumpsysBattery        string `json:"dumpsys_battery"`
	DumpsysThermalService string `json:"dumpsys_thermal_service"`
	// A positive Uptime indicates there is an Android device attached to the host.
	Uptime time.Duration `json:"uptime"`
}

Android contains the raw results from interrogating an Android device.

func (*Android) IsPopulated

func (a *Android) IsPopulated() bool

IsPopulated returns whether the Android subevent record has been filled out, indicating that an Android device is attached.

type Annotation

type Annotation struct {
	Message   string
	User      string
	Timestamp time.Time
}

Annotation represents a timestamped message.

type AttachedDevice

type AttachedDevice string

AttachedDevice is what kind of mobile device, if any, we expect to find attached to the test machine.

const (
	// AttachedDeviceNone means no device is attached. Used for all non-mobile
	// test machines, like Windows boxes, as well as Raspberry Pis that have no
	// device attached yet.
	AttachedDeviceNone AttachedDevice = "nodevice"

	// AttachedDeviceAdb means an Android device, or anything else that
	// understands adb.
	AttachedDeviceAdb AttachedDevice = "adb"

	// AttachedDeviceIOS means an iOS device, or anything else that we talk to
	// using idevice* commands.
	AttachedDeviceIOS AttachedDevice = "ios"

	// AttachedDeviceSSH means a ChromeOS device, or any other device we
	// interact with via SSH.
	AttachedDeviceSSH AttachedDevice = "ssh"
)

type ChromeOS

type ChromeOS struct {
	Channel        string `json:"channel"`
	Milestone      string `json:"milestone"`
	ReleaseVersion string `json:"release_version"`
	// A positive Uptime indicates there is an ChromeOS device attached to the host.
	Uptime time.Duration `json:"uptime"`
}

ChromeOS encapsulates the information reported by a ChromeOS machine.

func (*ChromeOS) IsPopulated

func (c *ChromeOS) IsPopulated() bool

IsPopulated returns whether the ChromeOS subevent record has been filled out, implying that the machine from which the event originated drives tests on a ChromeOS device.

type Description

type Description struct {
	// MaintenanceMode is non-empy if someone manually puts the machine into
	// this mode. The value will be the user's email address and the date of the
	// change.
	MaintenanceMode string

	// IsQuarantined is true if the machine has failed too many tasks and should
	// stop running tasks pending user intervention. Recipes/Task Drivers can
	// write a $HOME/${SWARMING_BOT_ID}.quarantined file to move a machine into
	// quarantined mode.
	IsQuarantined bool

	// Recovering is a non-empty string if test_machine_monitor detects the
	// device is too hot, or low on charge. The value is a description of what
	// is recovering.
	Recovering string

	// AttachedDevice defines the kind of device attached to this test machine,
	// if any.
	AttachedDevice AttachedDevice

	// Annotation is used to record the most recent non-user change to Description.
	// For example, if the device battery is too low, this will be set automatically.
	// This will be in addition to the normal auditlog of user actions:
	// https://pkg.go.dev/go.skia.org/infra/go/auditlog?tab=doc
	Annotation Annotation

	// Note is a user authored message on the state of a machine.
	Note Annotation

	// Version of test_machine_monitor being run.
	Version string

	// PowerCycle is true if the machine needs to be power-cycled.
	PowerCycle bool

	// PowerCycleState is the state of power cycling availability for this
	// machine.
	PowerCycleState PowerCycleState

	LastUpdated         time.Time
	Battery             int                // Charge as an integer percent, e.g. 50% = 50.
	Temperature         map[string]float64 // In Celsius.
	RunningSwarmingTask bool
	LaunchedSwarming    bool      // True if test_machine_monitor launched Swarming.
	RecoveryStart       time.Time // When did the machine start being in recovery mode.
	// DeviceUptime is how long the attached device has been up. It is measured in seconds.
	DeviceUptime int32

	// SSHUserIP, for example, "root@skia-sparky360-03" indicates we should connect to the
	// given ChromeOS device at that username and ip/hostname.
	SSHUserIP string

	// SuppliedDimensions are dimensions that we, the humans, supply because they are difficult
	// for the automated system to gather. These are used only for ChromeOS devices, which don't
	// readily report their CPU and GPU.
	SuppliedDimensions SwarmingDimensions

	// Dimensions describe what hardware/software this machine has and informs what tasks
	// it can run.
	Dimensions SwarmingDimensions
}

Description is the current state of a single machine.

func NewDescription

func NewDescription(ctx context.Context) Description

NewDescription returns a new Description instance. It describes an available machine with no known dimensions.

func (Description) Copy

func (d Description) Copy() Description

Copy returns a deep copy of Description.

func (Description) InMaintenanceMode

func (d Description) InMaintenanceMode() bool

InMaintenanceMode returns true if the machine is in maintenance mode, i.e. has a non-empty MaintenanceMode message.

func (Description) IsRecovering

func (d Description) IsRecovering() bool

IsRecovering returns true if the machine is recoving, i.e. has a non-empty Recovering message.

type Event

type Event struct {
	EventType           EventType  `json:"type"`
	Android             Android    `json:"android"`
	ChromeOS            ChromeOS   `json:"chromeos"`
	IOS                 IOS        `json:"ios"`
	Standalone          Standalone `json:"standalone"`
	Host                Host       `json:"host"`
	RunningSwarmingTask bool       `json:"running_swarming_task"`

	// ForcedQuarantine is true if a TaskDriver or Recipe wrote a file $HOME/${MACHINE_ID}.force_quarantine.
	ForcedQuarantine bool `json:"forced_quarantine"`

	// LaunchedSwarming is true if test_machine_monitor launched Swarming.
	LaunchedSwarming bool `json:"launched_swarming"`
}

Event is the information a machine should send via Source when its local state has changed.

func NewEvent

func NewEvent() Event

NewEvent returns a new Event instance.

type EventType

type EventType string

EventType is the type of update we got from the machine.

const (
	// EventTypeRawState means the raw state from test_machine_monitor has been
	// updated.
	EventTypeRawState EventType = "raw_state"
)

type Host

type Host struct {
	// Name is the machine id, from SWARMING_BOT_ID environment variable or hostname().
	Name string `json:"name"`

	// Version of test_machine_monitor being run.
	Version string `json:"version"`

	// StartTime is when the test_machine_monitor started running.
	StartTime time.Time `json:"start_time"`
}

Host is information about the host machine.

type IOS

type IOS struct {
	OSVersion  string `json:"version"`     // e.g. "13.3.1". "" if it couldn't be detected.
	DeviceType string `json:"device_type"` // e.g. "iPhone10,1"
	Battery    int    `json:"battery"`     // as integer percent, or BadBatteryLevel
}

func (*IOS) IsPopulated

func (i *IOS) IsPopulated() bool

IsPopulated returns whether the IOS subevent record has been filled out, implying an attached iOS device.

type PowerCycleState

type PowerCycleState string

PowerCycleState is the state of powercycling for a single machine.

const (
	// NotAvailable means powercycling is not available for this machine. This
	// is the default.
	NotAvailable PowerCycleState = "not_available"

	// Available means powercycling is available for this machine.
	Available PowerCycleState = "available"

	// InError means that powercycle should be available, but an error has
	// occurred on powercycle_server, likely it failed to connect to the power
	// cycle device, aka the POE switch, or the PD.
	InError PowerCycleState = "in_error"
)

type Standalone

type Standalone struct {
	// Number of CPU cores:
	Cores int `json:"cores"`

	// Model of CPU, e.g. "arm64-64-Apple_M1" or "x86-64", in various precisions, e.g. "x86",
	// "x86-64", "x86-64-i7-9750H":
	CPUs []string `json:"cpus"`

	// Model of GPU, e.g. "1002:6821-4.0.20-3.2.8" or "8086:591e", in various precisions:
	GPUs []string `json:"gpus"`

	// OS version in various previsions, e.g. ["Mac-10", "Mac-10.15", "Mac-10.15.7"]:
	OSVersions []string `json:"os_versions"`
}

Standalone represents the Swarming-style dimensions of a test machine that runs tests on itself, not on some attached device.

We may merge this into Host later, once we get consistent about dimensions referring to either the host or the attached device. Right now, they're a mix. Having Standalone makes it more obvious, in the processor flow control, which dimension values take precedence.

func (*Standalone) IsPopulated

func (s *Standalone) IsPopulated() bool

IsPopulated returns whether the Standalone subevent record is filled out, which is the case iff a host is explicitly marked as having no device in the machineserver UI. IsPopulated does not return true when a device merely falls off a host accidentally.

type SwarmingDimensions

type SwarmingDimensions map[string][]string

SwarmingDimensions is for de/serializing swarming dimensions:

https://chromium.googlesource.com/infra/luci/luci-py.git/+doc/master/appengine/swarming/doc/Magic-Values.md#bot-dimensions

func (SwarmingDimensions) AsMetricsTags

func (s SwarmingDimensions) AsMetricsTags() map[string]string

AsMetricsTags returns a map that is suitable to pass as tags for a metric.

If there are multiple values for a key only the most specific value us used.

func (SwarmingDimensions) Copy

Copy returns a deep copy of the dimensions map.

Source Files

Directories

Path Synopsis
sink/sse
Package sse implements sink.Sink using Server-Sent Events.
Package sse implements sink.Sink using Server-Sent Events.
event
sink
Package sink is for sending machine.Events that are eventually picked up by 'source'.
Package sink is for sending machine.Events that are eventually picked up by 'source'.
sink/httpsink
Package httpsink sends event to the machine server via HTTP.
Package httpsink sends event to the machine server via HTTP.
source/httpsource
Package httpsource implements event.Source by accepting incoming HTTP requests that contain a machine.Event serialized as JSON.
Package httpsource implements event.Source by accepting incoming HTTP requests that contain a machine.Event serialized as JSON.
source/pubsubsource
Package pubsubsource implements source.Source using Google Cloud PubSub.
Package pubsubsource implements source.Source using Google Cloud PubSub.
Package processor does the work of taking incoming events from machines and updating the machine state using that information.
Package processor does the work of taking incoming events from machines and updating the machine state using that information.
Package store is for storing and retrieving machine.Descriptions.
Package store is for storing and retrieving machine.Descriptions.
Program to generate TypeScript definition files for Golang structs that are serialized to JSON for the web UI.
Program to generate TypeScript definition files for Golang structs that are serialized to JSON for the web UI.

Jump to

Keyboard shortcuts

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