github.com/superfly/nomad@v0.10.5-fly/command/util_test.go (about) 1 package command 2 3 import ( 4 "testing" 5 6 "github.com/hashicorp/nomad/api" 7 "github.com/hashicorp/nomad/command/agent" 8 "github.com/hashicorp/nomad/helper" 9 ) 10 11 func testServer(t *testing.T, runClient bool, cb func(*agent.Config)) (*agent.TestAgent, *api.Client, string) { 12 // Make a new test server 13 a := agent.NewTestAgent(t, t.Name(), func(config *agent.Config) { 14 config.Client.Enabled = runClient 15 16 if cb != nil { 17 cb(config) 18 } 19 }) 20 21 c := a.Client() 22 return a, c, a.HTTPAddr() 23 } 24 25 func testJob(jobID string) *api.Job { 26 task := api.NewTask("task1", "mock_driver"). 27 SetConfig("kill_after", "1s"). 28 SetConfig("run_for", "5s"). 29 SetConfig("exit_code", 0). 30 Require(&api.Resources{ 31 MemoryMB: helper.IntToPtr(256), 32 CPU: helper.IntToPtr(100), 33 }). 34 SetLogConfig(&api.LogConfig{ 35 MaxFiles: helper.IntToPtr(1), 36 MaxFileSizeMB: helper.IntToPtr(2), 37 }) 38 39 group := api.NewTaskGroup("group1", 1). 40 AddTask(task). 41 RequireDisk(&api.EphemeralDisk{ 42 SizeMB: helper.IntToPtr(20), 43 }) 44 45 job := api.NewBatchJob(jobID, jobID, "global", 1). 46 AddDatacenter("dc1"). 47 AddTaskGroup(group) 48 49 return job 50 }