X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/e4b791cbe3536f08fbb5df10cf8de11c2d816e04..abfdd429351ad6b457667b624c8ba550ffcac999:/services/crunch-dispatch-local/crunch-dispatch-local_test.go diff --git a/services/crunch-dispatch-local/crunch-dispatch-local_test.go b/services/crunch-dispatch-local/crunch-dispatch-local_test.go index 1d526b91cd..3ec1e2ec6b 100644 --- a/services/crunch-dispatch-local/crunch-dispatch-local_test.go +++ b/services/crunch-dispatch-local/crunch-dispatch-local_test.go @@ -10,6 +10,7 @@ import ( "net/http/httptest" "os" "strings" + "syscall" "testing" "time" @@ -59,12 +60,12 @@ func (s *MockArvadosServerSuite) TearDownTest(c *C) { } func (s *TestSuite) Test_doMain(c *C) { - args := []string{"-poll-interval", "1", "-container-priority-poll-interval", "1", "-crunch-run-command", "echo"} + args := []string{"-poll-interval", "2", "-container-priority-poll-interval", "1", "-crunch-run-command", "echo"} os.Args = append(os.Args, args...) go func() { - time.Sleep(2 * time.Second) - doneProcessing <- true + time.Sleep(5 * time.Second) + sigChan <- syscall.SIGINT }() err := doMain() @@ -77,7 +78,7 @@ func (s *TestSuite) Test_doMain(c *C) { var containers ContainerList err = arv.List("containers", params, &containers) c.Check(err, IsNil) - c.Assert(containers.ItemsAvailable, Equals, 0) + c.Assert(len(containers.Items), Equals, 0) // Previously "Queued" container should now be in "Complete" state var container Container @@ -144,14 +145,14 @@ func testWithServerStub(c *C, apiStubResponses map[string]arvadostest.StubRespon log.SetOutput(tempfile) go func() { - time.Sleep(1 * time.Second) - doneProcessing <- true + time.Sleep(2 * time.Second) + sigChan <- syscall.SIGTERM }() runQueuedContainers(1, 1, crunchCmd) - // Give some time for run goroutine to complete - time.Sleep(5 * time.Second) + // Wait for all running crunch jobs to complete / terminate + waitGroup.Wait() buf, _ := ioutil.ReadFile(tempfile.Name()) c.Check(strings.Contains(string(buf), expected), Equals, true)