Skip to content

Commit

Permalink
container_stats_test.go: avoid checking snapshot size
Browse files Browse the repository at this point in the history
On Linux, the snapshot size differs depending on the backing filesystem.
See issue 7909.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit 76d68b0)
Signed-off-by: Austin Vazquez <macedonv@amazon.com>
  • Loading branch information
AkihiroSuda authored and austinvazquez committed Mar 7, 2024
1 parent 935720b commit 370ef11
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions integration/container_stats_test.go
Expand Up @@ -59,7 +59,7 @@ func TestContainerStats(t *testing.T) {
if err != nil {
return false, err
}
if s.GetWritableLayer().GetUsedBytes().GetValue() != 0 {
if s.GetWritableLayer().GetTimestamp() != 0 {
return true, nil
}
return false, nil
Expand Down Expand Up @@ -101,7 +101,7 @@ func TestContainerConsumedStats(t *testing.T) {
if err != nil {
return false, err
}
if s.GetMemory().GetWorkingSetBytes().GetValue() > 0 {
if s.GetWritableLayer().GetTimestamp() > 0 {
return true, nil
}
return false, nil
Expand Down Expand Up @@ -176,7 +176,7 @@ func TestContainerListStats(t *testing.T) {
return false, err
}
for _, s := range stats {
if s.GetWritableLayer().GetUsedBytes().GetValue() == 0 {
if s.GetWritableLayer().GetTimestamp() == 0 {
return false, nil
}
}
Expand Down Expand Up @@ -234,7 +234,7 @@ func TestContainerListStatsWithIdFilter(t *testing.T) {
if len(stats) != 1 {
return false, errors.New("unexpected stats length")
}
if stats[0].GetWritableLayer().GetUsedBytes().GetValue() != 0 {
if stats[0].GetWritableLayer().GetTimestamp() != 0 {
return true, nil
}
return false, nil
Expand Down Expand Up @@ -295,7 +295,7 @@ func TestContainerListStatsWithSandboxIdFilter(t *testing.T) {

for _, containerStats := range stats {
// Wait for stats on all containers, not just the first one in the list.
if containerStats.GetWritableLayer().GetUsedBytes().GetValue() == 0 {
if containerStats.GetWritableLayer().GetTimestamp() == 0 {
return false, nil
}
}
Expand Down Expand Up @@ -352,7 +352,7 @@ func TestContainerListStatsWithIdSandboxIdFilter(t *testing.T) {
if len(stats) != 1 {
return false, errors.New("unexpected stats length")
}
if stats[0].GetWritableLayer().GetUsedBytes().GetValue() != 0 {
if stats[0].GetWritableLayer().GetTimestamp() != 0 {
return true, nil
}
return false, nil
Expand All @@ -374,7 +374,7 @@ func TestContainerListStatsWithIdSandboxIdFilter(t *testing.T) {
if len(stats) != 1 {
return false, fmt.Errorf("expected only one stat, but got %v", stats)
}
if stats[0].GetWritableLayer().GetUsedBytes().GetValue() != 0 {
if stats[0].GetWritableLayer().GetTimestamp() != 0 {
return true, nil
}
return false, nil
Expand Down Expand Up @@ -404,7 +404,12 @@ func testStats(t *testing.T,
require.NotEmpty(t, s.GetMemory().GetWorkingSetBytes().GetValue())
require.NotEmpty(t, s.GetWritableLayer().GetTimestamp())
require.NotEmpty(t, s.GetWritableLayer().GetFsId().GetMountpoint())
require.NotEmpty(t, s.GetWritableLayer().GetUsedBytes().GetValue())

// UsedBytes of a fresh container can be zero on Linux, depending on the backing filesystem.
// https://github.com/containerd/containerd/issues/7909
if goruntime.GOOS == "windows" {
require.NotEmpty(t, s.GetWritableLayer().GetUsedBytes().GetValue())
}

// Windows does not collect inodes stats.
if goruntime.GOOS != "windows" {
Expand Down

0 comments on commit 370ef11

Please sign in to comment.