Skip to content

Commit 1f6e874

Browse files
authored
Merge pull request #4772 from AkihiroSuda/fix-TestLogs
tests: fix flaky TestLogs since/until 1s subtests
2 parents c5745d1 + 90092c6 commit 1f6e874

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cmd/nerdctl/container/container_logs_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ bar
6060
testCase.SubTests = []*test.Case{
6161
{
6262
Description: "since 1s",
63+
Setup: func(data test.Data, helpers test.Helpers) {
64+
// Ensure at least 2 seconds have elapsed since the container ran,
65+
// so that --since 1s does not include the container's output.
66+
time.Sleep(2 * time.Second)
67+
},
6368
Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
6469
return helpers.Command("logs", "--since", "1s", data.Labels().Get("cID"))
6570
},
@@ -81,6 +86,11 @@ bar
8186
},
8287
{
8388
Description: "until 1s",
89+
Setup: func(data test.Data, helpers test.Helpers) {
90+
// Ensure at least 2 seconds have elapsed since the container ran,
91+
// so that --until 1s includes the container's output.
92+
time.Sleep(2 * time.Second)
93+
},
8494
Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
8595
return helpers.Command("logs", "--until", "1s", data.Labels().Get("cID"))
8696
},

0 commit comments

Comments
 (0)