Merge branch '14807-prod-blockers'
[arvados.git] / lib / dispatchcloud / node_size_test.go
index 91c6bb1049fb381d9070e747b1f076eec2f95dbc..eef86f74775134b4c6b0848d0b2897c5d47bef29 100644 (file)
@@ -119,3 +119,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))
+}