From ee84e8575840fa15291d490679c9a413bc2e3137 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Thu, 11 Mar 2021 15:34:19 +0900 Subject: [PATCH] deflake TestRestartMonitor Fix #5146 Signed-off-by: Akihiro Suda --- restart_monitor_linux_test.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/restart_monitor_linux_test.go b/restart_monitor_linux_test.go index 631821124..df4669de2 100644 --- a/restart_monitor_linux_test.go +++ b/restart_monitor_linux_test.go @@ -82,15 +82,19 @@ version = 2 deadline := begin.Add(interval).Add(epsilon) for time.Now().Before(deadline) { status, err := task.Status(ctx) + now := time.Now() if err != nil { - t.Fatal(err) - } - t.Logf("%v: status=%q", time.Now(), status) + // ErrNotFound is expected here, because the restart monitor + // temporarily removes the task before restarting. + t.Logf("%v: err=%v", now, err) + } else { + t.Logf("%v: status=%q", now, status) - if status.Status == Running { - elapsed := time.Since(begin) - t.Logf("the task was restarted after %s", elapsed.String()) - return + if status.Status == Running { + elapsed := time.Since(begin) + t.Logf("the task was restarted within %s", elapsed.String()) + return + } } time.Sleep(epsilon) }