本文整理汇总了Golang中github.com/evergreen-ci/evergreen/model/task.Find函数的典型用法代码示例。如果您正苦于以下问题:Golang Find函数的具体用法?Golang Find怎么用?Golang Find使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Find函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestFinalizePatch
func TestFinalizePatch(t *testing.T) {
testutil.ConfigureIntegrationTest(t, patchTestConfig, "TestFinalizePatch")
Convey("With FinalizePatch on a project and commit event generated from GetPatchedProject path",
t, func() {
configPatch := resetPatchSetup(t, configFilePath)
Convey("a patched config should drive version creation", func() {
project, err := GetPatchedProject(configPatch, patchTestConfig)
So(err, ShouldBeNil)
yamlBytes, err := yaml.Marshal(project)
So(err, ShouldBeNil)
configPatch.PatchedConfig = string(yamlBytes)
version, err := model.FinalizePatch(configPatch, patchTestConfig)
So(err, ShouldBeNil)
So(version, ShouldNotBeNil)
// ensure the relevant builds/tasks were created
builds, err := build.Find(build.All)
So(err, ShouldBeNil)
So(len(builds), ShouldEqual, 1)
So(len(builds[0].Tasks), ShouldEqual, 2)
tasks, err := task.Find(task.All)
So(err, ShouldBeNil)
So(len(tasks), ShouldEqual, 2)
})
Convey("a patch that does not include the remote config should not "+
"drive version creation", func() {
patchedConfigFile := "fakeInPatchSoNotPatched"
configPatch := resetPatchSetup(t, patchedConfigFile)
project, err := GetPatchedProject(configPatch, patchTestConfig)
So(err, ShouldBeNil)
yamlBytes, err := yaml.Marshal(project)
So(err, ShouldBeNil)
configPatch.PatchedConfig = string(yamlBytes)
version, err := model.FinalizePatch(configPatch, patchTestConfig)
So(err, ShouldBeNil)
So(version, ShouldNotBeNil)
So(err, ShouldBeNil)
So(version, ShouldNotBeNil)
// ensure the relevant builds/tasks were created
builds, err := build.Find(build.All)
So(err, ShouldBeNil)
So(len(builds), ShouldEqual, 1)
So(len(builds[0].Tasks), ShouldEqual, 1)
tasks, err := task.Find(task.All)
So(err, ShouldBeNil)
So(len(tasks), ShouldEqual, 1)
})
Reset(func() {
db.Clear(distro.Collection)
})
})
}
开发者ID:tychoish,项目名称:evergreen,代码行数:55,代码来源:patch_test.go
示例2: DeactivatePreviousTasks
// Deactivate any previously activated but undispatched
// tasks for the same build variant + display name + project combination
// as the task.
func DeactivatePreviousTasks(taskId, caller string) error {
t, err := task.FindOne(task.ById(taskId))
if err != nil {
return err
}
statuses := []string{evergreen.TaskUndispatched}
allTasks, err := task.Find(task.ByActivatedBeforeRevisionWithStatuses(t.RevisionOrderNumber, statuses, t.BuildVariant,
t.DisplayName, t.Project))
if err != nil {
return err
}
for _, t := range allTasks {
err = SetActiveState(t.Id, caller, false)
if err != nil {
return err
}
event.LogTaskDeactivated(t.Id, caller)
// update the cached version of the task, in its build document to be deactivated
if err = build.SetCachedTaskActivated(t.BuildId, t.Id, false); err != nil {
return err
}
}
return nil
}
开发者ID:tychoish,项目名称:evergreen,代码行数:28,代码来源:task_lifecycle.go
示例3: flagTimedOutHeartbeats
// flagTimedOutHeartbeats is a taskFlaggingFunc to flag any tasks whose
// heartbeats have timed out
func flagTimedOutHeartbeats() ([]doomedTaskWrapper, error) {
evergreen.Logger.Logf(slogger.INFO, "Finding tasks with timed-out heartbeats...")
// fetch any running tasks whose last heartbeat was too long in the past
threshold := time.Now().Add(-HeartbeatTimeoutThreshold)
tasks, err := task.Find(task.ByRunningLastHeartbeat(threshold))
if err != nil {
return nil, fmt.Errorf("error finding tasks with timed-out"+
" heartbeats: %v", err)
}
// convert to be returned
wrappers := make([]doomedTaskWrapper, 0, len(tasks))
for _, task := range tasks {
wrappers = append(wrappers, doomedTaskWrapper{task, HeartbeatTimeout})
}
evergreen.Logger.Logf(slogger.INFO, "Found %v tasks whose heartbeats timed out",
len(wrappers))
return wrappers, nil
}
开发者ID:sr527,项目名称:evergreen,代码行数:27,代码来源:task_flagging.go
示例4: FindRunnableTasks
// FindRunnableTasks finds all tasks that are ready to be run.
// This works by fetching all undispatched tasks from the database,
// and filtering out any whose dependencies are not met.
func (self *DBTaskFinder) FindRunnableTasks() ([]task.Task, error) {
// find all of the undispatched tasks
undispatchedTasks, err := task.Find(task.IsUndispatched)
if err != nil {
return nil, err
}
// filter out any tasks whose dependencies are not met
runnableTasks := make([]task.Task, 0, len(undispatchedTasks))
dependencyCaches := make(map[string]task.Task)
for _, task := range undispatchedTasks {
depsMet, err := task.DependenciesMet(dependencyCaches)
if err != nil {
evergreen.Logger.Logf(slogger.ERROR, "Error checking dependencies for"+
" task %v: %v", task.Id, err)
continue
}
if depsMet {
runnableTasks = append(runnableTasks, task)
}
}
return runnableTasks, nil
}
开发者ID:sr527,项目名称:evergreen,代码行数:28,代码来源:task_finder.go
示例5: RefreshTasksCache
// RefreshTasksCache updates a build document so that the tasks cache reflects the correct current
// state of the tasks it represents.
func RefreshTasksCache(buildId string) error {
tasks, err := task.Find(task.ByBuildId(buildId).WithFields(task.IdKey, task.DisplayNameKey, task.StatusKey,
task.DetailsKey, task.StartTimeKey, task.TimeTakenKey, task.ActivatedKey, task.DependsOnKey))
if err != nil {
return err
}
cache := CreateTasksCache(tasks)
return build.SetTasksCache(buildId, cache)
}
开发者ID:sr527,项目名称:evergreen,代码行数:11,代码来源:lifecycle.go
示例6: TestCreateTaskBuckets
func TestCreateTaskBuckets(t *testing.T) {
testutil.HandleTestingErr(db.ClearCollections(task.Collection), t, "couldnt reset host")
Convey("With a starting time and a minute bucket size and inserting tasks with different start and finish", t, func() {
now := time.Now()
bucketSize := time.Duration(10) * time.Second
// -20 -> 20
beforeStartHost := task.Task{Id: "beforeStartTask", StartTime: now.Add(time.Duration(-20) * time.Second), FinishTime: now.Add(time.Duration(20) * time.Second), Status: evergreen.TaskSucceeded}
So(beforeStartHost.Insert(), ShouldBeNil)
// 80 -> 120
afterEndHost := task.Task{Id: "afterStartTask", StartTime: now.Add(time.Duration(80) * time.Second), FinishTime: now.Add(time.Duration(120) * time.Second), Status: evergreen.TaskFailed}
So(afterEndHost.Insert(), ShouldBeNil)
// 20 -> 40: shouldnt be added
h1 := task.Task{Id: "h1", StartTime: now.Add(time.Duration(20) * time.Second), FinishTime: now.Add(time.Duration(40) * time.Second), Status: evergreen.TaskUndispatched}
So(h1.Insert(), ShouldBeNil)
// 10 -> 80
h2 := task.Task{Id: "h2", StartTime: now.Add(time.Duration(10) * time.Second), FinishTime: now.Add(time.Duration(80) * time.Second), Status: evergreen.TaskSucceeded}
So(h2.Insert(), ShouldBeNil)
// 20 -> shouldnt be added
neverEnding := task.Task{Id: "neverEnding", StartTime: now.Add(time.Duration(20) * time.Second), Status: evergreen.TaskSucceeded}
So(neverEnding.Insert(), ShouldBeNil)
// 5 -> 7
sameBucket := task.Task{Id: "sameBucket", StartTime: now.Add(time.Duration(5) * time.Second), FinishTime: now.Add(time.Duration(7) * time.Second), Status: evergreen.TaskFailed}
So(sameBucket.Insert(), ShouldBeNil)
// 5 -> 30
h4 := task.Task{Id: "h4", StartTime: now.Add(time.Duration(5) * time.Second), FinishTime: now.Add(time.Duration(30) * time.Second), Status: evergreen.TaskFailed}
So(h4.Insert(), ShouldBeNil)
endTime := now.Add(time.Duration(40) * time.Second)
frameBounds := FrameBounds{
StartTime: now,
EndTime: endTime,
NumberBuckets: 4,
BucketSize: bucketSize,
}
Convey("for four buckets of 10 seconds", func() {
tasks, err := task.Find(task.ByTimeRun(now, endTime))
So(err, ShouldBeNil)
So(len(tasks), ShouldEqual, 4)
buckets, errors := CreateTaskBuckets(tasks, []task.Task{}, frameBounds)
So(errors, ShouldBeEmpty)
So(len(buckets), ShouldEqual, 4)
So(int(buckets[0].TotalTime.Seconds()), ShouldEqual, 17)
So(int(math.Ceil(buckets[1].TotalTime.Seconds())), ShouldEqual, 30)
So(int(math.Ceil(buckets[2].TotalTime.Seconds())), ShouldEqual, 20)
})
})
}
开发者ID:tychoish,项目名称:evergreen,代码行数:56,代码来源:scheduler_stats_test.go
示例7: updateMakespans
// updateMakespans
func updateMakespans(b *build.Build) error {
// find all tasks associated with the build
tasks, err := task.Find(task.ByBuildId(b.Id))
if err != nil {
return err
}
depPath := FindPredictedMakespan(tasks)
return b.UpdateMakespans(depPath.TotalTime, CalculateActualMakespan(tasks))
}
开发者ID:tychoish,项目名称:evergreen,代码行数:11,代码来源:task_lifecycle.go
示例8: TestDeletingBuild
func TestDeletingBuild(t *testing.T) {
Convey("With a build", t, func() {
testutil.HandleTestingErr(db.Clear(build.Collection), t, "Error clearing"+
" '%v' collection", build.Collection)
b := &build.Build{
Id: "build",
}
So(b.Insert(), ShouldBeNil)
Convey("deleting it should remove it and all its associated"+
" tasks from the database", func() {
testutil.HandleTestingErr(db.ClearCollections(task.Collection), t, "Error"+
" clearing '%v' collection", task.Collection)
// insert two tasks that are part of the build, and one that isn't
matchingTaskOne := &task.Task{
Id: "matchingOne",
BuildId: b.Id,
}
So(matchingTaskOne.Insert(), ShouldBeNil)
matchingTaskTwo := &task.Task{
Id: "matchingTwo",
BuildId: b.Id,
}
So(matchingTaskTwo.Insert(), ShouldBeNil)
nonMatchingTask := &task.Task{
Id: "nonMatching",
BuildId: "blech",
}
So(nonMatchingTask.Insert(), ShouldBeNil)
// delete the build, make sure only it and its tasks are deleted
So(DeleteBuild(b.Id), ShouldBeNil)
b, err := build.FindOne(build.ById(b.Id))
So(err, ShouldBeNil)
So(b, ShouldBeNil)
matchingTasks, err := task.Find(task.ByBuildId("build"))
So(err, ShouldBeNil)
So(len(matchingTasks), ShouldEqual, 0)
nonMatchingTask, err = task.FindOne(task.ById(nonMatchingTask.Id))
So(err, ShouldBeNil)
So(nonMatchingTask, ShouldNotBeNil)
})
})
}
开发者ID:sr527,项目名称:evergreen,代码行数:55,代码来源:lifecycle_test.go
示例9: addRecDeps
// addRecDeps recursively finds all dependencies of tasks and adds them to tasks and uiDeps.
// done is a hashtable of task IDs whose dependencies we have found.
// TODO EVG-614: delete this function once Task.DependsOn includes all recursive dependencies.
func addRecDeps(tasks map[string]task.Task, uiDeps map[string]uiDep, done map[string]bool) error {
curTask := make(map[string]bool)
depIds := make([]string, 0)
for _, t := range tasks {
if _, ok := done[t.Id]; !ok {
for _, dep := range t.DependsOn {
depIds = append(depIds, dep.TaskId)
}
curTask[t.Id] = true
}
}
if len(depIds) == 0 {
return nil
}
deps, err := task.Find(task.ByIds(depIds).WithFields(task.DisplayNameKey, task.StatusKey, task.ActivatedKey,
task.BuildVariantKey, task.DetailsKey, task.DependsOnKey))
if err != nil {
return err
}
for _, dep := range deps {
tasks[dep.Id] = dep
}
for _, t := range tasks {
if _, ok := curTask[t.Id]; ok {
for _, dep := range t.DependsOn {
if uid, ok := uiDeps[dep.TaskId]; !ok ||
// only replace if the current uiDep is not strict and not recursive
(uid.RequiredStatus == model.AllStatuses && !uid.Recursive) {
depTask := tasks[dep.TaskId]
uiDeps[depTask.Id] = uiDep{
Id: depTask.Id,
Name: depTask.DisplayName,
Status: depTask.Status,
RequiredStatus: dep.Status,
Activated: depTask.Activated,
BuildVariant: depTask.BuildVariant,
Details: depTask.Details,
Recursive: true,
}
}
}
done[t.Id] = true
}
}
return addRecDeps(tasks, uiDeps, done)
}
开发者ID:sr527,项目名称:evergreen,代码行数:55,代码来源:task.go
示例10: getRecentlyFinishedTasks
// This is used to pull recently finished tasks
func getRecentlyFinishedTasks(notificationKey *NotificationKey) (tasks []task.Task, err error) {
if cachedProjectRecords[notificationKey.String()] == nil {
tasks, err = task.Find(task.ByRecentlyFinished(lastProjectNotificationTime[notificationKey.Project],
notificationKey.Project, notificationKey.NotificationRequester))
if err != nil {
return nil, err
}
cachedProjectRecords[notificationKey.String()] = tasks
return tasks, err
}
return cachedProjectRecords[notificationKey.String()].([]task.Task), nil
}
开发者ID:sr527,项目名称:evergreen,代码行数:14,代码来源:notify.go
示例11: getTaskDependencies
// getTaskDependencies returns the uiDeps for the task and its status (either its original status,
// "blocked", or "pending")
func getTaskDependencies(t *task.Task) ([]uiDep, string, error) {
depIds := []string{}
for _, dep := range t.DependsOn {
depIds = append(depIds, dep.TaskId)
}
dependencies, err := task.Find(task.ByIds(depIds).WithFields(task.DisplayNameKey, task.StatusKey,
task.ActivatedKey, task.BuildVariantKey, task.DetailsKey, task.DependsOnKey))
if err != nil {
return nil, "", err
}
idToUiDep := make(map[string]uiDep)
// match each task with its dependency requirements
for _, depTask := range dependencies {
for _, dep := range t.DependsOn {
if dep.TaskId == depTask.Id {
idToUiDep[depTask.Id] = uiDep{
Id: depTask.Id,
Name: depTask.DisplayName,
Status: depTask.Status,
RequiredStatus: dep.Status,
Activated: depTask.Activated,
BuildVariant: depTask.BuildVariant,
Details: depTask.Details,
//TODO EVG-614: add "Recursive: dep.Recursive," once Task.DependsOn includes all recursive dependencies
}
}
}
}
idToDep := make(map[string]task.Task)
for _, dep := range dependencies {
idToDep[dep.Id] = dep
}
// TODO EVG 614: delete this section once Task.DependsOn includes all recursive dependencies
err = addRecDeps(idToDep, idToUiDep, make(map[string]bool))
if err != nil {
return nil, "", err
}
// set the status for each of the uiDeps as "blocked" or "pending" if appropriate
// and get the status for task
status := setBlockedOrPending(*t, idToDep, idToUiDep)
uiDeps := make([]uiDep, 0, len(idToUiDep))
for _, dep := range idToUiDep {
uiDeps = append(uiDeps, dep)
}
return uiDeps, status, nil
}
开发者ID:sr527,项目名称:evergreen,代码行数:53,代码来源:task.go
示例12: computeRunningTasksDuration
// computeRunningTasksDuration returns the estimated time to completion of all
// currently running tasks for a given distro given its hosts
func computeRunningTasksDuration(existingDistroHosts []host.Host,
taskDurations model.ProjectTaskDurations) (runningTasksDuration float64,
err error) {
runningTaskIds := []string{}
for _, existingDistroHost := range existingDistroHosts {
if existingDistroHost.RunningTask != "" {
runningTaskIds = append(runningTaskIds,
existingDistroHost.RunningTask)
}
}
// if this distro's hosts are all free, return immediately
if len(runningTaskIds) == 0 {
return
}
runningTasksMap := make(map[string]task.Task)
runningTasks, err := task.Find(task.ByIds(runningTaskIds))
if err != nil {
return runningTasksDuration, err
}
// build a map of task id => task
for _, runningTask := range runningTasks {
runningTasksMap[runningTask.Id] = runningTask
}
// compute the total time to completion for running tasks
for _, runningTaskId := range runningTaskIds {
runningTask, ok := runningTasksMap[runningTaskId]
if !ok {
return runningTasksDuration, fmt.Errorf("Unable to find running "+
"task with _id %v", runningTaskId)
}
expectedDuration := model.GetTaskExpectedDuration(runningTask,
taskDurations)
elapsedTime := time.Now().Sub(runningTask.StartTime)
if elapsedTime > expectedDuration {
// probably an outlier; or an unknown data point
continue
}
runningTasksDuration += expectedDuration.Seconds() -
elapsedTime.Seconds()
}
return
}
开发者ID:tychoish,项目名称:evergreen,代码行数:50,代码来源:duration_based_host_allocator.go
示例13: getTaskDrawerItems
// Given a task name and a slice of versions, return the appropriate sibling
// groups of tasks. They will be sorted by ascending revision order number,
// unless reverseOrder is true, in which case they will be sorted
// descending.
func getTaskDrawerItems(displayName string, variant string, reverseOrder bool, versions []version.Version) ([]taskDrawerItem, error) {
orderNumbers := make([]int, 0, len(versions))
for _, v := range versions {
orderNumbers = append(orderNumbers, v.RevisionOrderNumber)
}
revisionSort := task.RevisionOrderNumberKey
if reverseOrder {
revisionSort = "-" + revisionSort
}
tasks, err := task.Find(task.ByOrderNumbersForNameAndVariant(orderNumbers, displayName, variant).Sort([]string{revisionSort}))
if err != nil {
return nil, fmt.Errorf("error getting sibling tasks: %v", err)
}
return createSiblingTaskGroups(tasks, versions), nil
}
开发者ID:tychoish,项目名称:evergreen,代码行数:23,代码来源:task_history.go
示例14: getUiTaskCache
// getUiTaskCache takes a build object and returns a slice of
// uiTask objects suitable for front-end
func getUiTaskCache(build *build.Build) ([]uiTask, error) {
tasks, err := task.Find(task.ByBuildId(build.Id))
if err != nil {
return nil, err
}
idToTask := make(map[string]task.Task)
for _, task := range tasks {
idToTask[task.Id] = task
}
// Insert the tasks in the same order as the task cache
uiTasks := make([]uiTask, 0, len(build.Tasks))
for _, taskCache := range build.Tasks {
taskAsUI := uiTask{Task: idToTask[taskCache.Id]}
uiTasks = append(uiTasks, taskAsUI)
}
return uiTasks, nil
}
开发者ID:tychoish,项目名称:evergreen,代码行数:21,代码来源:build.go
示例15: getTaskForVariant
// getTaskForVariant finds a task by name and variant and finds
// the document in the json collection associated with that task's id.
func getTaskForVariant(w http.ResponseWriter, r *http.Request) {
t := plugin.GetTask(r)
if t == nil {
http.Error(w, "task not found", http.StatusNotFound)
return
}
name := mux.Vars(r)["name"]
taskName := mux.Vars(r)["task_name"]
variantId := mux.Vars(r)["variant"]
// Find the task for the other variant, if it exists
ts, err := task.Find(db.Query(bson.M{task.VersionKey: t.Version, task.BuildVariantKey: variantId,
task.DisplayNameKey: taskName}).Limit(1))
if err != nil {
if err == mgo.ErrNotFound {
plugin.WriteJSON(w, http.StatusNotFound, nil)
return
}
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if len(ts) == 0 {
plugin.WriteJSON(w, http.StatusNotFound, nil)
return
}
otherVariantTask := ts[0]
var jsonForTask TaskJSON
err = db.FindOneQ(collection, db.Query(bson.M{TaskIdKey: otherVariantTask.Id, NameKey: name}), &jsonForTask)
if err != nil {
if err == mgo.ErrNotFound {
plugin.WriteJSON(w, http.StatusNotFound, nil)
return
}
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if len(r.FormValue("full")) != 0 { // if specified, include the json data's container as well
plugin.WriteJSON(w, http.StatusOK, jsonForTask)
return
}
plugin.WriteJSON(w, http.StatusOK, jsonForTask.Data)
}
开发者ID:tychoish,项目名称:evergreen,代码行数:44,代码来源:task.go
示例16: CreateAllHostUtilizationBuckets
// CreateAllHostUtilizationBuckets aggregates each bucket by creating a time frame given the number of days back
// and the granularity wanted (ie. days, minutes, seconds, hours) all in seconds. It returns a list of Host utilization
// information for each bucket.
func CreateAllHostUtilizationBuckets(daysBack, granularity int) ([]HostUtilizationBucket, error) {
bounds := CalculateBounds(daysBack, granularity)
// find non-static hosts
dynamicHosts, err := host.Find(host.ByDynamicWithinTime(bounds.StartTime, bounds.EndTime))
if err != nil {
return nil, err
}
// find static hosts
staticHosts, err := host.Find(host.AllStatic)
if err != nil {
return nil, err
}
dynamicBuckets, _ := CreateHostBuckets(dynamicHosts, bounds)
staticBuckets, _ := CreateHostBuckets(staticHosts, bounds)
tasks, err := task.Find(task.ByTimeRun(bounds.StartTime, bounds.EndTime).WithFields(task.StartTimeKey, task.FinishTimeKey, task.HostIdKey))
if err != nil {
return nil, err
}
oldTasks, err := task.FindOld(task.ByTimeRun(bounds.StartTime, bounds.EndTime))
if err != nil {
return nil, err
}
taskBuckets, _ := CreateTaskBuckets(tasks, oldTasks, bounds)
bucketData := []HostUtilizationBucket{}
for i, staticBucket := range staticBuckets {
b := HostUtilizationBucket{
StaticHost: staticBucket.TotalTime,
DynamicHost: dynamicBuckets[i].TotalTime,
Task: taskBuckets[i].TotalTime,
StartTime: bounds.StartTime.Add(time.Duration(i) * bounds.BucketSize),
EndTime: bounds.StartTime.Add(time.Duration(i+1) * bounds.BucketSize),
}
bucketData = append(bucketData, b)
}
return bucketData, nil
}
开发者ID:tychoish,项目名称:evergreen,代码行数:44,代码来源:scheduler_stats.go
示例17: RestartBuild
// RestartBuild restarts completed tasks associated with a given buildId.
// If abortInProgress is true, it also sets the abort flag on any in-progress tasks.
func RestartBuild(buildId string, taskIds []string, abortInProgress bool, caller string) error {
// restart all the 'not in-progress' tasks for the build
allTasks, err := task.Find(task.ByIdsBuildAndStatus(taskIds, buildId, task.CompletedStatuses))
if err != nil && err != mgo.ErrNotFound {
return err
}
for _, t := range allTasks {
if t.DispatchTime != util.ZeroTime {
err = resetTask(t.Id)
if err != nil {
return fmt.Errorf("Restarting build %v failed, could not task.reset on task: %v",
buildId, t.Id, err)
}
}
}
if abortInProgress {
// abort in-progress tasks in this build
_, err = task.UpdateAll(
bson.M{
task.BuildIdKey: buildId,
task.StatusKey: bson.M{
"$in": evergreen.AbortableStatuses,
},
},
bson.M{
"$set": bson.M{
task.AbortedKey: true,
},
},
)
if err != nil {
return err
}
}
return build.UpdateActivation(buildId, true, caller)
}
开发者ID:sr527,项目名称:evergreen,代码行数:41,代码来源:lifecycle.go
示例18: AddNewTasksForPatch
// Given a patch version and set of variant/task pairs, creates any tasks that don't exist yet,
// within the set of already existing builds.
func AddNewTasksForPatch(p *patch.Patch, patchVersion *version.Version, project *Project, pairs TVPairSet) error {
builds, err := build.Find(build.ByIds(patchVersion.BuildIds).WithFields(build.IdKey, build.BuildVariantKey))
if err != nil {
return err
}
for _, b := range builds {
// Find the set of task names that already exist for the given build
tasksInBuild, err := task.Find(task.ByBuildId(b.Id).WithFields(task.DisplayNameKey))
if err != nil {
return err
}
// build an index to keep track of which tasks already exist
existingTasksIndex := map[string]bool{}
for _, t := range tasksInBuild {
existingTasksIndex[t.DisplayName] = true
}
// if the patch is activated, treat the build as activated
b.Activated = p.Activated
// build a list of tasks that haven't been created yet for the given variant, but have
// a record in the TVPairSet indicating that it should exist
tasksToAdd := []string{}
for _, taskname := range pairs.TaskNames(b.BuildVariant) {
if _, ok := existingTasksIndex[taskname]; ok {
continue
}
tasksToAdd = append(tasksToAdd, taskname)
}
if len(tasksToAdd) == 0 { // no tasks to add, so we do nothing.
continue
}
// Add the new set of tasks to the build.
if _, err = AddTasksToBuild(&b, project, patchVersion, tasksToAdd); err != nil {
return err
}
}
return nil
}
开发者ID:tychoish,项目名称:evergreen,代码行数:41,代码来源:patch_lifecycle.go
示例19: GetFailedTests
// GetFailedTests returns a mapping of task id to a slice of failed tasks
// extracted from a pipeline of aggregated tasks
func (self *taskHistoryIterator) GetFailedTests(aggregatedTasks *mgo.Pipe) (map[string][]task.TestResult, error) {
// get the ids of the failed task
var failedTaskIds []string
var taskHistory TaskHistory
iter := aggregatedTasks.Iter()
for {
if iter.Next(&taskHistory) {
for _, task := range taskHistory.Tasks {
if task.Status == evergreen.TaskFailed {
failedTaskIds = append(failedTaskIds, task.Id)
}
}
} else {
break
}
}
if err := iter.Err(); err != nil {
return nil, err
}
// find all the relevant failed tests
failedTestsMap := make(map[string][]task.TestResult)
tasks, err := task.Find(task.ByIds(failedTaskIds).WithFields(task.IdKey, task.TestResultsKey))
if err != nil {
return nil, err
}
// create the mapping of the task id to the list of failed tasks
for _, task := range tasks {
for _, test := range task.TestResults {
if test.Status == evergreen.TestFailedStatus {
failedTestsMap[task.Id] = append(failedTestsMap[task.Id], test)
}
}
}
return failedTestsMap, nil
}
开发者ID:sr527,项目名称:evergreen,代码行数:40,代码来源:task_history.go
示例20: TestBuildSetPriority
func TestBuildSetPriority(t *testing.T) {
Convey("With a build", t, func() {
testutil.HandleTestingErr(db.ClearCollections(build.Collection, task.Collection), t,
"Error clearing test collection")
b := &build.Build{
Id: "build",
}
So(b.Insert(), ShouldBeNil)
taskOne := &task.Task{Id: "taskOne", BuildId: b.Id}
So(taskOne.Insert(), ShouldBeNil)
taskTwo := &task.Task{Id: "taskTwo", BuildId: b.Id}
So(taskTwo.Insert(), ShouldBeNil)
taskThree := &task.Task{Id: "taskThree", BuildId: b.Id}
So(taskThree.Insert(), ShouldBeNil)
Convey("setting its priority should update the priority"+
" of all its tasks in the database", func() {
So(SetBuildPriority(b.Id, 42), ShouldBeNil)
tasks, err := task.Find(task.ByBuildId(b.Id))
So(err, ShouldBeNil)
So(len(tasks), ShouldEqual, 3)
So(tasks[0].Priority, ShouldEqual, 42)
So(tasks[1].Priority, ShouldEqual, 42)
So(tasks[2].Priority, ShouldEqual, 42)
})
})
}
开发者ID:sr527,项目名称:evergreen,代码行数:37,代码来源:lifecycle_test.go
注:本文中的github.com/evergreen-ci/evergreen/model/task.Find函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论