Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
container_stats_test.go: avoid checking snapshot size
On Linux, the snapshot size differs depending on the backing filesystem.
See issue 7909.

Signed-off-by: Akihiro Suda <[email protected]>
  • Loading branch information
AkihiroSuda committed Jan 3, 2023
commit 76d68b080ef69407129a5925ae5b97f1c9010dea
21 changes: 13 additions & 8 deletions integration/container_stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,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 @@ -103,7 +103,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 @@ -179,7 +179,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 @@ -238,7 +238,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 @@ -300,7 +300,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 @@ -358,7 +358,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 @@ -380,7 +380,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 @@ -410,7 +410,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