@@ -61,7 +61,7 @@ func TestContainerStats(t *testing.T) {
6161 if err != nil {
6262 return false , err
6363 }
64- if s .GetWritableLayer ().GetUsedBytes (). GetValue () != 0 {
64+ if s .GetWritableLayer ().GetTimestamp () != 0 {
6565 return true , nil
6666 }
6767 return false , nil
@@ -103,7 +103,7 @@ func TestContainerConsumedStats(t *testing.T) {
103103 if err != nil {
104104 return false , err
105105 }
106- if s .GetMemory ().GetWorkingSetBytes (). GetValue () > 0 {
106+ if s .GetWritableLayer ().GetTimestamp () > 0 {
107107 return true , nil
108108 }
109109 return false , nil
@@ -179,7 +179,7 @@ func TestContainerListStats(t *testing.T) {
179179 return false , err
180180 }
181181 for _ , s := range stats {
182- if s .GetWritableLayer ().GetUsedBytes (). GetValue () == 0 {
182+ if s .GetWritableLayer ().GetTimestamp () == 0 {
183183 return false , nil
184184 }
185185 }
@@ -238,7 +238,7 @@ func TestContainerListStatsWithIdFilter(t *testing.T) {
238238 if len (stats ) != 1 {
239239 return false , errors .New ("unexpected stats length" )
240240 }
241- if stats [0 ].GetWritableLayer ().GetUsedBytes (). GetValue () != 0 {
241+ if stats [0 ].GetWritableLayer ().GetTimestamp () != 0 {
242242 return true , nil
243243 }
244244 return false , nil
@@ -300,7 +300,7 @@ func TestContainerListStatsWithSandboxIdFilter(t *testing.T) {
300300
301301 for _ , containerStats := range stats {
302302 // Wait for stats on all containers, not just the first one in the list.
303- if containerStats .GetWritableLayer ().GetUsedBytes (). GetValue () == 0 {
303+ if containerStats .GetWritableLayer ().GetTimestamp () == 0 {
304304 return false , nil
305305 }
306306 }
@@ -358,7 +358,7 @@ func TestContainerListStatsWithIdSandboxIdFilter(t *testing.T) {
358358 if len (stats ) != 1 {
359359 return false , errors .New ("unexpected stats length" )
360360 }
361- if stats [0 ].GetWritableLayer ().GetUsedBytes (). GetValue () != 0 {
361+ if stats [0 ].GetWritableLayer ().GetTimestamp () != 0 {
362362 return true , nil
363363 }
364364 return false , nil
@@ -380,7 +380,7 @@ func TestContainerListStatsWithIdSandboxIdFilter(t *testing.T) {
380380 if len (stats ) != 1 {
381381 return false , fmt .Errorf ("expected only one stat, but got %v" , stats )
382382 }
383- if stats [0 ].GetWritableLayer ().GetUsedBytes (). GetValue () != 0 {
383+ if stats [0 ].GetWritableLayer ().GetTimestamp () != 0 {
384384 return true , nil
385385 }
386386 return false , nil
@@ -410,7 +410,12 @@ func testStats(t *testing.T,
410410 require .NotEmpty (t , s .GetMemory ().GetWorkingSetBytes ().GetValue ())
411411 require .NotEmpty (t , s .GetWritableLayer ().GetTimestamp ())
412412 require .NotEmpty (t , s .GetWritableLayer ().GetFsId ().GetMountpoint ())
413- require .NotEmpty (t , s .GetWritableLayer ().GetUsedBytes ().GetValue ())
413+
414+ // UsedBytes of a fresh container can be zero on Linux, depending on the backing filesystem.
415+ // https://github.com/containerd/containerd/issues/7909
416+ if goruntime .GOOS == "windows" {
417+ require .NotEmpty (t , s .GetWritableLayer ().GetUsedBytes ().GetValue ())
418+ }
414419
415420 // Windows does not collect inodes stats.
416421 if goruntime .GOOS != "windows" {
0 commit comments