testing: fixed test flake in TestSnapshotCounters (#1645)

* testing: added logging to figure out root cause of the flake in TestSnapshotCounters

* fixed test flake caused by not waiting for upload task to be created
This commit is contained in:
Jarek Kowalski authored and GitHub committed 2022-01-03 21:32:44 -08:00
1 parent 16a31c7247
commit f54049aed7
1 file changed
+14
+14
View File
@@ -66,8 +66,22 @@ func TestSnapshotCounters(t *testing.T) {
require.True(t, uresp.Sources[si.String()].Success)
require.NoError(t, err)
// wait until new task for the upload is created
deadline := clock.Now().Add(10 * time.Second)
for mustGetLatestTask(t, cli).TaskID == et.TaskID && clock.Now().Before(deadline) {
time.Sleep(100 * time.Microsecond)
}
ut := waitForTask(t, cli, mustGetLatestTask(t, cli).TaskID, 15*time.Second)
t.Logf("got latest task: %v", ut)
allTasks := mustListTasks(t, cli)
for tid, tsk := range allTasks {
t.Logf("allTasks[%v] = %v", tid, tsk)
}
require.Equal(t, ut.Counters["Hashed Files"], uitask.SimpleCounter(3))
require.Equal(t, ut.Counters["Hashed Bytes"], uitask.BytesCounter(9))
require.Equal(t, ut.Counters["Excluded Directories"], uitask.SimpleCounter(1))