swarming

package
v0.0.0-...-34cbb95 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: BSD-3-Clause Imports: 18 Imported by: 19

Documentation

Overview

Constants for swarming.

Index

Constants

View Source
const (
	API_BASE_PATH_PATTERN = "https://%s/_ah/api/swarming/v1/"
	AUTH_SCOPE            = "https://www.googleapis.com/auth/userinfo.email"

	DIMENSION_DEVICE_OS_KEY            = "device_os"
	DIMENSION_DEVICE_TYPE_KEY          = "device_type"
	DIMENSION_GPU_KEY                  = "gpu"
	DIMENSION_OS_KEY                   = "os"
	DIMENSION_POOL_KEY                 = "pool"
	DIMENSION_POOL_VALUE_SKIA          = "Skia"
	DIMENSION_POOL_VALUE_SKIA_CT       = "SkiaCT"
	DIMENSION_POOL_VALUE_SKIA_INTERNAL = "SkiaInternal"
	DIMENSION_POOL_VALUE_CT            = "CT"
	DIMENSION_QUARANTINED_KEY          = "quarantined"

	TASK_STATE_BOT_DIED     = "BOT_DIED"
	TASK_STATE_CANCELED     = "CANCELED"
	TASK_STATE_CLIENT_ERROR = "CLIENT_ERROR"
	TASK_STATE_COMPLETED    = "COMPLETED"
	TASK_STATE_EXPIRED      = "EXPIRED"
	TASK_STATE_KILLED       = "KILLED"
	TASK_STATE_NO_RESOURCE  = "NO_RESOURCE"
	TASK_STATE_PENDING      = "PENDING"
	TASK_STATE_RUNNING      = "RUNNING"
	TASK_STATE_TIMED_OUT    = "TIMED_OUT"

	// TIMESTAMP_FORMAT represents the timestamp format used by Swarming APIs. Use
	// with time.Parse/time.Format.
	TIMESTAMP_FORMAT = "2006-01-02T15:04:05.999999"
)
View Source
const (
	PUBSUB_FULLY_QUALIFIED_TOPIC_TMPL    = "projects/%s/topics/%s"
	PUBSUB_TOPIC_SWARMING_TASKS          = "swarming-tasks"
	PUBSUB_TOPIC_SWARMING_TASKS_INTERNAL = "swarming-tasks-internal"
)
View Source
const (
	SWARMING_SERVER          = "chromium-swarm.appspot.com"
	SWARMING_SERVER_PRIVATE  = "chrome-swarming.appspot.com"
	SWARMING_SERVER_DEV      = "chromium-swarm-dev.appspot.com"
	RECOMMENDED_IO_TIMEOUT   = 20 * time.Minute
	RECOMMENDED_HARD_TIMEOUT = 1 * time.Hour
	RECOMMENDED_PRIORITY     = 90
	RECOMMENDED_EXPIRATION   = 4 * time.Hour
	// "priority 0 can only be used for terminate request"
	HIGHEST_PRIORITY = 1
	LOWEST_PRIORITY  = 255
)

Variables

Functions

func BotDimensionsToStringMap

func BotDimensionsToStringMap(dims []*swarming.SwarmingRpcsStringListPair) map[string][]string

BotDimensionsToStringMap converts Swarming bot dimensions as represented in the Swarming API to a map[string][]string.

func BotDimensionsToStringSlice

func BotDimensionsToStringSlice(dims []*swarming.SwarmingRpcsStringListPair) []string

BotDimensionsToStringSlice converts Swarming bot dimensions as represented in the Swarming API to a []string.

func Completed

Completed returns a time.Time for the given task's started time.

func ConvertCIPDInput

func ConvertCIPDInput(pkgs []*cipd.Package) *swarming.SwarmingRpcsCipdInput

ConvertCIPDInput converts a slice of cipd.Package to a SwarmingRpcsCipdInput.

func Created

Created returns a time.Time for the given task's created time.

func GetTagValue

func GetTagValue(t *swarming.SwarmingRpcsTaskResult, tagKey string) (string, error)

GetTagValue returns the value for the given tag key from the given Swarming task.

func GetTaskRequestProperties

GetTaskRequestProperties returns the SwarmingRpcsTaskProperties for the given SwarmingRpcsTaskRequestMetadata.

func InitPubSub

func InitPubSub(topicName, subscriberName string, callback func(*PubSubTaskMessage) bool) error

InitPubSub ensures that the pub/sub topic and subscription exist and starts receiving messages, calling the given callback function for each one. The callback returns a bool indicating whether or not to ACK the message.

func MakeCASReference

func MakeCASReference(digest, casInstance string) (*swarming.SwarmingRpcsCASReference, error)

MakeCASReference returns a SwarmingRpcsCASReference which can be used as input to a Swarming task.

func NewApiClient

func NewApiClient(c *http.Client, server string) (*apiClient, error)

NewApiClient returns an ApiClient instance which uses the given authenticated http.Client.

func PackageDimensions

func PackageDimensions(dims map[string][]string) []string

PackageDimensions packages a map[string][]string of dimensions into a []string.

func PackageTags

func PackageTags(tags map[string][]string) []string

PackageTags packages a map[string]string of tags into a []string.

func ParseDimensions

func ParseDimensions(dims []string) (map[string][]string, error)

ParseDimensions parses a string slice of dimensions into a map[string][]string.

func ParseDimensionsSingleValue

func ParseDimensionsSingleValue(dimensions []string) (map[string]string, error)

ParseDimensionsSingleValue parses the MultiString flag into a map[string]string. Like ParseDimensions, except a single value is expected for each key.

func ParseTags

func ParseTags(tags []string) (map[string][]string, error)

ParseTags parses a string slice of tags into a map[string][]string.

func ParseTimestamp

func ParseTimestamp(ts string) (time.Time, error)

ParseTimestamp returns a UTC time.Time for the given timestamp.

func ProcessBotsListCall

func ProcessBotsListCall(ctx context.Context, call *swarming.BotsListCall) ([]*swarming.SwarmingRpcsBotInfo, error)

func Started

Started returns a time.Time for the given task's started time.

func StringMapToBotDimensions

func StringMapToBotDimensions(dims map[string][]string) []*swarming.SwarmingRpcsStringListPair

StringMapToBotDimensions converts Swarming bot dimensions from a map[string][]string to their Swarming API representation.

func StringMapToTaskDimensions

func StringMapToTaskDimensions(dims map[string]string) []*swarming.SwarmingRpcsStringPair

StringMapToTaskDimensions converts Swarming task dimensions from a map[string]string to their Swarming API representation.

func TaskDimensionsToStringMap

func TaskDimensionsToStringMap(dims []*swarming.SwarmingRpcsStringPair) map[string][]string

TaskDimensionsToStringMap converts Swarming task dimensions as represented in the Swarming API to a map[string][]string.

func TaskDimensionsToStringSlice

func TaskDimensionsToStringSlice(dims []*swarming.SwarmingRpcsStringPair) []string

TaskDimensionsToStringSlice converts Swarming task dimensions as represented in the Swarming API to a []string.

Types

type ApiClient

type ApiClient interface {
	// SwarmingService returns the underlying swarming.Service object.
	SwarmingService() *swarming.Service

	// ListBots returns a slice of swarming.SwarmingRpcsBotInfo instances
	// corresponding to the Swarming bots matching the requested dimensions.
	ListBots(ctx context.Context, dimensions map[string]string) ([]*swarming.SwarmingRpcsBotInfo, error)

	// ListFreeBots returns a slice of swarming.SwarmingRpcsBotInfo instances
	// corresponding to the free, alive, and not-quarantined bots in the
	// given pool.
	ListFreeBots(ctx context.Context, pool string) ([]*swarming.SwarmingRpcsBotInfo, error)

	// ListDownBots returns a slice of swarming.SwarmingRpcsBotInfo instances
	// corresponding to the dead or quarantined bots in the given pool.
	ListDownBots(ctx context.Context, pool string) ([]*swarming.SwarmingRpcsBotInfo, error)

	// ListBotsForPool returns a slice of swarming.SwarmingRpcsBotInfo
	// instances corresponding to the Swarming bots in the given pool.
	ListBotsForPool(ctx context.Context, pool string) ([]*swarming.SwarmingRpcsBotInfo, error)

	// ListBotsForDimensions returns a slice of swarming.SwarmingRpcsBotInfo instances
	// corresponding to alive and unquarantined bots given a set of dimensions
	ListBotsForDimensions(ctx context.Context, dimensions map[string]string) ([]*swarming.SwarmingRpcsBotInfo, error)

	// GetStates returns a slice of states corresponding to the given task
	// IDs.
	GetStates(ctx context.Context, ids []string) ([]string, error)

	GetStdoutOfTask(ctx context.Context, id string) (*swarming.SwarmingRpcsTaskOutput, error)

	GracefullyShutdownBot(ctx context.Context, id string) (*swarming.SwarmingRpcsTerminateResponse, error)

	// ListBotTasks returns a slice of SwarmingRpcsTaskResult that are the last
	// N tasks done by a bot. When limit is big (>100), this call is very expensive.
	ListBotTasks(ctx context.Context, botID string, limit int) ([]*swarming.SwarmingRpcsTaskResult, error)

	// ListTasks returns a slice of swarming.SwarmingRpcsTaskRequestMetadata
	// instances corresponding to the specified tags and within given time window.
	// The results will have TaskId, TaskResult, and Request fields populated.
	// Specify time.Time{} for start and end if you do not want to restrict on
	// time. Specify "" for state if you do not want to restrict on state.
	ListTasks(ctx context.Context, start, end time.Time, tags []string, state string) ([]*swarming.SwarmingRpcsTaskRequestMetadata, error)

	// ListSkiaTasks is ListTasks limited to pool:Skia.
	ListSkiaTasks(ctx context.Context, start, end time.Time) ([]*swarming.SwarmingRpcsTaskRequestMetadata, error)

	// ListTaskResults returns a slice of swarming.SwarmingRpcsTaskResult
	// instances corresponding to the specified tags and within given time window.
	// Specify time.Time{} for start and end if you do not want to restrict on
	// time. Specify "" for state if you do not want to restrict on state.
	// includePerformanceStats indicates whether or not to load performance
	// information (eg. overhead) in addition to the normal task data.
	ListTaskResults(ctx context.Context, start, end time.Time, tags []string, state string, includePerformanceStats bool) ([]*swarming.SwarmingRpcsTaskResult, error)

	// CancelTask cancels the task with the given ID.
	CancelTask(ctx context.Context, id string, killRunning bool) error

	// TriggerTask triggers a task with the given request.
	TriggerTask(ctx context.Context, t *swarming.SwarmingRpcsNewTaskRequest) (*swarming.SwarmingRpcsTaskRequestMetadata, error)

	// RetryTask triggers a retry of the given task.
	RetryTask(ctx context.Context, t *swarming.SwarmingRpcsTaskRequestMetadata) (*swarming.SwarmingRpcsTaskRequestMetadata, error)

	// GetTask returns a swarming.SwarmingRpcsTaskResult instance
	// corresponding to the given Swarming task.
	GetTask(ctx context.Context, id string, includePerformanceStats bool) (*swarming.SwarmingRpcsTaskResult, error)

	// GetTaskMetadata returns a swarming.SwarmingRpcsTaskRequestMetadata instance
	// corresponding to the given Swarming task.
	GetTaskMetadata(ctx context.Context, id string) (*swarming.SwarmingRpcsTaskRequestMetadata, error)

	DeleteBots(ctx context.Context, bots []string) error
}

ApiClient is a Skia-specific wrapper around the Swarming API.

type PubSubTaskMessage

type PubSubTaskMessage struct {
	SwarmingTaskId string `json:"task_id"`
	UserData       string `json:"userdata"`
}

PubSubTaskMessage is a message received from Swarming via pub/sub about a Task.

Directories

Path Synopsis
v2

Jump to

Keyboard shortcuts

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