From 407703f092f7cb920314d1e271fe67829b4beb30 Mon Sep 17 00:00:00 2001 From: Kazuyoshi Kato Date: Wed, 31 Aug 2022 17:29:56 +0000 Subject: [PATCH] Make checkContainerTimestamps less strict on Windows This assertion is flaky on Windows. Because of Go, Windows' time.Now resolution is lower than Linux. Signed-off-by: Kazuyoshi Kato --- metadata/containers_test.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/metadata/containers_test.go b/metadata/containers_test.go index 662d79cec..8f8a7d8ec 100644 --- a/metadata/containers_test.go +++ b/metadata/containers_test.go @@ -21,6 +21,7 @@ import ( "errors" "fmt" "path/filepath" + "runtime" "testing" "time" @@ -687,7 +688,12 @@ func checkContainerTimestamps(t *testing.T, c *containers.Container, now time.Ti } else { // ensure that updatedat is always after createdat if !c.UpdatedAt.After(c.CreatedAt) { - t.Fatalf("timestamp for updatedat not after createdat: %v <= %v", c.UpdatedAt, c.CreatedAt) + if runtime.GOOS == "windows" && c.UpdatedAt == c.CreatedAt { + // Windows' time.Now resolution is lower than Linux, due to Go. + // https://github.com/golang/go/issues/31160 + } else { + t.Fatalf("timestamp for updatedat not after createdat: %v <= %v", c.UpdatedAt, c.CreatedAt) + } } }