本文整理汇总了Golang中github.com/evergreen-ci/evergreen/model/task.FindOne函数的典型用法代码示例。如果您正苦于以下问题:Golang FindOne函数的具体用法?Golang FindOne怎么用?Golang FindOne使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FindOne函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: 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
示例2: spawnPage
func (uis *UIServer) spawnPage(w http.ResponseWriter, r *http.Request) {
flashes := PopFlashes(uis.CookieStore, r, w)
projCtx := MustHaveProjectContext(r)
var spawnDistro *distro.Distro
var spawnTask *task.Task
var err error
if len(r.FormValue("distro_id")) > 0 {
spawnDistro, err = distro.FindOne(distro.ById(r.FormValue("distro_id")))
if err != nil {
uis.LoggedError(w, r, http.StatusInternalServerError,
fmt.Errorf("Error finding distro %v: %v", r.FormValue("distro_id"), err))
return
}
}
if len(r.FormValue("task_id")) > 0 {
spawnTask, err = task.FindOne(task.ById(r.FormValue("task_id")))
if err != nil {
uis.LoggedError(w, r, http.StatusInternalServerError,
fmt.Errorf("Error finding task %v: %v", r.FormValue("task_id"), err))
return
}
}
uis.WriteHTML(w, http.StatusOK, struct {
ProjectData projectContext
User *user.DBUser
Flashes []interface{}
Distro *distro.Distro
Task *task.Task
MaxHostsPerUser int
}{projCtx, GetUser(r), flashes, spawnDistro, spawnTask, spawn.MaxPerUser}, "base", "spawned_hosts.html", "base_angular.html", "menu.html")
}
开发者ID:tychoish,项目名称:evergreen,代码行数:33,代码来源:spawn.go
示例3: MarkStart
// MarkStart updates the task, build, version and if necessary, patch documents with the task start time
func MarkStart(taskId string) error {
t, err := task.FindOne(task.ById(taskId))
if err != nil {
return err
}
startTime := time.Now()
if err = t.MarkStart(startTime); err != nil {
return err
}
event.LogTaskStarted(t.Id)
// ensure the appropriate build is marked as started if necessary
if err = build.TryMarkStarted(t.BuildId, startTime); err != nil {
return err
}
// ensure the appropriate version is marked as started if necessary
if err = MarkVersionStarted(t.Version, startTime); err != nil {
return err
}
// if it's a patch, mark the patch as started if necessary
if t.Requester == evergreen.PatchVersionRequester {
if err = patch.TryMarkStarted(t.Version, startTime); err != nil {
return err
}
}
// update the cached version of the task, in its build document
return build.SetCachedTaskStarted(t.BuildId, t.Id, startTime)
}
开发者ID:tychoish,项目名称:evergreen,代码行数:32,代码来源:task_lifecycle.go
示例4: getStepback
// Returns true if the task should stepback upon failure, and false
// otherwise. Note that the setting is obtained from the top-level
// project, if not explicitly set on the task.
func getStepback(taskId string, project *Project) (bool, error) {
t, err := task.FindOne(task.ById(taskId))
if err != nil {
return false, err
}
projectTask := project.FindProjectTask(t.DisplayName)
// Check if the task overrides the stepback policy specified by the project
if projectTask != nil && projectTask.Stepback != nil {
return *projectTask.Stepback, nil
}
// Check if the build variant overrides the stepback policy specified by the project
for _, buildVariant := range project.BuildVariants {
if t.BuildVariant == buildVariant.Name {
if buildVariant.Stepback != nil {
return *buildVariant.Stepback, nil
}
break
}
}
return project.Stepback, nil
}
开发者ID:tychoish,项目名称:evergreen,代码行数:28,代码来源:task_lifecycle.go
示例5: TestProjectTaskExecTimeout
func TestProjectTaskExecTimeout(t *testing.T) {
setupTlsConfigs(t)
for tlsString, tlsConfig := range tlsConfigs {
Convey("With agent running a slow test and live API server over "+tlsString, t, func() {
testTask, _, err := setupAPITestData(testConfig, "project_exec_timeout_task", "linux-64", filepath.Join(testDirectory, "testdata/config_test_plugin/project/project-timeout-test.yml"), NoPatch, t)
testutil.HandleTestingErr(err, t, "Failed to find test task")
testServer, err := service.CreateTestServer(testConfig, tlsConfig, plugin.APIPlugins, Verbose)
testutil.HandleTestingErr(err, t, "Couldn't create apiserver: %v", err)
testAgent, err := New(testServer.URL, testTask.Id, testTask.Secret, "", testConfig.Api.HttpsCert, testPidFile)
So(err, ShouldBeNil)
So(testAgent, ShouldNotBeNil)
Convey("after the slow test runs beyond the project timeout threshold", func() {
// actually run the task.
// this function won't return until the whole thing is done.
testAgent.RunTask()
testAgent.APILogger.Flush()
time.Sleep(5 * time.Second)
printLogsForTask(testTask.Id)
Convey("the test should be marked as failed and timed out", func() {
So(scanLogsForTask(testTask.Id, "", "executing the pre-run script"), ShouldBeTrue)
So(scanLogsForTask(testTask.Id, "", "executing the post-run script!"), ShouldBeTrue)
So(scanLogsForTask(testTask.Id, "", "executing the task-timeout script!"), ShouldBeTrue)
testTask, err = task.FindOne(task.ById(testTask.Id))
So(testTask.Status, ShouldEqual, evergreen.TaskFailed)
So(testTask.Details.TimedOut, ShouldBeTrue)
So(testTask.Details.Description, ShouldEqual, "shell.exec")
})
})
})
}
}
开发者ID:tychoish,项目名称:evergreen,代码行数:32,代码来源:api_integration_test.go
示例6: TestPatchPluginAPI
func TestPatchPluginAPI(t *testing.T) {
testConfig := evergreen.TestConfig()
cwd := testutil.GetDirectoryOfFile()
Convey("With a running api server and installed plugin", t, func() {
registry := plugin.NewSimpleRegistry()
gitPlugin := &GitPlugin{}
err := registry.Register(gitPlugin)
testutil.HandleTestingErr(err, t, "Couldn't register patch plugin")
server, err := service.CreateTestServer(testConfig, nil, plugin.APIPlugins, false)
testutil.HandleTestingErr(err, t, "Couldn't set up testing server")
taskConfig, _ := plugintest.CreateTestConfig(filepath.Join(cwd, "testdata", "plugin_patch.yml"), t)
testCommand := GitGetProjectCommand{Directory: "dir"}
_, _, err = plugintest.SetupAPITestData("testTask", filepath.Join(cwd, "testdata", "testmodule.patch"), t)
testutil.HandleTestingErr(err, t, "Couldn't set up test documents")
testTask, err := task.FindOne(task.ById("testTaskId"))
testutil.HandleTestingErr(err, t, "Couldn't set up test patch task")
sliceAppender := &evergreen.SliceAppender{[]*slogger.Log{}}
logger := agentutil.NewTestLogger(sliceAppender)
Convey("calls to existing tasks with patches should succeed", func() {
httpCom := plugintest.TestAgentCommunicator(testTask.Id, testTask.Secret, server.URL)
pluginCom := &comm.TaskJSONCommunicator{gitPlugin.Name(), httpCom}
patch, err := testCommand.GetPatch(taskConfig, pluginCom, logger)
So(err, ShouldBeNil)
So(patch, ShouldNotBeNil)
testutil.HandleTestingErr(db.Clear(version.Collection), t,
"unable to clear versions collection")
})
Convey("calls to non-existing tasks should fail", func() {
v := version.Version{Id: ""}
testutil.HandleTestingErr(v.Insert(), t, "Couldn't insert dummy version")
httpCom := plugintest.TestAgentCommunicator("BAD_TASK_ID", "", server.URL)
pluginCom := &comm.TaskJSONCommunicator{gitPlugin.Name(), httpCom}
patch, err := testCommand.GetPatch(taskConfig, pluginCom, logger)
So(err.Error(), ShouldContainSubstring, "not found")
So(err, ShouldNotBeNil)
So(patch, ShouldBeNil)
testutil.HandleTestingErr(db.Clear(version.Collection), t,
"unable to clear versions collection")
})
Convey("calls to existing tasks without patches should fail", func() {
noPatchTask := task.Task{Id: "noPatchTask", BuildId: "a"}
testutil.HandleTestingErr(noPatchTask.Insert(), t, "Couldn't insert patch task")
noPatchVersion := version.Version{Id: "noPatchVersion", BuildIds: []string{"a"}}
testutil.HandleTestingErr(noPatchVersion.Insert(), t, "Couldn't insert patch version")
v := version.Version{Id: ""}
testutil.HandleTestingErr(v.Insert(), t, "Couldn't insert dummy version")
httpCom := plugintest.TestAgentCommunicator(noPatchTask.Id, "", server.URL)
pluginCom := &comm.TaskJSONCommunicator{gitPlugin.Name(), httpCom}
patch, err := testCommand.GetPatch(taskConfig, pluginCom, logger)
So(err, ShouldNotBeNil)
So(err.Error(), ShouldContainSubstring, "no patch found for task")
So(patch, ShouldBeNil)
testutil.HandleTestingErr(db.Clear(version.Collection), t,
"unable to clear versions collection")
})
})
}
开发者ID:tychoish,项目名称:evergreen,代码行数:60,代码来源:patch_test.go
示例7: checkTask
func (as *APIServer) checkTask(checkSecret bool, next http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
taskId := mux.Vars(r)["taskId"]
if taskId == "" {
as.LoggedError(w, r, http.StatusBadRequest, fmt.Errorf("missing task id"))
return
}
t, err := task.FindOne(task.ById(taskId))
if err != nil {
as.LoggedError(w, r, http.StatusInternalServerError, err)
return
}
if t == nil {
as.LoggedError(w, r, http.StatusNotFound, fmt.Errorf("task not found"))
return
}
if checkSecret {
secret := r.Header.Get(evergreen.TaskSecretHeader)
// Check the secret - if it doesn't match, write error back to the client
if secret != t.Secret {
evergreen.Logger.Logf(slogger.ERROR, "Wrong secret sent for task %v: Expected %v but got %v", taskId, t.Secret, secret)
http.Error(w, "wrong secret!", http.StatusConflict)
return
}
}
context.Set(r, apiTaskKey, t)
// also set the task in the context visible to plugins
plugin.SetTask(r, t)
next(w, r)
}
}
开发者ID:tychoish,项目名称:evergreen,代码行数:34,代码来源:api.go
示例8: dBTestsWildcard
// dBTestsWildcard are the database verification tests for globbed file execution
func dBTestsWildcard() {
task, err := task.FindOne(task.ById("mocktaskid"))
So(err, ShouldBeNil)
So(len(task.TestResults), ShouldEqual, TotalResultCount)
Convey("along with the proper logs", func() {
// junit_1.xml
tl := dBFindOneTestLog("pkg1.test.test_things.test_params_func:2")
So(tl.Lines[0], ShouldContainSubstring, "FAILURE")
So(tl.Lines[6], ShouldContainSubstring, "AssertionError")
tl = dBFindOneTestLog("pkg1.test.test_things.SomeTests.test_skippy")
So(tl.Lines[0], ShouldContainSubstring, "SKIPPED")
// junit_2.xml
tl = dBFindOneTestLog("tests.ATest.fail")
So(tl.Lines[0], ShouldContainSubstring, "FAILURE")
So(tl.Lines[1], ShouldContainSubstring, "AssertionFailedError")
// junit_3.xml
tl = dBFindOneTestLog(
"test.test_threads_replica_set_client.TestThreadsReplicaSet.test_safe_update",
)
So(tl.Lines[0], ShouldContainSubstring, "SKIPPED")
tl = dBFindOneTestLog("test.test_bson.TestBSON.test_basic_encode")
So(tl.Lines[0], ShouldContainSubstring, "AssertionError")
})
}
开发者ID:sr527,项目名称:evergreen,代码行数:28,代码来源:xunit_results_command_test.go
示例9: reachedFailureLimit
// reachedFailureLimit returns true if task for the previous failure transition alert
// happened too long ago, as determined by some magic math.
func reachedFailureLimit(taskId string) (bool, error) {
t, err := task.FindOne(task.ById(taskId))
if err != nil {
return false, err
}
if t == nil {
return false, fmt.Errorf("task %v not found", taskId)
}
pr, err := model.FindOneProjectRef(t.Project)
if err != nil {
return false, err
}
if pr == nil {
return false, fmt.Errorf("project ref %v not found", t.Project)
}
p, err := model.FindProject(t.Revision, pr)
if err != nil {
return false, err
}
if p == nil {
return false, fmt.Errorf("project %v not found for revision %v", t.Project, t.Revision)
}
v := p.FindBuildVariant(t.BuildVariant)
if v == nil {
return false, fmt.Errorf("build variant %v does not exist in project", t.BuildVariant)
}
batchTime := pr.GetBatchTime(v)
reached := time.Since(t.FinishTime) > (time.Duration(batchTime) * time.Minute * failureLimitMultiplier)
return reached, nil
}
开发者ID:tychoish,项目名称:evergreen,代码行数:33,代码来源:project_triggers.go
示例10: TestPatchTask
func TestPatchTask(t *testing.T) {
setupTlsConfigs(t)
testConfig := evergreen.TestConfig()
db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(testConfig))
patchModes := []patchTestMode{InlinePatch, ExternalPatch}
testutil.ConfigureIntegrationTest(t, testConfig, "TestPatchTask")
for tlsString, tlsConfig := range tlsConfigs {
for _, testSetup := range testSetups {
Convey(testSetup.testSpec, t, func() {
Convey("With agent running a patched 'compile'"+tlsString, func() {
for _, mode := range patchModes {
Convey(fmt.Sprintf("Using patch mode %v", mode.String()), func() {
testTask, b, err := setupAPITestData(testConfig, "compile", "linux-64", "testdata/config_test_plugin/project/evergreen-ci-render.yml", mode, t)
githash := "1e5232709595db427893826ce19289461cba3f75"
setupPatches(mode, b, t,
patchRequest{"", "testdata/test.patch", githash},
patchRequest{"recursive", "testdata/testmodule.patch", githash})
testutil.HandleTestingErr(err, t, "Error setting up test data: %v", err)
testServer, err := apiserver.CreateTestServer(testConfig, tlsConfig, plugin.APIPlugins, Verbose)
testutil.HandleTestingErr(err, t, "Couldn't create apiserver: %v", err)
testAgent, err := New(testServer.URL, testTask.Id, testTask.Secret, "", testConfig.Api.HttpsCert)
// actually run the task.
// this function won't return until the whole thing is done.
testAgent.RunTask()
time.Sleep(100 * time.Millisecond)
testAgent.APILogger.FlushAndWait()
printLogsForTask(testTask.Id)
Convey("all scripts in task should have been run successfully", func() {
So(scanLogsForTask(testTask.Id, "executing the pre-run script"), ShouldBeTrue)
So(scanLogsForTask(testTask.Id, "executing the post-run script!"), ShouldBeTrue)
So(scanLogsForTask(testTask.Id, "Cloning into") || // git 1.8
scanLogsForTask(testTask.Id, "Initialized empty Git repository"), // git 1.7
ShouldBeTrue)
So(scanLogsForTask(testTask.Id, "i am patched!"), ShouldBeTrue)
So(scanLogsForTask(testTask.Id, "i am a patched module"), ShouldBeTrue)
So(scanLogsForTask(testTask.Id, "i am compiling!"), ShouldBeTrue)
So(scanLogsForTask(testTask.Id, "i am sanity testing!"), ShouldBeTrue)
testTask, err = task.FindOne(task.ById(testTask.Id))
testutil.HandleTestingErr(err, t, "Error finding test task: %v", err)
So(testTask.Status, ShouldEqual, evergreen.TaskSucceeded)
})
})
}
})
})
}
}
}
开发者ID:sr527,项目名称:evergreen,代码行数:57,代码来源:patch_integration_test.go
示例11: 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
示例12: TestTaskEndEndpoint
func TestTaskEndEndpoint(t *testing.T) {
setupTlsConfigs(t)
for tlsString, tlsConfig := range tlsConfigs {
testTask, _, err := setupAPITestData(testConfig, "random", "linux-64", filepath.Join(testDirectory, "testdata/config_test_plugin/project/evergreen-ci-render.yml"), NoPatch, t)
testutil.HandleTestingErr(err, t, "Couldn't make test data: %v", err)
Convey("With a live api server, agent, and test task over "+tlsString, t, func() {
testServer, err := service.CreateTestServer(testConfig, tlsConfig, plugin.APIPlugins, Verbose)
testutil.HandleTestingErr(err, t, "Couldn't create apiserver: %v", err)
testAgent, err := createAgent(testServer, testTask)
testutil.HandleTestingErr(err, t, "failed to create agent: %v")
testAgent.heartbeater.Interval = 10 * time.Second
testAgent.StartBackgroundActions(&NoopSignalHandler{})
Convey("calling end() should update task's/host's status properly "+
"and start running the next task", func() {
subsequentTaskId := testTask.Id + "Two"
details := &apimodels.TaskEndDetail{Status: evergreen.TaskSucceeded}
taskEndResp, err := testAgent.End(details)
time.Sleep(1 * time.Second)
So(err, ShouldBeNil)
taskUpdate, err := task.FindOne(task.ById(testTask.Id))
So(err, ShouldBeNil)
So(taskUpdate.Status, ShouldEqual, evergreen.TaskSucceeded)
testHost, err := host.FindOne(host.ById(testTask.HostId))
So(err, ShouldBeNil)
So(testHost.RunningTask, ShouldEqual, subsequentTaskId)
taskUpdate, err = task.FindOne(task.ById(subsequentTaskId))
So(err, ShouldBeNil)
So(taskUpdate.Status, ShouldEqual, evergreen.TaskDispatched)
So(taskEndResp, ShouldNotBeNil)
So(taskEndResp.RunNext, ShouldBeTrue)
So(taskEndResp.TaskId, ShouldEqual, subsequentTaskId)
})
})
}
}
开发者ID:tychoish,项目名称:evergreen,代码行数:41,代码来源:api_integration_test.go
示例13: TestDeactivatePreviousTask
func TestDeactivatePreviousTask(t *testing.T) {
Convey("With two tasks and a build", t, func() {
testutil.HandleTestingErr(db.ClearCollections(task.Collection, build.Collection), t,
"Error clearing task and build collections")
// create two tasks
displayName := "testTask"
userName := "user"
b := &build.Build{
Id: "testBuild",
}
previousTask := &task.Task{
Id: "one",
DisplayName: displayName,
RevisionOrderNumber: 1,
Priority: 1,
Activated: true,
ActivatedBy: "user",
BuildId: b.Id,
Status: evergreen.TaskUndispatched,
Project: "sample",
}
currentTask := &task.Task{
Id: "two",
DisplayName: displayName,
RevisionOrderNumber: 2,
Status: evergreen.TaskFailed,
Priority: 1,
Activated: true,
BuildId: b.Id,
Project: "sample",
}
tc := []build.TaskCache{
{
DisplayName: displayName,
Id: previousTask.Id,
},
{
DisplayName: displayName,
Id: currentTask.Id,
},
}
b.Tasks = tc
So(b.Insert(), ShouldBeNil)
So(previousTask.Insert(), ShouldBeNil)
So(currentTask.Insert(), ShouldBeNil)
Convey("activating a previous task should set the previous task's active field to true", func() {
So(DeactivatePreviousTasks(currentTask.Id, userName), ShouldBeNil)
previousTask, err := task.FindOne(task.ById(previousTask.Id))
So(err, ShouldBeNil)
So(previousTask.Activated, ShouldBeFalse)
})
})
}
开发者ID:tychoish,项目名称:evergreen,代码行数:53,代码来源:task_lifecycle_test.go
示例14: uiGetTaskHistory
func uiGetTaskHistory(w http.ResponseWriter, r *http.Request) {
t, err := task.FindOne(task.ById(mux.Vars(r)["task_id"]))
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if t == nil {
http.Error(w, "{}", http.StatusNotFound)
return
}
getTaskHistory(t, w, r)
}
开发者ID:tychoish,项目名称:evergreen,代码行数:12,代码来源:history.go
示例15: getTaskTriggerContext
func getTaskTriggerContext(t *task.Task) (*triggerContext, error) {
ctx := triggerContext{task: t}
t, err := task.FindOne(task.ByBeforeRevisionWithStatuses(t.RevisionOrderNumber, task.CompletedStatuses, t.BuildVariant,
t.DisplayName, t.Project).
Sort([]string{"-" + task.RevisionOrderNumberKey}))
if err != nil {
return nil, err
}
if t != nil {
ctx.previousCompleted = t
}
return &ctx, nil
}
开发者ID:sr527,项目名称:evergreen,代码行数:13,代码来源:alerts_activation.go
示例16: TestCLIFetchSource
func TestCLIFetchSource(t *testing.T) {
testutil.ConfigureIntegrationTest(t, testConfig, "TestCLIFetchSource")
Convey("with a task containing patches and modules", t, func() {
testSetup := setupCLITestHarness()
err := os.RemoveAll("source-patch-1_sample")
So(err, ShouldBeNil)
// first, create a patch
patchSub := patchSubmission{"sample",
testPatch,
"sample patch",
"3c7bfeb82d492dc453e7431be664539c35b5db4b",
"all",
[]string{"all"},
false}
// Set up a test patch that contains module changes
ac, rc, _, err := getAPIClients(&Options{testSetup.settingsFilePath})
So(err, ShouldBeNil)
newPatch, err := ac.PutPatch(patchSub)
So(err, ShouldBeNil)
patches, err := ac.GetPatches(0)
So(err, ShouldBeNil)
err = ac.UpdatePatchModule(newPatch.Id.Hex(), "render-module", testModulePatch, "1e5232709595db427893826ce19289461cba3f75")
So(ac.FinalizePatch(newPatch.Id.Hex()), ShouldBeNil)
patches, err = ac.GetPatches(0)
So(err, ShouldBeNil)
testTask, err := task.FindOne(
db.Query(bson.M{
task.VersionKey: patches[0].Version,
task.BuildVariantKey: "ubuntu",
}))
So(err, ShouldBeNil)
So(testTask, ShouldNotBeNil)
err = fetchSource(ac, rc, "", testTask.Id, false)
So(err, ShouldBeNil)
fileStat, err := os.Stat("./source-patch-1_sample/README.md")
So(err, ShouldBeNil)
// If patch was applied correctly, README.md will have a non-zero size
So(fileStat.Size, ShouldNotEqual, 0)
// If module was fetched, "render" directory should have been created.
// The "blah.md" file should have been created if the patch was applied successfully.
fileStat, err = os.Stat("./source-patch-1_sample/modules/render-module/blah.md")
So(err, ShouldBeNil)
So(fileStat.Size, ShouldNotEqual, 0)
})
}
开发者ID:tychoish,项目名称:evergreen,代码行数:51,代码来源:cli_integration_test.go
示例17: ActivatePreviousTask
// ActivatePreviousTask will set the Active state for the first task with a
// revision order number less than the current task's revision order number.
func ActivatePreviousTask(taskId, caller string) error {
// find the task first
t, err := task.FindOne(task.ById(taskId))
if err != nil {
return err
}
// find previous task limiting to just the last one
prevTask, err := task.FindOne(task.ByBeforeRevision(t.RevisionOrderNumber, t.BuildVariant, t.DisplayName, t.Project, t.Requester))
if err != nil {
return fmt.Errorf("Error finding previous task: %v:", err.Error())
}
// if this is the first time we're running the task, or it's finished or it is blacklisted
if prevTask == nil || task.IsFinished(*prevTask) || prevTask.Priority < 0 {
return nil
}
// activate the task
if err = SetActiveState(prevTask.Id, caller, true); err != nil {
return err
}
return nil
}
开发者ID:tychoish,项目名称:evergreen,代码行数:25,代码来源:task_lifecycle.go
示例18: TestMarkStart
func TestMarkStart(t *testing.T) {
Convey("With a task, build and version", t, func() {
testutil.HandleTestingErr(db.ClearCollections(task.Collection, build.Collection, version.Collection), t,
"Error clearing task and build collections")
displayName := "testName"
b := &build.Build{
Id: "buildtest",
Status: evergreen.BuildCreated,
Version: "abc",
}
v := &version.Version{
Id: b.Version,
Status: evergreen.VersionCreated,
}
testTask := task.Task{
Id: "testTask",
DisplayName: displayName,
Activated: true,
BuildId: b.Id,
Project: "sample",
Status: evergreen.TaskUndispatched,
Version: b.Version,
}
b.Tasks = []build.TaskCache{
{
Id: testTask.Id,
Status: evergreen.TaskUndispatched,
},
}
So(b.Insert(), ShouldBeNil)
So(testTask.Insert(), ShouldBeNil)
So(v.Insert(), ShouldBeNil)
Convey("when calling MarkStart, the task, version and build should be updated", func() {
So(MarkStart(testTask.Id), ShouldBeNil)
testTask, err := task.FindOne(task.ById(testTask.Id))
So(err, ShouldBeNil)
So(testTask.Status, ShouldEqual, evergreen.TaskStarted)
b, err := build.FindOne(build.ById(b.Id))
So(err, ShouldBeNil)
So(b.Status, ShouldEqual, evergreen.BuildStarted)
So(b.Tasks, ShouldNotBeNil)
So(len(b.Tasks), ShouldEqual, 1)
So(b.Tasks[0].Status, ShouldEqual, evergreen.TaskStarted)
v, err := version.FindOne(version.ById(v.Id))
So(err, ShouldBeNil)
So(v.Status, ShouldEqual, evergreen.VersionStarted)
})
})
}
开发者ID:tychoish,项目名称:evergreen,代码行数:50,代码来源:task_lifecycle_test.go
示例19: TestAttachResults
func TestAttachResults(t *testing.T) {
resetTasks(t)
testConfig := evergreen.TestConfig()
cwd := testutil.GetDirectoryOfFile()
Convey("With attachResults plugin installed into plugin registry", t, func() {
registry := plugin.NewSimpleRegistry()
attachPlugin := &AttachPlugin{}
err := registry.Register(attachPlugin)
testutil.HandleTestingErr(err, t, "Couldn't register plugin: %v")
server, err := service.CreateTestServer(testConfig, nil, plugin.APIPlugins, true)
testutil.HandleTestingErr(err, t, "Couldn't set up testing server")
httpCom := plugintest.TestAgentCommunicator("mocktaskid", "mocktasksecret", server.URL)
configFile := filepath.Join(cwd, "testdata", "plugin_attach_results.yml")
resultsLoc := filepath.Join(cwd, "testdata", "plugin_attach_results.json")
taskConfig, err := plugintest.CreateTestConfig(configFile, t)
testutil.HandleTestingErr(err, t, "failed to create test config: %v")
taskConfig.WorkDir = "."
sliceAppender := &evergreen.SliceAppender{[]*slogger.Log{}}
logger := agentutil.NewTestLogger(sliceAppender)
Convey("all commands in test project should execute successfully", func() {
for _, projTask := range taskConfig.Project.Tasks {
So(len(projTask.Commands), ShouldNotEqual, 0)
for _, command := range projTask.Commands {
pluginCmds, err := registry.GetCommands(command, taskConfig.Project.Functions)
testutil.HandleTestingErr(err, t, "Couldn't get plugin command: %v")
So(pluginCmds, ShouldNotBeNil)
So(err, ShouldBeNil)
pluginCom := &comm.TaskJSONCommunicator{pluginCmds[0].Plugin(), httpCom}
err = pluginCmds[0].Execute(logger, pluginCom, taskConfig, make(chan bool))
So(err, ShouldBeNil)
testTask, err := task.FindOne(task.ById(httpCom.TaskId))
testutil.HandleTestingErr(err, t, "Couldn't find task")
So(testTask, ShouldNotBeNil)
// ensure test results are exactly as expected
// attempt to open the file
reportFile, err := os.Open(resultsLoc)
testutil.HandleTestingErr(err, t, "Couldn't open report file: '%v'", err)
results := &task.TestResults{}
err = util.ReadJSONInto(reportFile, results)
testutil.HandleTestingErr(err, t, "Couldn't read report file: '%v'", err)
testResults := *results
So(testTask.TestResults, ShouldResemble, testResults.Results)
testutil.HandleTestingErr(err, t, "Couldn't clean up test temp dir")
}
}
})
})
}
开发者ID:tychoish,项目名称:evergreen,代码行数:50,代码来源:results_command_test.go
示例20: dBTests
// dBTests are the database verification tests for standard one file execution
func dBTests() {
task, err := task.FindOne(task.ById("mocktaskid"))
So(err, ShouldBeNil)
So(len(task.TestResults), ShouldNotEqual, 0)
Convey("along with the proper logs", func() {
// junit_3.xml
tl := dBFindOneTestLog(
"test.test_threads_replica_set_client.TestThreadsReplicaSet.test_safe_update",
)
So(tl.Lines[0], ShouldContainSubstring, "SKIPPED")
tl = dBFindOneTestLog("test.test_bson.TestBSON.test_basic_encode")
So(tl.Lines[0], ShouldContainSubstring, "AssertionError")
})
}
开发者ID:sr527,项目名称:evergreen,代码行数:16,代码来源:xunit_results_command_test.go
注:本文中的github.com/evergreen-ci/evergreen/model/task.FindOne函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论