12630: Call nvidia-modprobe, support CUDA_VISIBLE_DEVICES
[arvados.git] / lib / dispatchcloud / scheduler / sync_test.go
index ae264bb29887fa0bb65e092b655da76eec2fedd6..a3ff0636e1cd9e7eec69beacc1956c3fa3db08c9 100644 (file)
@@ -48,7 +48,7 @@ func (*SchedulerSuite) TestForgetIrrelevantContainers(c *check.C) {
        ents, _ := queue.Entries()
        c.Check(ents, check.HasLen, 1)
 
-       sch := New(ctx, &queue, &pool, time.Millisecond, time.Millisecond)
+       sch := New(ctx, &queue, &pool, nil, time.Millisecond, time.Millisecond)
        sch.sync()
 
        ents, _ = queue.Entries()
@@ -80,10 +80,18 @@ func (*SchedulerSuite) TestCancelOrphanedContainers(c *check.C) {
        ents, _ := queue.Entries()
        c.Check(ents, check.HasLen, 1)
 
-       sch := New(ctx, &queue, &pool, time.Millisecond, time.Millisecond)
+       sch := New(ctx, &queue, &pool, nil, time.Millisecond, time.Millisecond)
 
        // Sync shouldn't cancel the container because it might be
        // running on the VM with state=="unknown".
+       //
+       // (Cancel+forget happens asynchronously and requires multiple
+       // sync() calls, so even after 10x sync-and-sleep iterations,
+       // we aren't 100% confident that sync isn't trying to
+       // cancel. But in the test environment, the goroutines started
+       // by sync() access stubs and therefore run quickly, so it
+       // works fine in practice. We accept that if the code is
+       // broken, the test will still pass occasionally.)
        for i := 0; i < 10; i++ {
                sch.sync()
                time.Sleep(time.Millisecond)
@@ -94,6 +102,10 @@ func (*SchedulerSuite) TestCancelOrphanedContainers(c *check.C) {
 
        // Sync should cancel & forget the container when the
        // "unknown" node goes away.
+       //
+       // (As above, cancel+forget is async and requires multiple
+       // sync() calls, but stubs are fast so in practice this takes
+       // much less than 1s to complete.)
        pool.unknown = nil
        for deadline := time.Now().Add(time.Second); ; time.Sleep(time.Millisecond) {
                sch.sync()