Skip to content

Commit

Permalink
Merge pull request #3207 from apostasie/dev-ci-last
Browse files Browse the repository at this point in the history
Test fixes
  • Loading branch information
AkihiroSuda authored Jul 10, 2024
2 parents a47463b + 496c78e commit cf881e2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
5 changes: 0 additions & 5 deletions cmd/nerdctl/builder_build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ CMD ["cat", "/hello2"]
}

func TestBuildFromStdin(t *testing.T) {
t.Parallel()
testutil.RequiresBuild(t)
base := testutil.NewBase(t)
defer base.Cmd("builder", "prune").Run()
Expand Down Expand Up @@ -199,7 +198,6 @@ CMD ["echo", "nerdctl-build-test-dockerfile"]
}

func TestBuildLocal(t *testing.T) {
t.Parallel()
testutil.RequiresBuild(t)
base := testutil.NewBase(t)
if testutil.GetTarget() == testutil.Docker {
Expand Down Expand Up @@ -293,7 +291,6 @@ CMD echo $TEST_STRING
}

func TestBuildWithIIDFile(t *testing.T) {
t.Parallel()
testutil.RequiresBuild(t)
base := testutil.NewBase(t)
defer base.Cmd("builder", "prune").Run()
Expand All @@ -318,7 +315,6 @@ CMD ["echo", "nerdctl-build-test-string"]
}

func TestBuildWithLabels(t *testing.T) {
t.Parallel()
testutil.RequiresBuild(t)
base := testutil.NewBase(t)
defer base.Cmd("builder", "prune").Run()
Expand Down Expand Up @@ -547,7 +543,6 @@ func buildWithNamedBuilder(base *testutil.Base, builderName string, args ...stri
}

func TestBuildAttestation(t *testing.T) {
t.Parallel()
testutil.RequiresBuild(t)
base := testutil.NewBase(t)
builderName := testutil.Identifier(t)
Expand Down
6 changes: 3 additions & 3 deletions cmd/nerdctl/container_logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func TestLogsWithForegroundContainers(t *testing.T) {
}

func TestTailFollowRotateLogs(t *testing.T) {
// FIXME this is flaky by nature... 5 lines is arbitrary, 2000 ms is arbitrary, and both are some sort of educated
// FIXME this is flaky by nature... 2 lines is arbitrary, 10000 ms is arbitrary, and both are some sort of educated
// guess that things will mostly always kinda work maybe...
// Furthermore, parallelizing will put pressure on the daemon which might be even slower in answering, increasing
// the risk of transient failure.
Expand All @@ -222,7 +222,7 @@ func TestTailFollowRotateLogs(t *testing.T) {
containerName := testutil.Identifier(t)

const sampleJSONLog = `{"log":"A\n","stream":"stdout","time":"2024-04-11T12:01:09.800288974Z"}`
const linesPerFile = 5
const linesPerFile = 2

defer base.Cmd("rm", "-f", containerName).Run()
base.Cmd("run", "-d", "--log-driver", "json-file",
Expand All @@ -232,7 +232,7 @@ func TestTailFollowRotateLogs(t *testing.T) {
"sh", "-euc", "while true; do echo A; done").AssertOK()

tailLogCmd := base.Cmd("logs", "-f", containerName)
tailLogCmd.Timeout = 2000 * time.Millisecond
tailLogCmd.Timeout = 10000 * time.Millisecond
tailLogs := strings.Split(strings.TrimSpace(tailLogCmd.Run().Stdout()), "\n")
for _, line := range tailLogs {
if line != "" {
Expand Down
3 changes: 2 additions & 1 deletion pkg/testutil/testutil_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ func NewDelayOnceReader(wrapped io.Reader) io.Reader {
}

func (r *delayOnceReader) Read(p []byte) (int, error) {
r.once.Do(func() { time.Sleep(time.Second) })
// FIXME: this is obviously not exact science. At 1 second, it will fail regularly on the CI under load.
r.once.Do(func() { time.Sleep(2 * time.Second) })
n, err := r.wrapped.Read(p)
if errors.Is(err, io.EOF) {
time.Sleep(time.Second)
Expand Down

0 comments on commit cf881e2

Please sign in to comment.