Skip to content

Commit 28d057c

Browse files
committed
c8d/TestPsListContainersSize: Only check if size increased
Signed-off-by: Paweł Gronowski <[email protected]>
1 parent 34400dd commit 28d057c

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

integration-cli/docker_cli_ps_test.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,21 @@ func (s *DockerCLIPsSuite) TestPsListContainersSize(c *testing.T) {
186186
idIndex := strings.Index(lines[0], "CONTAINER ID")
187187
foundID := lines[1][idIndex : idIndex+12]
188188
assert.Equal(c, foundID, id[:12], fmt.Sprintf("Expected id %s, got %s", id[:12], foundID))
189-
expectedSize := units.HumanSize(float64(baseBytes + 2))
190-
foundSize := lines[1][sizeIndex:]
191-
assert.Assert(c, strings.Contains(foundSize, expectedSize), "Expected size %q, got %q", expectedSize, foundSize)
189+
foundSize, _, _ := strings.Cut(strings.TrimSpace(lines[1][sizeIndex:]), " ")
190+
191+
// With snapshotters the reported usage is the real space occupied on the
192+
// filesystem (also includes metadata), so this new file can actually
193+
// result in a bigger increase depending on the underlying filesystem (on
194+
// ext4 this would be 4096 which is a minimum allocation unit).
195+
if testEnv.UsingSnapshotter() {
196+
newBytes, err := units.FromHumanSize(foundSize)
197+
assert.NilError(c, err)
198+
// Check if size increased by at least 2 bytes.
199+
assert.Check(c, newBytes >= baseBytes+2)
200+
} else {
201+
expectedSize := units.HumanSize(float64(baseBytes + 2))
202+
assert.Assert(c, strings.Contains(foundSize, expectedSize), "Expected size %q, got %q", expectedSize, foundSize)
203+
}
192204
}
193205

194206
func (s *DockerCLIPsSuite) TestPsListContainersFilterStatus(c *testing.T) {

0 commit comments

Comments
 (0)