Documentation ¶
Index ¶
- Constants
- Variables
- func AbortBuild(buildId, caller string) error
- func Aggregate(pipeline []bson.M, results interface{}) error
- func AverageTaskTimeDifference(field1 string, field2 string, groupByField string, cutoff time.Time) (map[string]time.Duration, error)
- func ByAborted(aborted bool) db.Q
- func ByActivatedBeforeRevisionWithStatuses(revisionOrder int, statuses []string, buildVariant string, displayName string, ...) db.Q
- func ByActivation(active bool) db.Q
- func ByBeforeRevision(revisionOrder int, buildVariant, displayName, project, requester string) db.Q
- func ByBeforeRevisionWithStatuses(revisionOrder int, statuses []string, ...) db.Q
- func ByBeforeRevisionWithStatusesAndRequester(revisionOrder int, statuses []string, ...) db.Q
- func ByBuildId(buildId string) db.Q
- func ByBuildIdAfterTaskId(buildId, taskId string) db.Q
- func ByCommit(revision, buildVariant, displayName, project, requester string) db.Q
- func ByDifferentFailedBuildVariants(revision, buildVariant, displayName, project, requester string) db.Q
- func ByDispatchedWithIdsVersionAndStatus(taskIds []string, versionId string, statuses []string) db.Q
- func ByExecutionTask(taskId string) db.Q
- func ByIDPrefix(id string) db.Q
- func ById(id string) db.Q
- func ByIds(ids []string) db.Q
- func ByIdsBuildAndStatus(taskIds []string, buildId string, statuses []string) db.Q
- func ByIntermediateRevisions(previousRevisionOrder, currentRevisionOrder int, ...) db.Q
- func ByRecentlyFinished(finishTime time.Time, project string, requester string) db.Q
- func ByStaleRunningTask(staleness time.Duration) db.Q
- func ByStatusAndActivation(status string, active bool) db.Q
- func ByStatuses(statuses []string, buildVariant, displayName, project, requester string) db.Q
- func ByTimeRun(startTime, endTime time.Time) db.Q
- func ByTimeStartedAndFailed(startTime, endTime time.Time) db.Q
- func ByVersion(version string) db.Q
- func ByVersionsForNameAndVariant(versions []string, displayName, buildVariant string) db.Q
- func CostDataByDistroIdPipeline(distroId string, starttime time.Time, duration time.Duration) []bson.M
- func CostDataByVersionIdPipeline(versionId string) []bson.M
- func Count(query db.Q) (int, error)
- func ExpectedTaskDuration(project, buildvariant string, window time.Duration) (map[string]time.Duration, error)
- func FindAllTaskIDsFromBuild(buildId string) ([]string, error)
- func FindAllTaskIDsFromVersion(versionId string) ([]string, error)
- func IsAbortable(t Task) bool
- func Remove(id string) error
- func RemoveAllWithBuild(buildId string) error
- func ResetTasks(taskIds []string) error
- func SetTasksScheduledTime(tasks []Task, scheduledTime time.Time) error
- func TasksByBuildIdPipeline(buildId, taskId, taskStatus string, limit, sortDir int) []bson.M
- func TasksByProjectAndCommitPipeline(projectId, commitHash, taskId, taskStatus string, limit, sortDir int) []bson.M
- func UnscheduleStaleUnderwaterTasks(distroID string) (int, error)
- func UpdateAll(query interface{}, update interface{}) (*mgo.ChangeInfo, error)
- func UpdateExpectedDuration(t *Task, timeTaken time.Duration) error
- func UpdateOne(query interface{}, update interface{}) error
- type Dependency
- type DistroCost
- type LocalTestResults
- type ResultCounts
- type Task
- func FilterTasksOnStatus(tasks []Task, statuses ...string) []Task
- func Find(query db.Q) ([]Task, error)
- func FindCostTaskByProject(project, taskId string, starttime, endtime time.Time, limit, sortDir int) ([]Task, error)
- func FindOld(query db.Q) ([]Task, error)
- func FindOldWithDisplayTasks(query db.Q) ([]Task, error)
- func FindOne(query db.Q) (*Task, error)
- func FindOneId(id string) (*Task, error)
- func FindOneIdOldOrNew(id string, execution int) (*Task, error)
- func FindOneIdWithFields(id string, projected ...string) (*Task, error)
- func FindOneNoMerge(query db.Q) (*Task, error)
- func FindOneOld(query db.Q) (*Task, error)
- func FindOneOldNoMerge(query db.Q) (*Task, error)
- func FindRunnable(distroID string) ([]Task, error)
- func FindSchedulable(distroID string) ([]Task, error)
- func FindWithDisplayTasks(query db.Q) ([]Task, error)
- func GetRecentTasks(period time.Duration) ([]Task, error)
- func MergeTestResultsBulk(tasks []Task, query *db.Q) ([]Task, error)
- func (t *Task) ActivateTask(caller string) error
- func (t *Task) AllDependenciesSatisfied(cache map[string]Task) (bool, error)
- func (t *Task) Archive() error
- func (t *Task) CountSimilarFailingTasks() (int, error)
- func (t *Task) DeactivateTask(caller string) error
- func (t *Task) DependenciesMet(depCaches map[string]Task) (bool, error)
- func (t *Task) FetchExpectedDuration() time.Duration
- func (current *Task) FindIntermediateTasks(previous *Task) ([]Task, error)
- func (t *Task) FindTaskOnBaseCommit() (*Task, error)
- func (t *Task) GetDisplayTask() (*Task, error)
- func (t *Task) GetHistoricRuntime() (time.Duration, error)
- func (t *Task) GetJQL(searchProjects []string) string
- func (t *Task) GetTaskCreatedTime() time.Time
- func (t *Task) GetTestResultsForDisplayTask() ([]TestResult, error)
- func (t *Task) HasFailedTests() bool
- func (t *Task) Insert() error
- func (t *Task) IsDispatchable() bool
- func (t *Task) IsFinished() bool
- func (t *Task) IsPartOfDisplay() bool
- func (t *Task) IsPatchRequest() bool
- func (t *Task) MarkAsDispatched(hostId string, distroId string, dispatchTime time.Time) error
- func (t *Task) MarkAsUndispatched() error
- func (t *Task) MarkEnd(finishTime time.Time, detail *apimodels.TaskEndDetail) error
- func (t *Task) MarkFailed() error
- func (t *Task) MarkStart(startTime time.Time) error
- func (t *Task) MarkSystemFailed() error
- func (t *Task) MarkUnscheduled() error
- func (t *Task) MergeNewTestResults() error
- func (t *Task) PreviousCompletedTask(project string, statuses []string) (*Task, error)
- func (t *Task) Reset() error
- func (t *Task) ResultStatus() string
- func (t *Task) SetAborted() error
- func (t *Task) SetCost(cost float64) error
- func (t *Task) SetDistro(distroID string) error
- func (t *Task) SetExpectedDuration(duration time.Duration) error
- func (t *Task) SetOverrideDependencies(userID string) error
- func (t *Task) SetPriority(priority int64, user string) error
- func (t *Task) SetResults(results []TestResult) error
- func (t *Task) String() (taskStruct string)
- func (t *Task) UpdateDisplayTask() error
- func (t *Task) UpdateHeartbeat() error
- type TaskBookkeeping
- type TaskStatusCount
- type Tasks
- type TestResult
- type VersionCost
Constants ¶
const ( DefaultGuessDur = time.Minute * 20 TaskBookkeepingCollection = "task_bk" )
const ( Collection = "tasks" OldCollection = "old_tasks" TestLogPath = "/test_log/" )
const ( // tasks should be unscheduled after ~a week UnschedulableThreshold = 7 * 24 * time.Hour )
Variables ¶
var ( // BSON fields for the task struct IdKey = bsonutil.MustHaveTag(Task{}, "Id") SecretKey = bsonutil.MustHaveTag(Task{}, "Secret") CreateTimeKey = bsonutil.MustHaveTag(Task{}, "CreateTime") DispatchTimeKey = bsonutil.MustHaveTag(Task{}, "DispatchTime") ScheduledTimeKey = bsonutil.MustHaveTag(Task{}, "ScheduledTime") StartTimeKey = bsonutil.MustHaveTag(Task{}, "StartTime") FinishTimeKey = bsonutil.MustHaveTag(Task{}, "FinishTime") ActivatedTimeKey = bsonutil.MustHaveTag(Task{}, "ActivatedTime") VersionKey = bsonutil.MustHaveTag(Task{}, "Version") ProjectKey = bsonutil.MustHaveTag(Task{}, "Project") RevisionKey = bsonutil.MustHaveTag(Task{}, "Revision") LastHeartbeatKey = bsonutil.MustHaveTag(Task{}, "LastHeartbeat") ActivatedKey = bsonutil.MustHaveTag(Task{}, "Activated") BuildIdKey = bsonutil.MustHaveTag(Task{}, "BuildId") DistroIdKey = bsonutil.MustHaveTag(Task{}, "DistroId") BuildVariantKey = bsonutil.MustHaveTag(Task{}, "BuildVariant") DependsOnKey = bsonutil.MustHaveTag(Task{}, "DependsOn") OverrideDependenciesKey = bsonutil.MustHaveTag(Task{}, "OverrideDependencies") NumDepsKey = bsonutil.MustHaveTag(Task{}, "NumDependents") DisplayNameKey = bsonutil.MustHaveTag(Task{}, "DisplayName") HostIdKey = bsonutil.MustHaveTag(Task{}, "HostId") ExecutionKey = bsonutil.MustHaveTag(Task{}, "Execution") RestartsKey = bsonutil.MustHaveTag(Task{}, "Restarts") OldTaskIdKey = bsonutil.MustHaveTag(Task{}, "OldTaskId") ArchivedKey = bsonutil.MustHaveTag(Task{}, "Archived") RevisionOrderNumberKey = bsonutil.MustHaveTag(Task{}, "RevisionOrderNumber") RequesterKey = bsonutil.MustHaveTag(Task{}, "Requester") StatusKey = bsonutil.MustHaveTag(Task{}, "Status") DetailsKey = bsonutil.MustHaveTag(Task{}, "Details") AbortedKey = bsonutil.MustHaveTag(Task{}, "Aborted") TimeTakenKey = bsonutil.MustHaveTag(Task{}, "TimeTaken") ExpectedDurationKey = bsonutil.MustHaveTag(Task{}, "ExpectedDuration") DurationPredictionKey = bsonutil.MustHaveTag(Task{}, "DurationPrediction") PriorityKey = bsonutil.MustHaveTag(Task{}, "Priority") ActivatedByKey = bsonutil.MustHaveTag(Task{}, "ActivatedBy") CostKey = bsonutil.MustHaveTag(Task{}, "Cost") ExecutionTasksKey = bsonutil.MustHaveTag(Task{}, "ExecutionTasks") DisplayOnlyKey = bsonutil.MustHaveTag(Task{}, "DisplayOnly") TaskGroupKey = bsonutil.MustHaveTag(Task{}, "TaskGroup") GenerateTaskKey = bsonutil.MustHaveTag(Task{}, "GenerateTask") GeneratedByKey = bsonutil.MustHaveTag(Task{}, "GeneratedBy") // BSON fields for the test result struct TestResultStatusKey = bsonutil.MustHaveTag(TestResult{}, "Status") TestResultLineNumKey = bsonutil.MustHaveTag(TestResult{}, "LineNum") TestResultTestFileKey = bsonutil.MustHaveTag(TestResult{}, "TestFile") TestResultURLKey = bsonutil.MustHaveTag(TestResult{}, "URL") TestResultLogIdKey = bsonutil.MustHaveTag(TestResult{}, "LogId") TestResultURLRawKey = bsonutil.MustHaveTag(TestResult{}, "URLRaw") TestResultExitCodeKey = bsonutil.MustHaveTag(TestResult{}, "ExitCode") TestResultStartTimeKey = bsonutil.MustHaveTag(TestResult{}, "StartTime") TestResultEndTimeKey = bsonutil.MustHaveTag(TestResult{}, "EndTime") )
var ( // BSON fields for task status details struct TaskEndDetailStatus = bsonutil.MustHaveTag(apimodels.TaskEndDetail{}, "Status") TaskEndDetailTimedOut = bsonutil.MustHaveTag(apimodels.TaskEndDetail{}, "TimedOut") TaskEndDetailType = bsonutil.MustHaveTag(apimodels.TaskEndDetail{}, "Type") TaskEndDetailDescription = bsonutil.MustHaveTag(apimodels.TaskEndDetail{}, "Description") )
var ( SelectorTaskInProgress = bson.M{ "$in": []string{evergreen.TaskStarted, evergreen.TaskDispatched}, } FinishedOpts = []bson.M{{ StatusKey: bson.M{ "$in": []string{ evergreen.TaskFailed, evergreen.TaskSucceeded, }, }, }, } CompletedStatuses = []string{evergreen.TaskSucceeded, evergreen.TaskFailed} )
var (
AgentHeartbeat = "heartbeat"
)
var All = db.Query(nil)
All returns all tasks.
var (
AllStatuses = "*"
)
var ( IsDispatchedOrStarted = db.Query(bson.M{ StatusKey: bson.M{"$in": []string{evergreen.TaskStarted, evergreen.TaskDispatched}}, }) )
Functions ¶
func AbortBuild ¶
AbortBuild sets the abort flag on all tasks associated with the build which are in an abortable state
func AverageTaskTimeDifference ¶
func AverageTaskTimeDifference(field1 string, field2 string, groupByField string, cutoff time.Time) (map[string]time.Duration, error)
AverageTaskTimeDifference takes two field names (such that field2 happened after field1), a field to group on, and a cutoff time. It returns the average duration between fields 1 and 2, grouped by the groupBy field, including only task documents where both time fields happened after the given cutoff time. This information is returned as a map from groupBy_field -> avg_time_difference
NOTE: THIS FUNCTION DOES NOT SANITIZE INPUT! BAD THINGS CAN HAPPEN IF NON-TIME FIELDNAMES ARE PASSED IN OR IF A FIELD OF NON-STRING TYPE IS SUPPLIED FOR groupBy!
func ByActivation ¶
ByAborted creates a query to return tasks with an aborted state
func ByBeforeRevision ¶
func ByBuildIdAfterTaskId ¶
ByBuildIdAfterTaskId provides a way to get an ordered list of tasks from a build. Providing a taskId allows indexing into the list of tasks that naturally exists when tasks are sorted by taskId.
func ByCommit ¶
ByCommit creates a query on Evergreen as the requester on a revision, buildVariant, displayName and project.
func ByDifferentFailedBuildVariants ¶
func ByDifferentFailedBuildVariants(revision, buildVariant, displayName, project, requester string) db.Q
ByDifferentFailedBuildVariants returns a query for all failed tasks on a revision that are not of a buildVariant
func ByExecutionTask ¶
func ByIDPrefix ¶
func ByIdsBuildAndStatus ¶
ByIdsBuildIdAndStatus creates a query to return tasks with a certain build id and statuses
func ByIntermediateRevisions ¶
func ByIntermediateRevisions(previousRevisionOrder, currentRevisionOrder int, buildVariant, displayName, project, requester string) db.Q
ByIntermediateRevisions creates a query that returns the tasks existing between two revision order numbers, exclusive.
func ByRecentlyFinished ¶
func ByStaleRunningTask ¶
ByStaleRunningTask creates a query that finds any running tasks whose last heartbeat was at least the specified threshold ago, or that has been dispatched but hasn't started in twice that long.
func ByStatusAndActivation ¶
ByStatusAndActivation creates a query that returns tasks of a certain status and activation state.
func ByStatuses ¶
func ByTimeStartedAndFailed ¶
ByTimeStartedAndFailed returns all failed tasks that started between 2 given times
func CostDataByDistroIdPipeline ¶
func CostDataByDistroIdPipeline(distroId string, starttime time.Time, duration time.Duration) []bson.M
CostDataByDistroIdPipeline returns an aggregation pipeline for fetching cost data (sum of time taken) from a distro by its Id.
func CostDataByVersionIdPipeline ¶
CostDataByVersionIdPipeline returns an aggregation pipeline for fetching cost data (sum of time taken) from a version by its Id.
func ExpectedTaskDuration ¶
func ExpectedTaskDuration(project, buildvariant string, window time.Duration) (map[string]time.Duration, error)
ExpectedTaskDuration takes a given project and buildvariant and computes the average duration - grouped by task display name - for tasks that have completed within a given threshold as determined by the window
func FindAllTaskIDsFromBuild ¶
func RemoveAllWithBuild ¶
Remove all deletes all tasks with a given buildId
func ResetTasks ¶
Reset sets the task state to be activated, with a new secret, undispatched status and zero time on Start, Scheduled, Dispatch and FinishTime
func SetTasksScheduledTime ¶
SetTasksScheduledTime takes a list of tasks and a time, and then sets the scheduled time in the database for the tasks if it is currently unset
func TasksByBuildIdPipeline ¶
TasksByBuildIdPipeline fetches the pipeline to get the retrieve all tasks associated with a given build.
func TasksByProjectAndCommitPipeline ¶
func TasksByProjectAndCommitPipeline(projectId, commitHash, taskId, taskStatus string, limit, sortDir int) []bson.M
TasksByProjectAndCommitPipeline fetches the pipeline to get the retrieve all tasks associated with a given project and commit hash.
func UnscheduleStaleUnderwaterTasks ¶
Removes tasks older than the unscheduable threshold (e.g. two weeks) from the scheduler queue.
If you pass an empty string as an argument to this function, this operation will select tasks from all distros.
func UpdateExpectedDuration ¶
update the expected duration that we expect the given task to take when run on the given host
Types ¶
type Dependency ¶
type Dependency struct { TaskId string `bson:"_id" json:"id"` Status string `bson:"status" json:"status"` }
Dependency represents a task that must be completed before the owning task can be scheduled.
type DistroCost ¶
type DistroCost struct { DistroId string `bson:"distro_id"` SumTimeTaken time.Duration `bson:"sum_time_taken"` SumEstimatedCost float64 `bson:"sum_estimated_cost"` Provider string `json:"provider"` ProviderSettings map[string]interface{} `json:"provider_settings"` NumTasks int `bson:"num_tasks"` }
DistroCost is service level model for representing cost data related to a distro. SumTimeTaken is the aggregation of time taken by all tasks associated with a distro.
type LocalTestResults ¶
type LocalTestResults struct {
Results []TestResult `json:"results"`
}
LocalTestResults is only used when transferring data from agent to api.
type ResultCounts ¶
type ResultCounts struct { Total int `json:"total"` Inactive int `json:"inactive"` Unstarted int `json:"unstarted"` Started int `json:"started"` Succeeded int `json:"succeeded"` Failed int `json:"failed"` SetupFailed int `json:"setup-failed"` SystemFailed int `json:"system-failed"` SystemUnresponsive int `json:"system-unresponsive"` SystemTimedOut int `json:"system-timed-out"` TestTimedOut int `json:"test-timed-out"` message.Base `json:"metadata,omitempty"` // contains filtered or unexported fields }
ResultCounts stores a collection of counters related to.
This type implements the grip/message.Composer interface and may be passed directly to grip loggers.
func GetResultCounts ¶
func GetResultCounts(tasks []Task) *ResultCounts
GetResultCounts takes a list of tasks and collects their outcomes using the same status as the.
func (*ResultCounts) Loggable ¶
func (c *ResultCounts) Loggable() bool
func (*ResultCounts) Raw ¶
func (c *ResultCounts) Raw() interface{}
func (*ResultCounts) String ¶
func (c *ResultCounts) String() string
type Task ¶
type Task struct { Id string `bson:"_id" json:"id"` Secret string `bson:"secret" json:"secret"` // time information for task // create - the creation time for the task, derived from the commit time or the patch creation time. // dispatch - the time the task runner starts up the agent on the host // scheduled - the time the commit is scheduled // start - the time the agent starts the task on the host after spinning it up // finish - the time the task was completed on the remote host CreateTime time.Time `bson:"create_time" json:"create_time"` IngestTime time.Time `bson:"injest_time" json:"ingest_time"` DispatchTime time.Time `bson:"dispatch_time" json:"dispatch_time"` ScheduledTime time.Time `bson:"scheduled_time" json:"scheduled_time"` StartTime time.Time `bson:"start_time" json:"start_time"` FinishTime time.Time `bson:"finish_time" json:"finish_time"` ActivatedTime time.Time `bson:"activated_time" json:"activated_time"` Version string `bson:"version" json:"version,omitempty"` Project string `bson:"branch" json:"branch,omitempty"` Revision string `bson:"gitspec" json:"gitspec"` Priority int64 `bson:"priority" json:"priority"` TaskGroup string `bson:"task_group" json:"task_group"` TaskGroupMaxHosts int `bson:"task_group_max_hosts,omitempty" json:"task_group_max_hosts,omitempty"` // only relevant if the task is runnin. the time of the last heartbeat // sent back by the agent LastHeartbeat time.Time `bson:"last_heartbeat"` // used to indicate whether task should be scheduled to run Activated bool `bson:"activated" json:"activated"` ActivatedBy string `bson:"activated_by" json:"activated_by"` BuildId string `bson:"build_id" json:"build_id"` DistroId string `bson:"distro" json:"distro"` BuildVariant string `bson:"build_variant" json:"build_variant"` DependsOn []Dependency `bson:"depends_on" json:"depends_on"` NumDependents int `bson:"num_dependents,omitempty" json:"num_dependents,omitempty"` OverrideDependencies bool `bson:"override_dependencies,omitempty" json:"override_dependencies,omitempty"` // Human-readable name DisplayName string `bson:"display_name" json:"display_name"` // Tags that describe the task Tags []string `bson:"tags,omitempty" json:"tags,omitempty"` // The host the task was run on HostId string `bson:"host_id" json:"host_id"` // the number of times this task has been restarted Restarts int `bson:"restarts" json:"restarts,omitempty"` Execution int `bson:"execution" json:"execution"` OldTaskId string `bson:"old_task_id,omitempty" json:"old_task_id,omitempty"` Archived bool `bson:"archived,omitempty" json:"archived,omitempty"` RevisionOrderNumber int `bson:"order,omitempty" json:"order,omitempty"` // task requester - this is used to help tell the // reason this task was created. e.g. it could be // because the repotracker requested it (via tracking the // repository) or it was triggered by a developer // patch request Requester string `bson:"r" json:"r"` // Status represents the various stages the task could be in Status string `bson:"status" json:"status"` Details apimodels.TaskEndDetail `bson:"details" json:"task_end_details"` Aborted bool `bson:"abort,omitempty" json:"abort"` // TimeTaken is how long the task took to execute. meaningless if the task is not finished TimeTaken time.Duration `bson:"time_taken" json:"time_taken"` // how long we expect the task to take from start to // finish. expected duration is the legacy value, but the UI // probably depends on it, so we maintain both values. ExpectedDuration time.Duration `bson:"expected_duration,omitempty" json:"expected_duration,omitempty"` DurationPrediction util.CachedDurationValue `bson:"duration_prediction,omitempty" json:"-"` // an estimate of what the task cost to run, hidden from JSON views for now Cost float64 `bson:"cost,omitempty" json:"-"` // test results embedded from the testresults collection LocalTestResults []TestResult `bson:"-" json:"test_results"` // display task fields DisplayOnly bool `bson:"display_only,omitempty" json:"display_only,omitempty"` ExecutionTasks []string `bson:"execution_tasks,omitempty" json:"execution_tasks,omitempty"` DisplayTask *Task `bson:"-" json:"-"` // this is a local pointer from an exec to display task // GenerateTask indicates that the task generates other tasks, which the // scheduler will use to prioritize this task. GenerateTask bool `bson:"generate_task,omitempty" json:"generate_task,omitempty"` // GeneratedBy, if present, is the ID of the task that generated this task. GeneratedBy string `bson:"generated_by,omitempty" json:"generated_by,omitempty"` }
func FilterTasksOnStatus ¶
FilterTasksOnStatus tasks in a slice of tasks and removes tasks whose result status do not match the passed-in statuses
func FindCostTaskByProject ¶
func FindCostTaskByProject(project, taskId string, starttime, endtime time.Time, limit, sortDir int) ([]Task, error)
FindCostTaskByProject fetches all tasks of a project matching the given time range, starting at task's IdKey in sortDir direction.
func FindOldWithDisplayTasks ¶
FindOldWithDisplayTasks finds display and execution tasks in the old collection
func FindOneIdOldOrNew ¶
FindOneIdOldOrNew attempts to find a given task ID by first looking in the old collection, then the tasks collection
func FindOneNoMerge ¶
FindOneNoMerge is a FindOne without merging test results.
func FindOneOld ¶
FindOneOld returns one task from the old tasks collection that satisfies the query.
func FindOneOldNoMerge ¶
FindOneOldNoMerge is a FindOneOld without merging test results.
func FindRunnable ¶
func FindSchedulable ¶
func GetRecentTasks ¶
GetRecentTasks returns the task results used by the recent_tasks endpoints.
func MergeTestResultsBulk ¶
MergeTestResultsBulk takes a slice of task structs and returns the slice with test results populated. Note that the order may change. The second parameter can be used to use a specific test result filtering query, otherwise all test results for the passed in tasks will be merged. Display tasks will have the execution task results merged
func (*Task) ActivateTask ¶
ActivateTask will set the ActivatedBy field to the caller and set the active state to be true
func (*Task) AllDependenciesSatisfied ¶
AllDependenciesSatisfied inspects the tasks first-order dependencies with regards to the cached tasks, and reports if all of the dependencies have been satisfied.
If the cached tasks do not include a dependency specified by one of the tasks, the function returns an error.
func (*Task) CountSimilarFailingTasks ¶
CountSimilarFailingTasks returns a count of all tasks with the same project, same display name, and in other buildvariants, that have failed in the same revision
func (*Task) DeactivateTask ¶
DeactivateTask will set the ActivatedBy field to the caller and set the active state to be false and deschedule the task
func (*Task) DependenciesMet ¶
Checks whether the dependencies for the task have all completed successfully. If any of the dependencies exist in the map that is passed in, they are used to check rather than fetching from the database. All queries are cached back into the map for later use.
func (*Task) FetchExpectedDuration ¶
func (*Task) FindIntermediateTasks ¶
FindIntermediateTasks returns the tasks from most recent to least recent between two tasks.
func (*Task) FindTaskOnBaseCommit ¶
FindTaskOnBaseCommit returns the task that is on the base commit.
func (*Task) GetDisplayTask ¶
func (*Task) GetJQL ¶
Generates a jira JQL string from the task When we search in jira for a task we search in the specified JIRA project If there are any test results, then we only search by test file name of all of the failed tests. Otherwise we search by the task name.
func (*Task) GetTaskCreatedTime ¶
func (*Task) GetTestResultsForDisplayTask ¶
func (t *Task) GetTestResultsForDisplayTask() ([]TestResult, error)
GetTestResultsForDisplayTask returns the test results for the execution tasks for a display task.
func (*Task) HasFailedTests ¶
HasFailedTests iterates through a tasks' tests and returns true if that task had any failed tests.
func (*Task) IsDispatchable ¶
IsDispatchable return true if the task should be dispatched
func (*Task) IsFinished ¶
IsFinished returns true if the project is no longer running
func (*Task) IsPartOfDisplay ¶
func (*Task) IsPatchRequest ¶
func (*Task) MarkAsDispatched ¶
Mark that the task has been dispatched onto a particular host. Sets the running task field on the host and the host id field on the task. Returns an error if any of the database updates fail.
func (*Task) MarkAsUndispatched ¶
MarkAsUndispatched marks that the task has been undispatched from a particular host. Unsets the running task field on the host and the host id field on the task Returns an error if any of the database updates fail.
func (*Task) MarkEnd ¶
MarkEnd handles the Task updates associated with ending a task. If the task's start time is zero at this time, it will set it to the finish time minus the timeout time.
func (*Task) MarkFailed ¶
MarkFailed changes the state of the task to failed.
func (*Task) MarkSystemFailed ¶
func (*Task) MarkUnscheduled ¶
MarkUnscheduled marks the task as undispatched and updates it in the database
func (*Task) MergeNewTestResults ¶
MergeNewTestResults returns the task with both old (embedded in the tasks collection) and new (from the testresults collection) test results merged in the Task's LocalTestResults field.
func (*Task) PreviousCompletedTask ¶
Find the previously completed task for the same requester + project + build variant + display name combination as the specified task
func (*Task) Reset ¶
Reset sets the task state to be activated, with a new secret, undispatched status and zero time on Start, Scheduled, Dispatch and FinishTime
func (*Task) ResultStatus ¶
ResultStatus returns the status for this task that should be displayed in the UI. Itb uses a combination of the TaskEndDetails and the Task's status to determine the state of the task.
func (*Task) SetAborted ¶
SetAborted sets the abort field of task to aborted
func (*Task) SetExpectedDuration ¶
SetExpectedDuration updates the expected duration field for the task
func (*Task) SetOverrideDependencies ¶
func (*Task) SetPriority ¶
SetPriority sets the priority of the tasks and the tasks that they depend on
func (*Task) SetResults ¶
func (t *Task) SetResults(results []TestResult) error
SetResults sets the results of the task in LocalTestResults
func (*Task) UpdateDisplayTask ¶
func (*Task) UpdateHeartbeat ¶
UpdateHeartbeat updates the heartbeat to be the current time
type TaskBookkeeping ¶
type TaskBookkeeping struct { // standard object id Id bson.ObjectId `bson:"_id"` // info that tasks with the same guessed duration will share Name string `bson:"name"` BuildVariant string `bson:"build_variant"` HostType string `bson:"host_type"` // may change to an enum once Host.HostType changes Project string `bson:"branch"` // the duration we expect the task to take ExpectedDuration time.Duration `bson:"expected_duration"` // the number of times this task - as defined by the // buildvariant and task name - has been started NumStarted int64 `bson:"num_started"` }
type TaskStatusCount ¶
type TaskStatusCount struct { Succeeded int `json:"succeeded"` Failed int `json:"failed"` Started int `json:"started"` Undispatched int `json:"undispatched"` Inactive int `json:"inactive"` Dispatched int `json:"dispatched"` TimedOut int `json:"timed_out"` }
TaskStatusCount holds counts for task statuses
func (*TaskStatusCount) IncrementStatus ¶
func (tsc *TaskStatusCount) IncrementStatus(status string, statusDetails apimodels.TaskEndDetail)
type TestResult ¶
type TestResult struct { Status string `json:"status" bson:"status"` TestFile string `json:"test_file" bson:"test_file"` URL string `json:"url" bson:"url,omitempty"` URLRaw string `json:"url_raw" bson:"url_raw,omitempty"` LogId string `json:"log_id,omitempty" bson:"log_id,omitempty"` LineNum int `json:"line_num,omitempty" bson:"line_num,omitempty"` ExitCode int `json:"exit_code" bson:"exit_code"` StartTime float64 `json:"start" bson:"start"` EndTime float64 `json:"end" bson:"end"` // LogRaw is not saved in the task LogRaw string `json:"log_raw" bson:"log_raw,omitempty"` }
func ConvertToOld ¶
func ConvertToOld(in *testresult.TestResult) TestResult
type VersionCost ¶
type VersionCost struct { VersionId string `bson:"version_id"` SumTimeTaken time.Duration `bson:"sum_time_taken"` SumEstimatedCost float64 `bson:"sum_estimated_cost"` }
VersionCost is service level model for representing cost data related to a version. SumTimeTaken is the aggregation of time taken by all tasks associated with a version.