Fix flakiness on Windows for list stats

This change fixes flakiness on Windows for TestContainerListStatsWithSandboxIdFilter

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
Gabriel Adrian Samfira 2021-12-17 17:36:11 +02:00
parent b93119501f
commit aadae6d50b
No known key found for this signature in database
GPG Key ID: 7D073DCC2C074CB5

View File

@ -292,10 +292,14 @@ func TestContainerListStatsWithSandboxIdFilter(t *testing.T) {
if len(stats) != 3 {
return false, errors.New("unexpected stats length")
}
if stats[0].GetWritableLayer().GetUsedBytes().GetValue() != 0 {
return true, nil
for _, containerStats := range stats {
// Wait for stats on all containers, not just the first one in the list.
if containerStats.GetWritableLayer().GetUsedBytes().GetValue() == 0 {
return false, nil
}
}
return false, nil
return true, nil
}, time.Second, 45*time.Second))
// TODO(claudiub): Reduce the timer above to 30 seconds once Windows flakiness has been addressed.
t.Logf("Verify container stats for sandbox %q", sb)