X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/e892c7ee96f28bef7d5b2a9314eb9549ee56634d..c3d4f8a585202ec58df5506934b698039c200b68:/services/crunch-dispatch-slurm/crunch-dispatch-slurm_test.go diff --git a/services/crunch-dispatch-slurm/crunch-dispatch-slurm_test.go b/services/crunch-dispatch-slurm/crunch-dispatch-slurm_test.go index c9208a6943..8809e7bcc6 100644 --- a/services/crunch-dispatch-slurm/crunch-dispatch-slurm_test.go +++ b/services/crunch-dispatch-slurm/crunch-dispatch-slurm_test.go @@ -81,7 +81,8 @@ func (s *TestSuite) TestIntegrationCancel(c *C) { return exec.Command("echo") } - container := s.integrationTest(c, func() *exec.Cmd { return exec.Command("echo", "zzzzz-dz642-queuedcontainer") }, + container := s.integrationTest(c, + func() *exec.Cmd { return exec.Command("echo", "zzzzz-dz642-queuedcontainer") }, []string(nil), func(dispatcher *dispatch.Dispatcher, container arvados.Container) { dispatcher.UpdateState(container.UUID, dispatch.Running) @@ -134,7 +135,7 @@ func (s *TestSuite) integrationTest(c *C, }(squeueCmd) squeueCmd = newSqueueCmd - // There should be no queued containers now + // There should be one queued container params := arvadosclient.Dict{ "filters": [][]string{{"state", "=", "Queued"}}, } @@ -145,25 +146,24 @@ func (s *TestSuite) integrationTest(c *C, theConfig.CrunchRunCommand = []string{"echo"} - doneProcessing := make(chan struct{}) dispatcher := dispatch.Dispatcher{ - Arv: arv, - PollInterval: time.Duration(1) * time.Second, + Arv: arv, + PollPeriod: time.Duration(1) * time.Second, RunContainer: func(dispatcher *dispatch.Dispatcher, container arvados.Container, status chan arvados.Container) { go runContainer(dispatcher, container) run(dispatcher, container, status) - doneProcessing <- struct{}{} + dispatcher.Stop() }, - DoneProcessing: doneProcessing} + } - squeueUpdater.StartMonitor(time.Duration(500) * time.Millisecond) + sqCheck = SqueueChecker{Period: 500 * time.Millisecond} - err = dispatcher.RunDispatcher() + err = dispatcher.Run() c.Assert(err, IsNil) - squeueUpdater.Done() + sqCheck.Stop() c.Check(sbatchCmdLine, DeepEquals, sbatchCmdComps) @@ -207,10 +207,9 @@ func testWithServerStub(c *C, apiStubResponses map[string]arvadostest.StubRespon theConfig.CrunchRunCommand = []string{crunchCmd} - doneProcessing := make(chan struct{}) dispatcher := dispatch.Dispatcher{ - Arv: arv, - PollInterval: time.Duration(1) * time.Second, + Arv: arv, + PollPeriod: time.Duration(1) * time.Second, RunContainer: func(dispatcher *dispatch.Dispatcher, container arvados.Container, status chan arvados.Container) { @@ -220,18 +219,18 @@ func testWithServerStub(c *C, apiStubResponses map[string]arvadostest.StubRespon dispatcher.UpdateState(container.UUID, dispatch.Complete) }() run(dispatcher, container, status) - doneProcessing <- struct{}{} + dispatcher.Stop() }, - DoneProcessing: doneProcessing} + } go func() { for i := 0; i < 80 && !strings.Contains(buf.String(), expected); i++ { time.Sleep(100 * time.Millisecond) } - dispatcher.DoneProcessing <- struct{}{} + dispatcher.Stop() }() - err := dispatcher.RunDispatcher() + err := dispatcher.Run() c.Assert(err, IsNil) c.Check(buf.String(), Matches, `(?ms).*`+expected+`.*`) @@ -318,7 +317,7 @@ func testSbatchFuncWithArgs(c *C, args []string) { func (s *MockArvadosServerSuite) TestSbatchPartition(c *C) { theConfig.SbatchArguments = nil - container := arvados.Container{UUID: "123", RuntimeConstraints: arvados.RuntimeConstraints{RAM: 250000000, VCPUs: 1, Partition: []string{"blurb", "b2"}}} + container := arvados.Container{UUID: "123", RuntimeConstraints: arvados.RuntimeConstraints{RAM: 250000000, VCPUs: 1}, SchedulingParameters: arvados.SchedulingParameters{Partitions: []string{"blurb", "b2"}}} sbatchCmd := sbatchFunc(container) var expected []string