X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/4a2dc82a1acce855151928abe0030e1dd7dbf728..89bdd6bf07147ad707125fc3882caebb5402ab09:/lib/dispatchcloud/node_size_test.go diff --git a/lib/dispatchcloud/node_size_test.go b/lib/dispatchcloud/node_size_test.go index 91c6bb1049..abd292cbaf 100644 --- a/lib/dispatchcloud/node_size_test.go +++ b/lib/dispatchcloud/node_size_test.go @@ -5,7 +5,7 @@ package dispatchcloud import ( - "git.curoverse.com/arvados.git/sdk/go/arvados" + "git.arvados.org/arvados.git/sdk/go/arvados" check "gopkg.in/check.v1" ) @@ -73,8 +73,14 @@ func (*NodeSizeSuite) TestChoose(c *check.C) { "best": {Price: 3.3, RAM: 4000000000, VCPUs: 4, Scratch: 2 * GiB, Name: "best"}, "costly": {Price: 4.4, RAM: 4000000000, VCPUs: 8, Scratch: 2 * GiB, Name: "costly"}, }, + { + "small": {Price: 1.1, RAM: 1000000000, VCPUs: 2, Scratch: GiB, Name: "small"}, + "nearly": {Price: 2.2, RAM: 1200000000, VCPUs: 4, Scratch: 2 * GiB, Name: "nearly"}, + "best": {Price: 3.3, RAM: 4000000000, VCPUs: 4, Scratch: 2 * GiB, Name: "best"}, + "costly": {Price: 4.4, RAM: 4000000000, VCPUs: 8, Scratch: 2 * GiB, Name: "costly"}, + }, } { - best, err := ChooseInstanceType(&arvados.Cluster{InstanceTypes: menu}, &arvados.Container{ + best, err := ChooseInstanceType(&arvados.Cluster{InstanceTypes: menu, Containers: arvados.ContainersConfig{ReserveExtraRAM: 268435456}}, &arvados.Container{ Mounts: map[string]arvados.Mount{ "/tmp": {Kind: "tmp", Capacity: 2 * int64(GiB)}, }, @@ -119,3 +125,25 @@ func (*NodeSizeSuite) TestChoosePreemptable(c *check.C) { c.Check(best.Scratch >= 2*GiB, check.Equals, true) c.Check(best.Preemptible, check.Equals, true) } + +func (*NodeSizeSuite) TestScratchForDockerImage(c *check.C) { + n := EstimateScratchSpace(&arvados.Container{ + ContainerImage: "d5025c0f29f6eef304a7358afa82a822+342", + }) + // Actual image is 371.1 MiB (according to workbench) + // Estimated size is 384 MiB (402653184 bytes) + // Want to reserve 2x the estimated size, so 805306368 bytes + c.Check(n, check.Equals, int64(805306368)) + + n = EstimateScratchSpace(&arvados.Container{ + ContainerImage: "d5025c0f29f6eef304a7358afa82a822+-342", + }) + // Parse error will return 0 + c.Check(n, check.Equals, int64(0)) + + n = EstimateScratchSpace(&arvados.Container{ + ContainerImage: "d5025c0f29f6eef304a7358afa82a822+34", + }) + // Short manifest will return 0 + c.Check(n, check.Equals, int64(0)) +}