Skip to content
Merged

Chores #3564

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/nerdctl/container/container_create_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ func TestCreateWithMACAddress(t *testing.T) {
// res = base.Cmd("start", "-i", containerName).
// CmdOption(testutil.WithStdin(strings.NewReader("ip addr show eth0 | grep ether | awk '{printf $2}'"))).Run()
res = base.Cmd("start", "-a", containerName).Run()
// FIXME: flaky - this has failed on the CI once, with the output NOT containing anything
// https://github.com/containerd/nerdctl/actions/runs/11392051487/job/31697214002?pr=3535#step:7:271
assert.Assert(t, strings.Contains(res.Stdout(), expect), fmt.Sprintf("expected output to contain %q: %q", expect, res.Stdout()))
assert.Assert(t, res.ExitCode == 0, "Command should have succeeded")
} else {
Expand Down
1 change: 1 addition & 0 deletions cmd/nerdctl/container/container_logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func TestLogsOutStreamsSeparated(t *testing.T) {
}

func TestLogsWithInheritedFlags(t *testing.T) {
// Seen flaky with Docker
t.Parallel()
base := testutil.NewBase(t)
for k, v := range base.Args {
Expand Down
2 changes: 2 additions & 0 deletions cmd/nerdctl/container/container_stop_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ func TestStopStart(t *testing.T) {

func TestStopWithStopSignal(t *testing.T) {
t.Parallel()
// There may be issues with logs in Docker.
// This test is flaky with Docker. Might be related to https://github.com/containerd/nerdctl/pull/3557
base := testutil.NewBase(t)
testContainerName := testutil.Identifier(t)
defer base.Cmd("rm", "-f", testContainerName).Run()
Expand Down
5 changes: 5 additions & 0 deletions cmd/nerdctl/image/image_inspect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package image

import (
"encoding/json"
"runtime"
"strings"
"testing"

Expand Down Expand Up @@ -63,6 +64,10 @@ func TestImageInspectSimpleCases(t *testing.T) {
},
}

if runtime.GOOS == "windows" {
testCase.Require = nerdtest.IsFlaky("https://github.com/containerd/nerdctl/issues/3524")
}

testCase.Run(t)
}

Expand Down
11 changes: 9 additions & 2 deletions cmd/nerdctl/image/image_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package image

import (
"fmt"
"runtime"
"slices"
"strings"
"testing"
Expand Down Expand Up @@ -117,6 +118,13 @@ func TestImages(t *testing.T) {
},
}

if runtime.GOOS == "windows" {
testCase.Require = test.Require(
testCase.Require,
nerdtest.IsFlaky("https://github.com/containerd/nerdctl/issues/3524"),
)
Comment on lines +122 to +125
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain this a bit?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

On windows, this may fail (randomly) - detailed in the linked ticket.

nerdtest.IsFlaky("issue link") is part of the new test framework (https://github.com/containerd/nerdctl/blob/main/docs/testing/tools.md#requirements)

It marks a test as flaky, which makes it run only if -test.only-flaky is provided to the integration test.
Very soon, with PR #3535 we will have separate steps to run non-flaky (no retries, hard failure) and flaky tests (retries, hard fail only if all retries fail).

Now, this test also has a requirement of not(docker):

Require: test.Not(nerdtest.Docker),

and I do not want that to get overridden here (otherwise, if ran on windows against target docker, the test would not be skipped).

test.Require(reqs...) is a helper that just bundles together a set of requirements (the previous one testCase.Require, and the conditional one IsFlaky).

Lmk if that does not clarify or if your question was about something I missed?

Thanks @djdongjin

}

testCase.Run(t)
}

Expand Down Expand Up @@ -179,7 +187,7 @@ RUN echo "actually creating a layer so that docker sets the createdAt time"
},
},
{
Description: "label=foo=bar label=version=0.1",
Description: "label=foo=bar label=version=0.2",
Command: test.Command("images", "--filter", "label=foo=bar", "--filter", "label=version=0.2"),
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
return &test.Expected{
Expand All @@ -189,7 +197,6 @@ RUN echo "actually creating a layer so that docker sets the createdAt time"
},
{
Description: "label=version",
Require: nerdtest.IsFlaky("https://github.com/containerd/nerdctl/issues/3512"),
Command: test.Command("images", "--filter", "label=version"),
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
return &test.Expected{
Expand Down
5 changes: 5 additions & 0 deletions cmd/nerdctl/image/image_save_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package image
import (
"os"
"path/filepath"
"runtime"
"strings"
"testing"

Expand Down Expand Up @@ -70,6 +71,10 @@ func TestSave(t *testing.T) {
// See https://github.com/containerd/nerdctl/issues/3425 and others for details.
testCase.Require = nerdtest.Private

if runtime.GOOS == "windows" {
testCase.Require = nerdtest.IsFlaky("https://github.com/containerd/nerdctl/issues/3524")
}

testCase.SubTests = []*test.Case{
{
Description: "Single image, by id",
Expand Down
2 changes: 2 additions & 0 deletions cmd/nerdctl/ipfs/ipfs_compose_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func TestIPFSCompNoBuild(t *testing.T) {
test.Not(nerdtest.Docker),
nerdtest.Registry,
nerdtest.IPFS,
nerdtest.IsFlaky("https://github.com/containerd/nerdctl/issues/3510"),
// See note below
// nerdtest.Private,
)
Expand Down Expand Up @@ -153,6 +154,7 @@ services:
WORDPRESS_DB_USER: exampleuser
WORDPRESS_DB_PASSWORD: examplepass
WORDPRESS_DB_NAME: exampledb
# FIXME: this is flaky and will make the container fail on occasions
volumes:
- wordpress:/var/www/html

Expand Down
8 changes: 1 addition & 7 deletions cmd/nerdctl/network/network_create_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ func TestNetworkCreate(t *testing.T) {
testCase.SubTests = []*test.Case{
{
Description: "vanilla",
// #3491 and #3508 may have helped - commenting this out for now
// Require: nerdtest.IsFlaky("https://github.com/containerd/nerdctl/issues/3086"),
Setup: func(data test.Data, helpers test.Helpers) {
helpers.Ensure("network", "create", data.Identifier())
netw := nerdtest.InspectNetwork(helpers, data.Identifier())
Expand Down Expand Up @@ -66,8 +64,6 @@ func TestNetworkCreate(t *testing.T) {
},
{
Description: "with MTU",
// #3491 and #3508 may have helped - commenting this out for now
// Require: nerdtest.IsFlaky("https://github.com/containerd/nerdctl/issues/3086"),
Setup: func(data test.Data, helpers test.Helpers) {
helpers.Ensure("network", "create", data.Identifier(), "--driver", "bridge", "--opt", "com.docker.network.driver.mtu=9216")
},
Expand All @@ -81,9 +77,7 @@ func TestNetworkCreate(t *testing.T) {
},
{
Description: "with ipv6",
// #3491 and #3508 may have helped - commenting this out for now
// Require: nerdtest.IsFlaky("https://github.com/containerd/nerdctl/issues/3086"),
Require: nerdtest.OnlyIPv6,
Require: nerdtest.OnlyIPv6,
Setup: func(data test.Data, helpers test.Helpers) {
subnetStr := "2001:db8:8::/64"
data.Set("subnetStr", subnetStr)
Expand Down
3 changes: 0 additions & 3 deletions cmd/nerdctl/network/network_list_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ import (
func TestNetworkLsFilter(t *testing.T) {
testCase := nerdtest.Setup()

// #3491 and #3508 may have helped - commenting this out for now
// testCase.Require = nerdtest.IsFlaky("https://github.com/containerd/nerdctl/issues/3086"),

testCase.Setup = func(data test.Data, helpers test.Helpers) {
data.Set("identifier", data.Identifier())
data.Set("label", "mylabel=label-1")
Expand Down
3 changes: 0 additions & 3 deletions pkg/cmd/image/ensure.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ func ensureOne(ctx context.Context, client *containerd.Client, rawRef string, ta
if err != nil {
return err
}
// if platform == nil {
// platform = platforms.DefaultSpec()
//}
pltf := []ocispec.Platform{platform}
platformComparer := platformutil.NewMatchComparerFromOCISpecPlatformSlice(pltf)

Expand Down
17 changes: 0 additions & 17 deletions pkg/referenceutil/referenceutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ func TestReferenceUtil(t *testing.T) {
needles := map[string]struct {
Error string
String string
Normalized string
Suggested string
FamiliarName string
FamiliarMatch map[string]bool
Expand Down Expand Up @@ -82,7 +81,6 @@ func TestReferenceUtil(t *testing.T) {
"sha256:4b826db5f1f14d1db0b560304f189d4b17798ddce2278b7822c9d32313fe3f50": {
Error: "",
String: "sha256:4b826db5f1f14d1db0b560304f189d4b17798ddce2278b7822c9d32313fe3f50",
Normalized: "sha256:4b826db5f1f14d1db0b560304f189d4b17798ddce2278b7822c9d32313fe3f50",
Suggested: "untitled-abcde",
FamiliarName: "",
Protocol: "",
Expand All @@ -94,7 +92,6 @@ func TestReferenceUtil(t *testing.T) {
"4b826db5f1f14d1db0b560304f189d4b17798ddce2278b7822c9d32313fe3f50": {
Error: "",
String: "sha256:4b826db5f1f14d1db0b560304f189d4b17798ddce2278b7822c9d32313fe3f50",
Normalized: "sha256:4b826db5f1f14d1db0b560304f189d4b17798ddce2278b7822c9d32313fe3f50",
Suggested: "untitled-abcde",
FamiliarName: "",
Protocol: "",
Expand All @@ -106,7 +103,6 @@ func TestReferenceUtil(t *testing.T) {
"image_name": {
Error: "",
String: "docker.io/library/image_name:latest",
Normalized: "docker.io/library/image_name:latest",
Suggested: "image_name-abcde",
FamiliarName: "image_name",
Protocol: "",
Expand All @@ -119,7 +115,6 @@ func TestReferenceUtil(t *testing.T) {
"library/image_name": {
Error: "",
String: "docker.io/library/image_name:latest",
Normalized: "docker.io/library/image_name:latest",
Suggested: "image_name-abcde",
FamiliarName: "image_name",
Protocol: "",
Expand All @@ -132,7 +127,6 @@ func TestReferenceUtil(t *testing.T) {
"something/image_name": {
Error: "",
String: "docker.io/something/image_name:latest",
Normalized: "docker.io/something/image_name:latest",
Suggested: "image_name-abcde",
FamiliarName: "something/image_name",
Protocol: "",
Expand All @@ -145,7 +139,6 @@ func TestReferenceUtil(t *testing.T) {
"docker.io/library/image_name": {
Error: "",
String: "docker.io/library/image_name:latest",
Normalized: "docker.io/library/image_name:latest",
Suggested: "image_name-abcde",
FamiliarName: "image_name",
Protocol: "",
Expand All @@ -158,7 +151,6 @@ func TestReferenceUtil(t *testing.T) {
"image_name:latest": {
Error: "",
String: "docker.io/library/image_name:latest",
Normalized: "docker.io/library/image_name:latest",
Suggested: "image_name-abcde",
FamiliarName: "image_name",
Protocol: "",
Expand All @@ -171,7 +163,6 @@ func TestReferenceUtil(t *testing.T) {
"image_name:foo": {
Error: "",
String: "docker.io/library/image_name:foo",
Normalized: "docker.io/library/image_name:foo",
Suggested: "image_name-abcde",
FamiliarName: "image_name",
Protocol: "",
Expand All @@ -184,7 +175,6 @@ func TestReferenceUtil(t *testing.T) {
"image_name@sha256:4b826db5f1f14d1db0b560304f189d4b17798ddce2278b7822c9d32313fe3f50": {
Error: "",
String: "docker.io/library/image_name@sha256:4b826db5f1f14d1db0b560304f189d4b17798ddce2278b7822c9d32313fe3f50",
Normalized: "docker.io/library/image_name@sha256:4b826db5f1f14d1db0b560304f189d4b17798ddce2278b7822c9d32313fe3f50",
Suggested: "image_name-abcde",
FamiliarName: "image_name",
Protocol: "",
Expand All @@ -197,7 +187,6 @@ func TestReferenceUtil(t *testing.T) {
"image_name:latest@sha256:4b826db5f1f14d1db0b560304f189d4b17798ddce2278b7822c9d32313fe3f50": {
Error: "",
String: "docker.io/library/image_name:latest@sha256:4b826db5f1f14d1db0b560304f189d4b17798ddce2278b7822c9d32313fe3f50",
Normalized: "docker.io/library/image_name:latest@sha256:4b826db5f1f14d1db0b560304f189d4b17798ddce2278b7822c9d32313fe3f50",
Suggested: "image_name-abcde",
FamiliarName: "image_name",
Protocol: "",
Expand All @@ -210,7 +199,6 @@ func TestReferenceUtil(t *testing.T) {
"ghcr.io:1234/image_name": {
Error: "",
String: "ghcr.io:1234/image_name:latest",
Normalized: "ghcr.io:1234/image_name:latest",
Suggested: "image_name-abcde",
FamiliarName: "ghcr.io:1234/image_name",
Protocol: "",
Expand All @@ -223,7 +211,6 @@ func TestReferenceUtil(t *testing.T) {
"ghcr.io/sub_name/image_name": {
Error: "",
String: "ghcr.io/sub_name/image_name:latest",
Normalized: "ghcr.io/sub_name/image_name:latest",
Suggested: "image_name-abcde",
FamiliarName: "ghcr.io/sub_name/image_name",
Protocol: "",
Expand All @@ -236,7 +223,6 @@ func TestReferenceUtil(t *testing.T) {
"bafkreicq4dg6nkef5ju422ptedcwfz6kcvpvvhuqeykfrwq5krazf3muze": {
Error: "",
String: "bafkreicq4dg6nkef5ju422ptedcwfz6kcvpvvhuqeykfrwq5krazf3muze",
Normalized: "bafkreicq4dg6nkef5ju422ptedcwfz6kcvpvvhuqeykfrwq5krazf3muze",
Suggested: "ipfs-bafkr-abcde",
FamiliarName: "bafkreicq4dg6nkef5ju422ptedcwfz6kcvpvvhuqeykfrwq5krazf3muze",
Protocol: "ipfs",
Expand All @@ -249,7 +235,6 @@ func TestReferenceUtil(t *testing.T) {
"ipfs://bafkreicq4dg6nkef5ju422ptedcwfz6kcvpvvhuqeykfrwq5krazf3muze": {
Error: "",
String: "bafkreicq4dg6nkef5ju422ptedcwfz6kcvpvvhuqeykfrwq5krazf3muze",
Normalized: "bafkreicq4dg6nkef5ju422ptedcwfz6kcvpvvhuqeykfrwq5krazf3muze",
Suggested: "ipfs-bafkr-abcde",
FamiliarName: "bafkreicq4dg6nkef5ju422ptedcwfz6kcvpvvhuqeykfrwq5krazf3muze",
Protocol: "ipfs",
Expand All @@ -262,7 +247,6 @@ func TestReferenceUtil(t *testing.T) {
"ipfs://ghcr.io/stargz-containers/alpine:3.13-org": {
Error: "",
String: "ghcr.io/stargz-containers/alpine:3.13-org",
Normalized: "ghcr.io/stargz-containers/alpine:3.13-org",
Suggested: "alpine-abcde",
FamiliarName: "ghcr.io/stargz-containers/alpine",
FamiliarMatch: map[string]bool{
Expand All @@ -280,7 +264,6 @@ func TestReferenceUtil(t *testing.T) {
"ipfs://alpine": {
Error: "",
String: "docker.io/library/alpine:latest",
Normalized: "docker.io/library/alpine:latest",
Suggested: "alpine-abcde",
FamiliarName: "alpine",
Protocol: "ipfs",
Expand Down
9 changes: 2 additions & 7 deletions pkg/testutil/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,7 @@ func (b *Base) EnsureDaemonActive() {
sleep = 3 * time.Second
)
for i := 0; i < maxRetry; i++ {
cmd := exec.Command("systemctl",
append(systemctlArgs,
[]string{"is-active", target}...)...)
cmd := exec.Command("systemctl", append(systemctlArgs, "is-active", target)...)
out, err := cmd.CombinedOutput()
b.T.Logf("(retry=%d) %s", i, string(out))
if err == nil {
Expand All @@ -204,10 +202,7 @@ func (b *Base) DumpDaemonLogs(minutes int) {
b.T.Helper()
target := b.systemctlTarget()
cmd := exec.Command("journalctl",
append(b.systemctlArgs(),
[]string{"-u", target,
"--no-pager",
"-S", fmt.Sprintf("%d min ago", minutes)}...)...)
append(b.systemctlArgs(), "-u", target, "--no-pager", "-S", fmt.Sprintf("%d min ago", minutes))...)
b.T.Logf("===== %v =====", cmd.Args)
out, err := cmd.CombinedOutput()
if err != nil {
Expand Down