Documentation ¶
Index ¶
- Constants
- Variables
- func GetStateDimension(dims []*swarming.SwarmingRpcsStringListPair) fleet.DutState
- func NewGerritClient(c context.Context, host string) (gerrit.GerritClient, error)
- func NewGerritClientAsSelf(ctx context.Context, host string) (gerrit.GerritClient, error)
- func NewGitilesClient(c context.Context, host string) (gitiles.GitilesClient, error)
- func NewGitilesClientAsSelf(ctx context.Context, host string) (gitiles.GitilesClient, error)
- func PushAuditDUTs(ctx context.Context, botIDs, actions []string, taskname string) error
- func PushRepairDUTs(ctx context.Context, botIDs []string, expectedState string) error
- func PushRepairLabstations(ctx context.Context, botIDs []string) error
- func TaskDoneTime(tr *swarming.SwarmingRpcsTaskResult) (time.Time, error)
- func TimeSinceBotTask(tr *swarming.SwarmingRpcsTaskResult) (*duration.Duration, error)
- func TimeSinceBotTaskN(tr *swarming.SwarmingRpcsTaskResult, 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 []*swarming.SwarmingRpcsStringListPair) fleet.DutState
GetStateDimension gets the dut_state value from a dimension slice.
func NewGerritClient ¶
NewGerritClient returns a new gerrit client.
This function is intended to be used within the context of an RPC to this app. The returned gerrit client forwards the oauth token used for the original RPC. In particular, this means that the original oauth credentials must include the gerrit OAuth 2.0 scope.
func NewGerritClientAsSelf ¶
NewGerritClientAsSelf returns a new gerrit client using oauth tokens for the current service itself.
This function is intended to be used from cron calls that are not part of a user session. For normal RPC users, see NewGerritClient.
func NewGitilesClient ¶
NewGitilesClient returns a new gitiles client.
This function is intended to be used within the context of an RPC to this app. The returned gitiles client forwards the oauth token used for the original RPC. In particular, this means that the original oauth credentials must include the gerrit OAuth 2.0 scope.
func NewGitilesClientAsSelf ¶
NewGitilesClientAsSelf returns a new gitiles client using oauth tokens for the current service itself.
This function is intended to be used from cron calls that are not part of a user session. For normal RPC users, see NewGitilesClient.
func PushAuditDUTs ¶
PushAuditDUTs pushes BOT ids to taskqueue auditBotsQueue for upcoming audit jobs.
func PushRepairDUTs ¶
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 *swarming.SwarmingRpcsTaskResult) (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 *swarming.SwarmingRpcsTaskResult) (*duration.Duration, error)
TimeSinceBotTask calls TimeSinceBotTaskN with time.Now().
func TimeSinceBotTaskN ¶
func TimeSinceBotTaskN(tr *swarming.SwarmingRpcsTaskResult, 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, int64) ([]*swarming.SwarmingRpcsTaskResult, 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 int }
Pager manages pagination of API calls.
type SwarmingClient ¶
type SwarmingClient interface { ListAliveIdleBotsInPool(c context.Context, pool string, dims strpair.Map) ([]*swarming.SwarmingRpcsBotInfo, error) ListAliveBotsInPool(context.Context, string, strpair.Map) ([]*swarming.SwarmingRpcsBotInfo, error) ListBotTasks(id string) BotTasksCursor ListRecentTasks(c context.Context, tags []string, state string, limit int) ([]*swarming.SwarmingRpcsTaskResult, error) ListSortedRecentTasksForBot(c context.Context, botID string, limit int) ([]*swarming.SwarmingRpcsTaskResult, error) CreateTask(c context.Context, name string, args *SwarmingCreateTaskArgs) (string, error) GetTaskResult(ctx context.Context, tid string) (*swarming.SwarmingRpcsTaskResult, 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 int64 ExpirationSecs int64 Pool string Priority int64 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.