X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/dc021c3b57dcdebe464c148d55f9990a74e8246b..c19811454b70623c0f0f92e07ffc6c4b33deb63d:/lib/dispatchcloud/container/queue_test.go diff --git a/lib/dispatchcloud/container/queue_test.go b/lib/dispatchcloud/container/queue_test.go index 3e1cd5061c..ca10983534 100644 --- a/lib/dispatchcloud/container/queue_test.go +++ b/lib/dispatchcloud/container/queue_test.go @@ -41,6 +41,7 @@ func (suite *IntegrationSuite) TearDownTest(c *check.C) { func (suite *IntegrationSuite) TestGetLockUnlockCancel(c *check.C) { typeChooser := func(ctr *arvados.Container) (arvados.InstanceType, error) { + c.Check(ctr.Mounts["/tmp"].Capacity, check.Equals, int64(24000000000)) return arvados.InstanceType{Name: "testType"}, nil } @@ -64,13 +65,15 @@ func (suite *IntegrationSuite) TestGetLockUnlockCancel(c *check.C) { c.Check(ent.InstanceType.Name, check.Equals, "testType") c.Check(ent.Container.State, check.Equals, arvados.ContainerStateQueued) c.Check(ent.Container.Priority > 0, check.Equals, true) + // Mounts should be deleted to avoid wasting memory + c.Check(ent.Container.Mounts, check.IsNil) ctr, ok := cq.Get(uuid) c.Check(ok, check.Equals, true) 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) @@ -99,13 +102,20 @@ 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() } func (suite *IntegrationSuite) TestCancelIfNoInstanceType(c *check.C) { errorTypeChooser := func(ctr *arvados.Container) (arvados.InstanceType, error) { + // Make sure the relevant container fields are + // actually populated. + c.Check(ctr.ContainerImage, check.Equals, "test") + c.Check(ctr.RuntimeConstraints.VCPUs, check.Equals, 4) + c.Check(ctr.RuntimeConstraints.RAM, check.Equals, int64(12000000000)) + c.Check(ctr.Mounts["/tmp"].Capacity, check.Equals, int64(24000000000)) + c.Check(ctr.Mounts["/var/spool/cwl"].Capacity, check.Equals, int64(24000000000)) return arvados.InstanceType{}, errors.New("no suitable instance type") } @@ -134,10 +144,11 @@ func (suite *IntegrationSuite) TestCancelIfNoInstanceType(c *check.C) { c.Check(err, check.IsNil) c.Check(ctr.State, check.Equals, arvados.ContainerStateQueued) + go cq.Update() + // Wait for the cancel operation to take effect. Container // will have state=Cancelled or just disappear from the queue. suite.waitfor(c, time.Second, func() bool { - cq.Update() err := client.RequestAndDecode(&ctr, "GET", "arvados/v1/containers/"+arvadostest.QueuedContainerUUID, nil, nil) return err == nil && ctr.State == arvados.ContainerStateCancelled })