Documentation ¶
Overview ¶
Constants for swarming.
Index ¶
- Constants
- Variables
- func BotDimensionsToStringMap(dims []*swarming.SwarmingRpcsStringListPair) map[string][]string
- func BotDimensionsToStringSlice(dims []*swarming.SwarmingRpcsStringListPair) []string
- func Completed(t *swarming.SwarmingRpcsTaskRequestMetadata) (time.Time, error)
- func ConvertCIPDInput(pkgs []*cipd.Package) *swarming.SwarmingRpcsCipdInput
- func Created(t *swarming.SwarmingRpcsTaskRequestMetadata) (time.Time, error)
- func GetTagValue(t *swarming.SwarmingRpcsTaskResult, tagKey string) (string, error)
- func GetTaskRequestProperties(t *swarming.SwarmingRpcsTaskRequestMetadata) *swarming.SwarmingRpcsTaskProperties
- func InitPubSub(topicName, subscriberName string, callback func(*PubSubTaskMessage) bool) error
- func MakeCASReference(digest, casInstance string) (*swarming.SwarmingRpcsCASReference, error)
- func NewApiClient(c *http.Client, server string) (*apiClient, error)
- func PackageDimensions(dims map[string][]string) []string
- func PackageTags(tags map[string][]string) []string
- func ParseDimensions(dims []string) (map[string][]string, error)
- func ParseDimensionsSingleValue(dimensions []string) (map[string]string, error)
- func ParseTags(tags []string) (map[string][]string, error)
- func ParseTimestamp(ts string) (time.Time, error)
- func ProcessBotsListCall(ctx context.Context, call *swarming.BotsListCall) ([]*swarming.SwarmingRpcsBotInfo, error)
- func Started(t *swarming.SwarmingRpcsTaskRequestMetadata) (time.Time, error)
- func StringMapToBotDimensions(dims map[string][]string) []*swarming.SwarmingRpcsStringListPair
- func StringMapToTaskDimensions(dims map[string]string) []*swarming.SwarmingRpcsStringPair
- func TaskDimensionsToStringMap(dims []*swarming.SwarmingRpcsStringPair) map[string][]string
- func TaskDimensionsToStringSlice(dims []*swarming.SwarmingRpcsStringPair) []string
- type ApiClient
- type PubSubTaskMessage
Constants ¶
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" )
const ( PUBSUB_FULLY_QUALIFIED_TOPIC_TMPL = "projects/%s/topics/%s" PUBSUB_TOPIC_SWARMING_TASKS = "swarming-tasks" PUBSUB_TOPIC_SWARMING_TASKS_INTERNAL = "swarming-tasks-internal" )
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 ¶
var ( POOLS_PUBLIC = []string{DIMENSION_POOL_VALUE_SKIA, DIMENSION_POOL_VALUE_SKIA_CT} POOLS_PRIVATE = []string{DIMENSION_POOL_VALUE_CT, DIMENSION_POOL_VALUE_SKIA_INTERNAL} TASK_STATES = []string{ TASK_STATE_BOT_DIED, TASK_STATE_CANCELED, TASK_STATE_CLIENT_ERROR, TASK_STATE_COMPLETED, TASK_STATE_EXPIRED, TASK_STATE_KILLED, TASK_STATE_PENDING, TASK_STATE_RUNNING, TASK_STATE_TIMED_OUT, } )
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 ¶
func Completed(t *swarming.SwarmingRpcsTaskRequestMetadata) (time.Time, error)
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 ¶
func Created(t *swarming.SwarmingRpcsTaskRequestMetadata) (time.Time, error)
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 ¶
func GetTaskRequestProperties(t *swarming.SwarmingRpcsTaskRequestMetadata) *swarming.SwarmingRpcsTaskProperties
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 ¶
NewApiClient returns an ApiClient instance which uses the given authenticated http.Client.
func PackageDimensions ¶
PackageDimensions packages a map[string][]string of dimensions into a []string.
func PackageTags ¶
PackageTags packages a map[string]string of tags into a []string.
func ParseDimensions ¶
ParseDimensions parses a string slice of dimensions into a map[string][]string.
func ParseDimensionsSingleValue ¶
ParseDimensionsSingleValue parses the MultiString flag into a map[string]string. Like ParseDimensions, except a single value is expected for each key.
func ParseTimestamp ¶
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 ¶
func Started(t *swarming.SwarmingRpcsTaskRequestMetadata) (time.Time, error)
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.