X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/30fc42873b2c82e72a95393eb053abf1f7052618..7c7b9ab80e1b33a108c55a23b3dfe793a73ecc95:/lib/dispatchcloud/container/queue_test.go diff --git a/lib/dispatchcloud/container/queue_test.go b/lib/dispatchcloud/container/queue_test.go index daf7977ad5..31f321488e 100644 --- a/lib/dispatchcloud/container/queue_test.go +++ b/lib/dispatchcloud/container/queue_test.go @@ -11,8 +11,8 @@ import ( "testing" "time" - "git.curoverse.com/arvados.git/sdk/go/arvados" - "git.curoverse.com/arvados.git/sdk/go/arvadostest" + "git.arvados.org/arvados.git/sdk/go/arvados" + "git.arvados.org/arvados.git/sdk/go/arvadostest" "github.com/sirupsen/logrus" check "gopkg.in/check.v1" ) @@ -70,11 +70,11 @@ func (suite *IntegrationSuite) TestGetLockUnlockCancel(c *check.C) { c.Check(ctr.UUID, check.Equals, uuid) wg.Add(1) - go func() { + go func(uuid string) { defer wg.Done() err := cq.Unlock(uuid) c.Check(err, check.NotNil) - c.Check(err, check.ErrorMatches, ".*cannot unlock when Queued*.") + c.Check(err, check.ErrorMatches, ".*cannot unlock when Queued.*") err = cq.Lock(uuid) c.Check(err, check.IsNil) @@ -99,7 +99,7 @@ func (suite *IntegrationSuite) TestGetLockUnlockCancel(c *check.C) { c.Check(ctr.State, check.Equals, arvados.ContainerStateCancelled) err = cq.Lock(uuid) c.Check(err, check.NotNil) - }() + }(uuid) } wg.Wait() } @@ -112,12 +112,29 @@ func (suite *IntegrationSuite) TestCancelIfNoInstanceType(c *check.C) { client := arvados.NewClientFromEnv() cq := NewQueue(logger(), nil, errorTypeChooser, client) + ch := cq.Subscribe() + go func() { + defer cq.Unsubscribe(ch) + for range ch { + // Container should never be added to + // queue. Note that polling the queue this way + // doesn't guarantee a bug (container being + // incorrectly added to the queue) will cause + // a test failure. + _, ok := cq.Get(arvadostest.QueuedContainerUUID) + if !c.Check(ok, check.Equals, false) { + // Don't spam the log with more failures + break + } + } + }() + var ctr arvados.Container err := client.RequestAndDecode(&ctr, "GET", "arvados/v1/containers/"+arvadostest.QueuedContainerUUID, nil, nil) c.Check(err, check.IsNil) c.Check(ctr.State, check.Equals, arvados.ContainerStateQueued) - cq.Update() + go cq.Update() // Wait for the cancel operation to take effect. Container // will have state=Cancelled or just disappear from the queue.