Documentation
¶
Index ¶
- Constants
- Variables
- func GetStateDimension(dims []*swarmingv2.StringListPair) fleet.DutState
- func GetStateDimensionV2(dims []*swarmingv2.StringListPair) fleet.DutState
- func PushAuditDUTs(ctx context.Context, botIDs, actions []string, taskname, swarmingPool string) error
- func PushRepairDUTs(ctx context.Context, botIDs []string, expectedState string, ...) error
- func PushRepairLabstations(ctx context.Context, botIDs []string, swarmingPool string) error
- func TaskDoneTime(tr *swarmingv2.TaskResultResponse) (time.Time, error)
- func TimeSinceBotTask(tr *swarmingv2.TaskResultResponse) (*duration.Duration, error)
- func TimeSinceBotTaskN(tr *swarmingv2.TaskResultResponse, now time.Time) (*duration.Duration, error)
- type BotTasksCursor
- type Pager
- type SwarmingClient
- type SwarmingCreateTaskArgs
Constants ¶
const ( // MaxConcurrentSwarmingCalls is the maximum number of concurrent swarming // calls made within the context of a single RPC call to this app. // // There is no per-instance limit (yet). MaxConcurrentSwarmingCalls = 20 // BotIDDimensionKey identifies the swarming dimension containing // the ID of BOT BotIDDimensionKey = "id" // DutIDDimensionKey identifies the swarming dimension containing the ID for // the DUT corresponding to a bot. DutIDDimensionKey = "dut_id" // DutModelDimensionKey identifies the swarming dimension containing the // Autotest model label for the DUT. DutModelDimensionKey = "label-model" // DutPoolDimensionKey identifies the swarming dimension containing the // Autotest pool label for the DUT. DutPoolDimensionKey = "label-pool" // DutOSDimensionKey identifies the swarming dimension containing the // OS label for the DUT. DutOSDimensionKey = "label-os_type" // DutNameDimensionKey identifies the swarming dimension // containing the DUT name. DutNameDimensionKey = "dut_name" // DutStateDimensionKey identifies the swarming dimension containing the // autotest DUT state for a bot. DutStateDimensionKey = "dut_state" // PoolDimensionKey identifies the swarming pool dimension. PoolDimensionKey = "pool" // SwarmingTimeLayout is the layout used by swarming RPCs to specify timestamps. SwarmingTimeLayout = "2006-01-02T15:04:05.999999999" )
Variables ¶
var DutStateRevMap = map[fleet.DutState]string{ fleet.DutState_Ready: "ready", fleet.DutState_NeedsCleanup: "needs_cleanup", fleet.DutState_NeedsRepair: "needs_repair", fleet.DutState_NeedsReset: "needs_reset", fleet.DutState_RepairFailed: "repair_failed", fleet.DutState_NeedsManualRepair: "needs_manual_repair", fleet.DutState_NeedsReplacement: "needs_replacement", fleet.DutState_NeedsDeploy: "needs_deploy", }
DutStateRevMap mapping DutState to swarming value representation
var HealthyDutStates = map[fleet.DutState]bool{ fleet.DutState_Ready: true, fleet.DutState_NeedsCleanup: true, fleet.DutState_NeedsRepair: true, fleet.DutState_NeedsReset: true, }
HealthyDutStates is the set of healthy DUT states.
Functions ¶
func GetStateDimension ¶
func GetStateDimension(dims []*swarmingv2.StringListPair) fleet.DutState
GetStateDimension gets the dut_state value from a dimension slice.
func GetStateDimensionV2 ¶
func GetStateDimensionV2(dims []*swarmingv2.StringListPair) fleet.DutState
GetStateDimensionV2 gets the dut_state value from a dimension slice.
func PushAuditDUTs ¶
func PushAuditDUTs(ctx context.Context, botIDs, actions []string, taskname, swarmingPool string) error
PushAuditDUTs pushes BOT ids to taskqueue auditBotsQueue for upcoming audit jobs.
func PushRepairDUTs ¶
func PushRepairDUTs(ctx context.Context, botIDs []string, expectedState string, swarmingPool string) error
PushRepairDUTs pushes BOT ids to taskqueue repairBotsQueue for upcoming repair jobs.
func PushRepairLabstations ¶
PushRepairLabstations pushes BOT ids to taskqueue repairLabstationQueue for upcoming repair jobs.
func TaskDoneTime ¶
func TaskDoneTime(tr *swarmingv2.TaskResultResponse) (time.Time, error)
TaskDoneTime returns the time when the given task completed on a bot. If the task was never run or is still running, this function returns a zero time.
func TimeSinceBotTask ¶
func TimeSinceBotTask(tr *swarmingv2.TaskResultResponse) (*duration.Duration, error)
TimeSinceBotTask calls TimeSinceBotTaskN with time.Now().
func TimeSinceBotTaskN ¶
func TimeSinceBotTaskN(tr *swarmingv2.TaskResultResponse, now time.Time) (*duration.Duration, error)
TimeSinceBotTaskN returns the duration.Duration elapsed since the given task completed on a bot.
This function only considers tasks that were executed by Swarming to a specific bot. For tasks that were never executed on a bot, this function returns nil duration.
Types ¶
type BotTasksCursor ¶
type BotTasksCursor interface {
Next(context.Context, int32) ([]*swarmingv2.TaskResultResponse, error)
}
BotTasksCursor tracks a paginated query for Swarming bot tasks.
type Pager ¶
type Pager struct { // Remaining is set to the number of items to retrieve. This // can be modified after Pager has been used, but not // concurrently. Remaining int32 }
Pager manages pagination of API calls.
type SwarmingClient ¶
type SwarmingClient interface { ListAliveIdleBotsInPool(c context.Context, pool string, dims strpair.Map) ([]*swarmingv2.BotInfo, error) ListAliveBotsInPool(context.Context, string, strpair.Map) ([]*swarmingv2.BotInfo, error) ListBotTasks(id string) BotTasksCursor ListRecentTasks(c context.Context, tags []string, state swarmingv2.StateQuery, limit int32) ([]*swarmingv2.TaskResultResponse, error) ListSortedRecentTasksForBot(c context.Context, botID string, limit int32) ([]*swarmingv2.TaskResultResponse, error) CreateTask(c context.Context, name string, args *SwarmingCreateTaskArgs) (string, error) GetTaskResult(ctx context.Context, tid string) (*swarmingv2.TaskResultResponse, error) }
SwarmingClient exposes Swarming client API used by this package.
In prod, a SwarmingClient for interacting with the Swarming service will be used. Tests should use a fake.
func NewSwarmingClient ¶
func NewSwarmingClient(c context.Context, host string) (SwarmingClient, error)
NewSwarmingClient returns a SwarmingClient for interaction with the Swarming service.
type SwarmingCreateTaskArgs ¶
type SwarmingCreateTaskArgs struct { Cmd []string // The task targets a dut with the given bot id. BotID string // The task targets a dut with the given dut id. DutID string // If non-empty, the task targets a dut in the given state. DutState string DutName string ExecutionTimeoutSecs int32 ExpirationSecs int32 Pool string Priority int32 Tags []string User string Realm string ServiceAccount string }
SwarmingCreateTaskArgs contains the arguments to SwarmingClient.CreateTask.
This struct contains only a small subset of the Swarming task arguments that is needed by this app.