"net/http/httptest"
"os"
"strings"
+ "syscall"
"testing"
"time"
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()
c.Check(err, IsNil)
- // Give some time for run goroutine to complete
- time.Sleep(1 * time.Second)
-
// There should be no queued containers now
params := arvadosclient.Dict{
"filters": [][]string{[]string{"state", "=", "Queued"}},
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)