14324: Use logrus in Azure driver. Fix Sirupsen->sirupsen in imports
[arvados.git] / lib / dispatchcloud / worker / pool_test.go
index f8667e06cdb3917fcbdee4d563833367eb599545..7551caff9547178338e5ba7c900dadfde2c88184 100644 (file)
@@ -11,7 +11,7 @@ import (
        "git.curoverse.com/arvados.git/lib/cloud"
        "git.curoverse.com/arvados.git/lib/dispatchcloud/test"
        "git.curoverse.com/arvados.git/sdk/go/arvados"
-       "github.com/Sirupsen/logrus"
+       "github.com/sirupsen/logrus"
        check "gopkg.in/check.v1"
 )
 
@@ -68,23 +68,16 @@ func (suite *PoolSuite) TestCreateUnallocShutdown(c *check.C) {
        pool.Create(type2)
        c.Check(pool.Unallocated()[type1], check.Equals, 1)
        c.Check(pool.Unallocated()[type2], check.Equals, 2)
-       // Unblock the pending Create calls and (before calling Sync!)
-       // wait for the pool to process the returned instances.
+
+       // Unblock the pending Create calls.
        go lameInstanceSet.Release(3)
-       suite.wait(c, pool, notify, func() bool {
-               list, err := lameInstanceSet.Instances(nil)
-               return err == nil && len(list) == 3
-       })
 
-       c.Check(pool.Unallocated()[type1], check.Equals, 1)
-       c.Check(pool.Unallocated()[type2], check.Equals, 2)
-       pool.getInstancesAndSync()
-       // Returned counts can be temporarily higher than 1 and 2 if
-       // poll ran before Create() returned.
-       c.Check(pool.Unallocated()[type1], check.Not(less), 1)
-       c.Check(pool.Unallocated()[type2], check.Not(less), 2)
+       // Wait for each instance to either return from its Create
+       // call, or show up in a poll.
        suite.wait(c, pool, notify, func() bool {
-               return pool.Unallocated()[type1] == 1 && pool.Unallocated()[type2] == 2
+               pool.mtx.RLock()
+               defer pool.mtx.RUnlock()
+               return len(pool.workers) == 3
        })
 
        c.Check(pool.Shutdown(type2), check.Equals, true)