From 2e8a572dfd6cc170ed60a45d7d1180d56958eb12 Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Tue, 13 Jul 2021 09:51:48 -0700 Subject: [PATCH 1/2] Add timestamp to flaky restart monitor test Signed-off-by: Derek McGowan --- integration/client/restart_monitor_linux_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration/client/restart_monitor_linux_test.go b/integration/client/restart_monitor_linux_test.go index aa37a1e17..eb1950bdc 100644 --- a/integration/client/restart_monitor_linux_test.go +++ b/integration/client/restart_monitor_linux_test.go @@ -99,8 +99,8 @@ version = 2 } time.Sleep(epsilon) } - t.Fatalf("the task was not restarted in %s + %s", - interval.String(), epsilon.String()) + t.Fatalf("%v: the task was not restarted in %s + %s", + time.Now(), interval.String(), epsilon.String()) } // withRestartStatus is a copy of "github.com/containerd/containerd/runtime/restart".WithStatus. From 18321f539ce5f78e5db034ce0af73076ea4f11b0 Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Tue, 13 Jul 2021 11:54:33 -0700 Subject: [PATCH 2/2] Move loop check to before sleep Signed-off-by: Derek McGowan --- integration/client/restart_monitor_linux_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/integration/client/restart_monitor_linux_test.go b/integration/client/restart_monitor_linux_test.go index eb1950bdc..f9dde83d7 100644 --- a/integration/client/restart_monitor_linux_test.go +++ b/integration/client/restart_monitor_linux_test.go @@ -81,7 +81,7 @@ version = 2 task.Kill(ctx, syscall.SIGKILL) begin := time.Now() deadline := begin.Add(interval).Add(epsilon) - for time.Now().Before(deadline) { + for { status, err := task.Status(ctx) now := time.Now() if err != nil { @@ -97,6 +97,9 @@ version = 2 return } } + if time.Now().After(deadline) { + break + } time.Sleep(epsilon) } t.Fatalf("%v: the task was not restarted in %s + %s",