Forráskód Böngészése

c8d/TestPsListContainersSize: Only check if size increased

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Paweł Gronowski 1 éve
szülő
commit
28d057cb0e
1 módosított fájl, 15 hozzáadás és 3 törlés
  1. 15 3
      integration-cli/docker_cli_ps_test.go

+ 15 - 3
integration-cli/docker_cli_ps_test.go

@@ -186,9 +186,21 @@ func (s *DockerCLIPsSuite) TestPsListContainersSize(c *testing.T) {
 	idIndex := strings.Index(lines[0], "CONTAINER ID")
 	foundID := lines[1][idIndex : idIndex+12]
 	assert.Equal(c, foundID, id[:12], fmt.Sprintf("Expected id %s, got %s", id[:12], foundID))
-	expectedSize := units.HumanSize(float64(baseBytes + 2))
-	foundSize := lines[1][sizeIndex:]
-	assert.Assert(c, strings.Contains(foundSize, expectedSize), "Expected size %q, got %q", expectedSize, foundSize)
+	foundSize, _, _ := strings.Cut(strings.TrimSpace(lines[1][sizeIndex:]), " ")
+
+	// With snapshotters the reported usage is the real space occupied on the
+	// filesystem (also includes metadata), so this new file can actually
+	// result in a bigger increase depending on the underlying filesystem (on
+	// ext4 this would be 4096 which is a minimum allocation unit).
+	if testEnv.UsingSnapshotter() {
+		newBytes, err := units.FromHumanSize(foundSize)
+		assert.NilError(c, err)
+		// Check if size increased by at least 2 bytes.
+		assert.Check(c, newBytes >= baseBytes+2)
+	} else {
+		expectedSize := units.HumanSize(float64(baseBytes + 2))
+		assert.Assert(c, strings.Contains(foundSize, expectedSize), "Expected size %q, got %q", expectedSize, foundSize)
+	}
 }
 
 func (s *DockerCLIPsSuite) TestPsListContainersFilterStatus(c *testing.T) {