本文整理汇总了Golang中github.com/evergreen-ci/evergreen/db.SetGlobalSessionProvider函数的典型用法代码示例。如果您正苦于以下问题:Golang SetGlobalSessionProvider函数的具体用法?Golang SetGlobalSessionProvider怎么用?Golang SetGlobalSessionProvider使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetGlobalSessionProvider函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: init
func init() {
db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(
taskImportanceCmpTestConf))
if taskImportanceCmpTestConf.Scheduler.LogFile != "" {
evergreen.SetLogger(taskImportanceCmpTestConf.Scheduler.LogFile)
}
}
开发者ID:himanshugpt,项目名称:evergreen,代码行数:7,代码来源:task_priority_cmp_test.go
示例2: init
func init() {
db.SetGlobalSessionProvider(
db.SessionFactoryFromConfig(hostAllocatorTestConf))
if hostAllocatorTestConf.Scheduler.LogFile != "" {
evergreen.SetLogger(hostAllocatorTestConf.Scheduler.LogFile)
}
}
开发者ID:tychoish,项目名称:evergreen,代码行数:7,代码来源:deficit_based_host_allocator_test.go
示例3: init
func init() {
db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(
taskQueuePersisterTestConf))
if taskQueuePersisterTestConf.Scheduler.LogFile != "" {
evergreen.SetLogger(taskQueuePersisterTestConf.Scheduler.LogFile)
}
}
开发者ID:tychoish,项目名称:evergreen,代码行数:7,代码来源:task_queue_persister_test.go
示例4: init
func init() {
db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(
taskDurationEstimatorTestConf))
if taskDurationEstimatorTestConf.Scheduler.LogFile != "" {
evergreen.SetLogger(taskDurationEstimatorTestConf.Scheduler.LogFile)
}
}
开发者ID:tychoish,项目名称:evergreen,代码行数:7,代码来源:task_duration_estimator_test.go
示例5: TestFindRunningSpawnedHosts
func TestFindRunningSpawnedHosts(t *testing.T) {
testConfig := evergreen.TestConfig()
db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(testConfig))
testutil.HandleTestingErr(db.Clear(Collection), t, "Error"+
" clearing '%v' collection", Collection)
Convey("With calling FindRunningSpawnedHosts...", t, func() {
Convey("if there are no spawned hosts, nothing should be returned",
func() {
spawnedHosts, err := Find(IsRunningAndSpawned)
So(err, ShouldBeNil)
// make sure we only returned no document
So(len(spawnedHosts), ShouldEqual, 0)
})
Convey("if there are spawned hosts, they should be returned", func() {
host := &Host{}
host.Id = "spawned-1"
host.Status = "running"
host.StartedBy = "user1"
testutil.HandleTestingErr(host.Insert(), t, "error from "+
"FindRunningSpawnedHosts")
spawnedHosts, err := Find(IsRunningAndSpawned)
testutil.HandleTestingErr(err, t, "error from "+
"FindRunningSpawnedHosts: %v", err)
// make sure we only returned no document
So(len(spawnedHosts), ShouldEqual, 1)
})
})
}
开发者ID:tychoish,项目名称:evergreen,代码行数:33,代码来源:host_test.go
示例6: main
func main() {
settings := evergreen.GetSettingsOrExit()
if settings.Runner.LogFile != "" {
evergreen.SetLogger(settings.Runner.LogFile)
}
go util.DumpStackOnSIGQUIT(os.Stdout)
db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(settings))
// just run one process if an argument was passed in
if flag.Arg(0) != "" {
err := runProcessByName(flag.Arg(0), settings)
if err != nil {
evergreen.Logger.Logf(slogger.ERROR, "Error: %v", err)
os.Exit(1)
}
return
}
if settings.Runner.IntervalSeconds <= 0 {
evergreen.Logger.Logf(slogger.WARN, "Interval set to %vs (<= 0s) using %vs instead",
settings.Runner.IntervalSeconds, runInterval)
} else {
runInterval = settings.Runner.IntervalSeconds
}
// start and schedule runners
wg := &sync.WaitGroup{}
ch := startRunners(wg, settings)
go listenForSIGTERM(ch)
// wait for all the processes to exit
wg.Wait()
evergreen.Logger.Logf(slogger.INFO, "Cleanly terminated all %v processes", len(Runners))
}
开发者ID:tychoish,项目名称:evergreen,代码行数:35,代码来源:runner.go
示例7: main
func main() {
settings := evergreen.GetSettingsOrExit()
if settings.Ui.LogFile != "" {
evergreen.SetLogger(settings.Ui.LogFile)
}
db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(settings))
home := evergreen.FindEvergreenHome()
userManager, err := auth.LoadUserManager(settings.AuthConfig)
if err != nil {
fmt.Println("Failed to create user manager:", err)
os.Exit(1)
}
cookieStore := sessions.NewCookieStore([]byte(settings.Ui.Secret))
uis := ui.UIServer{
nil, // render
settings.Ui.Url, // RootURL
userManager, // User Manager
*settings, // mci settings
cookieStore, // cookiestore
nil, // plugin panel manager
}
router, err := uis.NewRouter()
if err != nil {
fmt.Println("Failed to create router:", err)
os.Exit(1)
}
webHome := filepath.Join(home, "public")
functionOptions := ui.FuncOptions{webHome, settings.Ui.HelpUrl, true, router}
functions, err := ui.MakeTemplateFuncs(functionOptions, settings.SuperUsers)
if err != nil {
fmt.Println("Failed to create template function map:", err)
os.Exit(1)
}
uis.Render = render.New(render.Options{
Directory: filepath.Join(home, ui.WebRootPath, ui.Templates),
DisableCache: !settings.Ui.CacheTemplates,
Funcs: functions,
})
err = uis.InitPlugins()
if err != nil {
fmt.Println("WARNING: Error initializing plugins:", err)
}
n := negroni.New()
n.Use(negroni.NewStatic(http.Dir(webHome)))
n.Use(ui.NewLogger())
n.Use(negroni.HandlerFunc(ui.UserMiddleware(userManager)))
n.UseHandler(router)
graceful.Run(settings.Ui.HttpListenAddr, requestTimeout, n)
evergreen.Logger.Logf(slogger.INFO, "UI server cleanly terminated")
}
开发者ID:himanshugpt,项目名称:evergreen,代码行数:59,代码来源:ui.go
示例8: init
func init() {
dbutil.SetGlobalSessionProvider(dbutil.SessionFactoryFromConfig(testConfig))
testSetups = []testConfigPath{
{"With plugin mode test config",
filepath.Join(testutil.GetDirectoryOfFile(), "testdata", "config_test_plugin")},
}
}
开发者ID:tychoish,项目名称:evergreen,代码行数:8,代码来源:api_integration_test.go
示例9: 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
示例10: TestS3CopyPluginExecution
func TestS3CopyPluginExecution(t *testing.T) {
testConfig := evergreen.TestConfig()
db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(testConfig))
testutil.ConfigureIntegrationTest(t, testConfig, "TestS3CopyPluginExecution")
Convey("With a SimpleRegistry and test project file", t, func() {
registry := plugin.NewSimpleRegistry()
s3CopyPlugin := &S3CopyPlugin{}
testutil.HandleTestingErr(registry.Register(s3CopyPlugin), t, "failed to register s3Copy plugin")
testutil.HandleTestingErr(registry.Register(&s3Plugin.S3Plugin{}), t, "failed to register S3 plugin")
testutil.HandleTestingErr(
db.ClearCollections(model.PushlogCollection, version.Collection), t,
"error clearing test collections")
version := &version.Version{
Id: "",
}
So(version.Insert(), ShouldBeNil)
server, err := apiserver.CreateTestServer(testConfig, nil, plugin.APIPlugins, false)
testutil.HandleTestingErr(err, t, "Couldn't set up testing server")
httpCom := plugintest.TestAgentCommunicator("mocktaskid", "mocktasksecret", server.URL)
//server.InstallPlugin(s3CopyPlugin)
taskConfig, err := plugintest.CreateTestConfig("testdata/plugin_s3_copy.yml", t)
testutil.HandleTestingErr(err, t, "failed to create test config: %v", err)
taskConfig.WorkDir = "."
sliceAppender := &evergreen.SliceAppender{[]*slogger.Log{}}
logger := agent.NewTestLogger(sliceAppender)
taskConfig.Expansions.Update(map[string]string{
"aws_key": testConfig.Providers.AWS.Id,
"aws_secret": testConfig.Providers.AWS.Secret,
})
Convey("the s3 copy command should execute successfully", func() {
for _, task := range taskConfig.Project.Tasks {
So(len(task.Commands), ShouldNotEqual, 0)
for _, command := range task.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 := &agent.TaskJSONCommunicator{s3CopyPlugin.Name(), httpCom}
err = pluginCmds[0].Execute(logger, pluginCom, taskConfig,
make(chan bool))
So(err, ShouldBeNil)
}
}
})
})
}
开发者ID:himanshugpt,项目名称:evergreen,代码行数:54,代码来源:s3_copy_plugin_test.go
示例11: TestPatchTask
func TestPatchTask(t *testing.T) {
setupTlsConfigs(t)
testConfig := evergreen.TestConfig()
db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(testConfig))
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() {
testTask, _, err := setupAPITestData(testConfig, "compile", "linux-64", true, t)
testutil.HandleTestingErr(err, t, "Error setting up test data: %v", err)
testServer, err := apiserver.CreateTestServer(testConfig, tlsConfig, plugin.Published, Verbose)
testutil.HandleTestingErr(err, t, "Couldn't create apiserver: %v", err)
testAgent, err := New(testServer.URL, testTask.Id, testTask.Secret, "", testConfig.Expansions["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 = model.FindTask(testTask.Id)
testutil.HandleTestingErr(err, t, "Error finding test task: %v", err)
So(testTask.Status, ShouldEqual, evergreen.TaskSucceeded)
})
})
})
}
}
}
开发者ID:markbenvenuto,项目名称:evergreen,代码行数:47,代码来源:patch_integration_test.go
示例12: TestPatchPlugin
func TestPatchPlugin(t *testing.T) {
cwd := testutil.GetDirectoryOfFile()
testConfig := evergreen.TestConfig()
db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(testConfig))
Convey("With patch plugin installed into plugin registry", t, func() {
registry := plugin.NewSimpleRegistry()
gitPlugin := &GitPlugin{}
err := registry.Register(gitPlugin)
testutil.HandleTestingErr(err, t, "Couldn't register plugin %v")
testutil.HandleTestingErr(db.Clear(version.Collection), t,
"unable to clear versions collection")
version := &version.Version{
Id: "",
}
So(version.Insert(), ShouldBeNil)
server, err := service.CreateTestServer(testConfig, nil, plugin.APIPlugins, false)
testutil.HandleTestingErr(err, t, "Couldn't set up testing server")
httpCom := plugintest.TestAgentCommunicator("testTaskId", "testTaskSecret", server.URL)
//sliceAppender := &evergreen.SliceAppender{[]*slogger.Log{}}
sliceAppender := slogger.StdOutAppender()
logger := agentutil.NewTestLogger(sliceAppender)
Convey("all commands in test project should execute successfully", func() {
taskConfig, err := plugintest.CreateTestConfig(filepath.Join(cwd, "testdata", "plugin_patch.yml"), t)
testutil.HandleTestingErr(err, t, "could not create test config")
taskConfig.Task.Requester = evergreen.PatchVersionRequester
_, _, err = plugintest.SetupAPITestData("testTask", filepath.Join(cwd, "testdata", "testmodule.patch"), t)
testutil.HandleTestingErr(err, t, "Couldn't set up test documents")
for _, task := range taskConfig.Project.Tasks {
So(len(task.Commands), ShouldNotEqual, 0)
for _, command := range task.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)
}
}
})
})
}
开发者ID:tychoish,项目名称:evergreen,代码行数:46,代码来源:patch_test.go
示例13: TestFlaggingProvisioningFailedHosts
func TestFlaggingProvisioningFailedHosts(t *testing.T) {
testConfig := evergreen.TestConfig()
db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(testConfig))
Convey("When flagging hosts whose provisioning failed", t, func() {
// reset the db
testutil.HandleTestingErr(db.ClearCollections(host.Collection),
t, "error clearing hosts collection")
Convey("only hosts whose provisioning failed should be"+
" picked up", func() {
host1 := &host.Host{
Id: "h1",
Status: evergreen.HostRunning,
}
testutil.HandleTestingErr(host1.Insert(), t, "error inserting host")
host2 := &host.Host{
Id: "h2",
Status: evergreen.HostUninitialized,
}
testutil.HandleTestingErr(host2.Insert(), t, "error inserting host")
host3 := &host.Host{
Id: "h3",
Status: evergreen.HostProvisionFailed,
}
testutil.HandleTestingErr(host3.Insert(), t, "error inserting host")
unprovisioned, err := flagProvisioningFailedHosts(nil, nil)
So(err, ShouldBeNil)
So(len(unprovisioned), ShouldEqual, 1)
So(unprovisioned[0].Id, ShouldEqual, "h3")
})
})
}
开发者ID:himanshugpt,项目名称:evergreen,代码行数:42,代码来源:host_flagging_test.go
示例14: NewUIServer
func NewUIServer(settings *evergreen.Settings, home string) (*UIServer, error) {
uis := &UIServer{}
if settings.Ui.LogFile != "" {
evergreen.SetLogger(settings.Ui.LogFile)
}
db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(settings))
uis.Settings = *settings
uis.Home = home
userManager, err := auth.LoadUserManager(settings.AuthConfig)
if err != nil {
return nil, err
}
uis.UserManager = userManager
uis.CookieStore = sessions.NewCookieStore([]byte(settings.Ui.Secret))
uis.PluginTemplates = map[string]*htmlTemplate.Template{}
return uis, nil
}
开发者ID:tychoish,项目名称:evergreen,代码行数:22,代码来源:ui.go
示例15: init
func init() {
db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(evergreen.TestConfig()))
}
开发者ID:ramonfm,项目名称:build-baron-plugin,代码行数:3,代码来源:build_baron_test.go
示例16: init
func init() {
db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(taskRunnerTestConf))
if taskRunnerTestConf.TaskRunner.LogFile != "" {
evergreen.SetLogger(taskRunnerTestConf.TaskRunner.LogFile)
}
}
开发者ID:sr527,项目名称:evergreen,代码行数:6,代码来源:task_runner_test.go
示例17: TestPushTask
func TestPushTask(t *testing.T) {
testConfig := evergreen.TestConfig()
setupTlsConfigs(t)
db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(testConfig))
testutil.ConfigureIntegrationTest(t, testConfig, "TestPushTask")
for tlsString, tlsConfig := range tlsConfigs {
for _, testSetup := range testSetups {
Convey(testSetup.testSpec, t, func() {
Convey("With agent running a push task "+tlsString, func() {
testTask, _, err := setupAPITestData(testConfig, evergreen.PushStage,
"linux-64", false, t)
testutil.HandleTestingErr(err, t, "Error setting up test data: %v", err)
testutil.HandleTestingErr(db.ClearCollections(artifact.Collection), t, "can't clear files collection")
testServer, err := apiserver.CreateTestServer(testConfig, tlsConfig, plugin.Published, Verbose)
testutil.HandleTestingErr(err, t, "Couldn't create apiserver: %v", err)
testAgent, err := New(testServer.URL, testTask.Id, testTask.Secret, "", testConfig.Expansions["api_httpscert"])
testutil.HandleTestingErr(err, t, "Error making test agent: %v", err)
// 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)
newDate := testAgent.taskConfig.Expansions.Get("new_date")
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, "push task pre-run!"), ShouldBeTrue)
So(scanLogsForTask(testTask.Id, "push task post-run!"), ShouldBeTrue)
Convey("s3.put attaches task file properly", func() {
entry, err := artifact.FindOne(artifact.ByTaskId(testTask.Id))
So(err, ShouldBeNil)
So(len(entry.Files), ShouldEqual, 2)
for _, element := range entry.Files {
So(element.Name, ShouldNotEqual, "")
}
So(entry.Files[0].Name, ShouldEqual, "push_file")
link := "https://s3.amazonaws.com/build-push-testing/pushtest-stage/unittest-testTaskId-DISTRO_EXP-BUILDVAR_EXP-FILE_EXP.txt"
So(entry.Files[0].Link, ShouldEqual, link)
})
Convey("s3.copy attached task file properly", func() {
entry, err := artifact.FindOne(artifact.ByTaskId(testTask.Id))
So(err, ShouldBeNil)
So(len(entry.Files), ShouldNotEqual, 0)
So(entry.Files[0].Name, ShouldEqual, "push_file")
So(entry.Files[1].Name, ShouldEqual, "copy_file")
So(entry.Files[0].Link, ShouldEqual, "https://s3.amazonaws.com/build-push-testing/pushtest-stage/unittest-testTaskId-DISTRO_EXP-BUILDVAR_EXP-FILE_EXP.txt")
So(entry.Files[1].Link, ShouldEqual,
"https://s3.amazonaws.com/build-push-testing/pushtest/unittest-DISTRO_EXP-BUILDVAR_EXP-FILE_EXP-latest.txt")
})
testTask, err = model.FindTask(testTask.Id)
testutil.HandleTestingErr(err, t, "Error finding test task: %v", err)
So(testTask.Status, ShouldEqual, evergreen.TaskSucceeded)
// Check the file written to s3 is what we expected
auth := &aws.Auth{
AccessKey: testConfig.Providers.AWS.Id,
SecretKey: testConfig.Providers.AWS.Secret,
}
// check the staging location first
filebytes, err := getS3FileBytes(auth, "build-push-testing", "/pushtest-stage/unittest-testTaskId-DISTRO_EXP-BUILDVAR_EXP-FILE_EXP.txt")
testutil.HandleTestingErr(err, t, "Failed to get file from s3: %v", err)
So(string(filebytes), ShouldEqual, newDate+"\n")
// now check remote location (after copy)
filebytes, err = getS3FileBytes(auth, "build-push-testing", "/pushtest/unittest-DISTRO_EXP-BUILDVAR_EXP-FILE_EXP-latest.txt")
testutil.HandleTestingErr(err, t, "Failed to get remote file from s3: %v", err)
So(string(filebytes), ShouldEqual, newDate+"\n")
})
})
})
}
}
}
开发者ID:markbenvenuto,项目名称:evergreen,代码行数:81,代码来源:push_integration_test.go
示例18: TestWarnSlowProvisioningHosts
func TestWarnSlowProvisioningHosts(t *testing.T) {
testConfig := evergreen.TestConfig()
db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(testConfig))
Convey("When building warnings for hosts that are taking a long time to"+
" provision", t, func() {
// reset the db
testutil.HandleTestingErr(db.ClearCollections(host.Collection),
t, "error clearing hosts collection")
Convey("hosts that have not hit the threshold should not trigger a"+
" warning", func() {
host1 := &host.Host{
Id: "h1",
StartedBy: evergreen.User,
CreationTime: time.Now().Add(-10 * time.Minute),
}
testutil.HandleTestingErr(host1.Insert(), t, "error inserting host")
warnings, err := slowProvisioningWarnings(testConfig)
So(err, ShouldBeNil)
So(len(warnings), ShouldEqual, 0)
})
Convey("hosts that have already triggered a notification should not"+
" trigger another", func() {
host1 := &host.Host{
Id: "h1",
StartedBy: evergreen.User,
CreationTime: time.Now().Add(-1 * time.Hour),
Notifications: map[string]bool{
slowProvisioningWarning: true,
},
}
testutil.HandleTestingErr(host1.Insert(), t, "error inserting host")
warnings, err := slowProvisioningWarnings(testConfig)
So(err, ShouldBeNil)
So(len(warnings), ShouldEqual, 0)
})
Convey("terminated hosts should not trigger a warning", func() {
host1 := &host.Host{
Id: "h1",
StartedBy: evergreen.User,
Status: evergreen.HostTerminated,
CreationTime: time.Now().Add(-1 * time.Hour),
}
testutil.HandleTestingErr(host1.Insert(), t, "error inserting host")
warnings, err := slowProvisioningWarnings(testConfig)
So(err, ShouldBeNil)
So(len(warnings), ShouldEqual, 0)
})
Convey("hosts that are at the threshold and have not previously"+
" triggered a warning should trigger one", func() {
host1 := &host.Host{
Id: "h1",
StartedBy: evergreen.User,
CreationTime: time.Now().Add(-1 * time.Hour),
}
testutil.HandleTestingErr(host1.Insert(), t, "error inserting host")
warnings, err := slowProvisioningWarnings(testConfig)
So(err, ShouldBeNil)
So(len(warnings), ShouldEqual, 1)
// make sure running the callback sets the notification key
So(warnings[0].callback(warnings[0].host, warnings[0].threshold), ShouldBeNil)
host1, err = host.FindOne(host.ById("h1"))
So(err, ShouldBeNil)
So(host1.Notifications[slowProvisioningWarning], ShouldBeTrue)
})
})
}
开发者ID:himanshugpt,项目名称:evergreen,代码行数:88,代码来源:notification_test.go
示例19: init
func init() {
db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(taskFinderTestConf))
if setupFuncsTestConf.Scheduler.LogFile != "" {
evergreen.SetLogger(setupFuncsTestConf.Scheduler.LogFile)
}
}
开发者ID:himanshugpt,项目名称:evergreen,代码行数:6,代码来源:setup_funcs_test.go
示例20: reset
func reset(t *testing.T) {
db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(evergreen.TestConfig()))
testutil.HandleTestingErr(
db.ClearCollections(model.TasksCollection, model.TestLogCollection), t,
"error clearing test collections")
}
开发者ID:himanshugpt,项目名称:evergreen,代码行数:6,代码来源:gotest_plugin_test.go
注:本文中的github.com/evergreen-ci/evergreen/db.SetGlobalSessionProvider函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论