From ab11cef58ac4c15b0fc58c3d8c56ed01ef7f9d36 Mon Sep 17 00:00:00 2001 From: apostasie Date: Tue, 8 Oct 2024 17:19:59 -0700 Subject: [PATCH] Tests adjustments Signed-off-by: apostasie --- .../ghcr-image-build-and-publish.yml | 5 +- .github/workflows/lint.yml | 82 ++++++++++++++ .github/workflows/test-canary.yml | 31 ++--- .github/workflows/test-kube.yml | 5 +- .github/workflows/test.yml | 106 +++++------------- .../container_run_restart_linux_test.go | 1 + cmd/nerdctl/image/image_history_test.go | 9 +- cmd/nerdctl/image/image_list_test.go | 2 +- cmd/nerdctl/image/image_push_linux_test.go | 5 +- cmd/nerdctl/issues/issues_linux_test.go | 25 +++-- hack/build-integration-kubernetes.sh | 4 +- hack/test-integration.sh | 6 +- pkg/testutil/testutil.go | 9 +- 13 files changed, 155 insertions(+), 135 deletions(-) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/ghcr-image-build-and-publish.yml b/.github/workflows/ghcr-image-build-and-publish.yml index ebb35de53cb..1337a47c007 100644 --- a/.github/workflows/ghcr-image-build-and-publish.yml +++ b/.github/workflows/ghcr-image-build-and-publish.yml @@ -1,4 +1,4 @@ -name: Container Image Build +name: image # This workflow uses actions that are not certified by GitHub. # They are provided by a third-party and are governed by @@ -21,9 +21,8 @@ env: # github.repository as / IMAGE_NAME: ${{ github.repository }} - jobs: - build: + publish: runs-on: ubuntu-24.04 permissions: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000000..2b2cdadfc76 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,82 @@ +name: lint + +on: + push: + branches: + - main + - 'release/**' + pull_request: + +env: + GO_VERSION: 1.23.x + +jobs: + go: + timeout-minutes: 5 + name: "go | ${{ matrix.goos }} | ${{ matrix.gonext }}" + runs-on: "${{ matrix.os }}" + strategy: + matrix: + include: + - os: ubuntu-24.04 + goos: linux + - os: ubuntu-24.04 + goos: freebsd + # FIXME: this is currently failing in a non-sensical way, so, running on linux instead... + # - os: windows-2022 + - os: ubuntu-24.04 + goos: windows + - os: ubuntu-24.04 + goos: linux + # This allows the canary script to select any upcoming golang alpha/beta/RC + gonext: next + - os: ubuntu-24.04 + goos: freebsd + gonext: next + - os: ubuntu-24.04 + goos: windows + gonext: next + env: + GOOS: "${{ matrix.goos }}" + steps: + - uses: actions/checkout@v4.2.1 + with: + fetch-depth: 1 + - name: Set GO env + run: | + # If gonext is specified, get the latest available golang pre-release instead of the major version + if [ "$gonext" != "" ]; then + . ./hack/build-integration-canary.sh + canary::golang::latest + fi + - uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + check-latest: true + cache: true + - name: golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + args: --verbose + + other: + timeout-minutes: 5 + name: yaml, shell, import order + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4.2.1 + with: + fetch-depth: 1 + - uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + check-latest: true + cache: true + - name: yaml + run: make lint-yaml + - name: shell + run: make lint-shell + - name: go imports ordering + run: | + go install -v github.com/incu6us/goimports-reviser/v3@latest + make lint-imports diff --git a/.github/workflows/test-canary.yml b/.github/workflows/test-canary.yml index cee60a360b9..12dc4abe045 100644 --- a/.github/workflows/test-canary.yml +++ b/.github/workflows/test-canary.yml @@ -15,27 +15,6 @@ env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: - lint: - runs-on: "ubuntu-24.04" - timeout-minutes: 20 - steps: - - uses: actions/checkout@v4.2.1 - with: - fetch-depth: 1 - - name: Set GO env - run: | - . ./hack/build-integration-canary.sh - canary::golang::latest - - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - check-latest: true - cache: true - - name: golangci-lint - uses: golangci/golangci-lint-action@v6.1.1 - with: - args: --verbose - linux: runs-on: "ubuntu-24.04" timeout-minutes: 40 @@ -66,10 +45,12 @@ jobs: run: go test -v ./pkg/... - name: "Run integration tests" run: docker run -t --rm --privileged test-integration ./hack/test-integration.sh + - name: "Run integration tests (flaky)" + run: docker run -t --rm --privileged test-integration ./hack/test-integration.sh -test.only-flaky windows: - runs-on: windows-latest timeout-minutes: 30 + runs-on: windows-latest defaults: run: shell: bash @@ -95,6 +76,7 @@ jobs: cache: true check-latest: true - run: go install ./cmd/nerdctl + - run: go install -v gotest.tools/gotestsum@v1 # This here is solely to get the cni install script, which has not been modified in 3+ years. # There is little to no reason to update this to latest containerd - uses: actions/checkout@v4.2.1 @@ -112,5 +94,6 @@ jobs: ctrdVersion: ${{ env.CONTAINERD_VERSION }} run: powershell hack/configure-windows-ci.ps1 - name: "Run integration tests" - # See https://github.com/containerd/nerdctl/blob/main/docs/testing/README.md#about-parallelization - run: go test -p 1 -v ./cmd/nerdctl/... + run: ./hack/test-integration.sh + - name: "Run integration tests (flaky)" + run: ./hack/test-integration.sh -test.only-flaky diff --git a/.github/workflows/test-kube.yml b/.github/workflows/test-kube.yml index c8e2ccda405..3c6faaaa457 100644 --- a/.github/workflows/test-kube.yml +++ b/.github/workflows/test-kube.yml @@ -10,13 +10,12 @@ on: paths-ignore: - '**.md' -env: - ROOTFUL: true - jobs: linux: runs-on: "ubuntu-24.04" timeout-minutes: 40 + env: + ROOTFUL: true steps: - uses: actions/checkout@v4.2.1 with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2f3b9331278..26a6e42b37e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,62 +15,10 @@ env: LONG_TIMEOUT: 60 jobs: - lint-go: + test-unit: # Supposed to work: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/evaluate-expressions-in-workflows-and-actions#example-returning-a-json-data-type # Apparently does not # timeout-minutes: ${{ fromJSON(env.SHORT_TIMEOUT) }} - timeout-minutes: 5 - name: lint-go ${{ matrix.goos }} - runs-on: "${{ matrix.os }}" - strategy: - matrix: - include: - - os: ubuntu-24.04 - goos: linux - - os: ubuntu-24.04 - goos: freebsd - # FIXME: this is currently failing in a non-sensical way, so, running on linux instead... - # - os: windows-2022 - - os: ubuntu-24.04 - goos: windows - env: - GOOS: "${{ matrix.goos }}" - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 1 - - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - check-latest: true - cache: true - - name: golangci-lint - uses: golangci/golangci-lint-action@v6 - with: - args: --verbose - - lint-other: - timeout-minutes: 5 - runs-on: ubuntu-24.04 - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 1 - - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - check-latest: true - cache: true - - name: yaml - run: make lint-yaml - - name: shell - run: make lint-shell - - name: go imports ordering - run: | - go install -v github.com/incu6us/goimports-reviser/v3@latest - make lint-imports - - test-unit: timeout-minutes: 5 name: unit ${{ matrix.goos }} runs-on: "${{ matrix.os }}" @@ -83,7 +31,7 @@ jobs: - os: ubuntu-24.04 goos: linux steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4.2.1 with: fetch-depth: 1 - uses: actions/setup-go@v5 @@ -96,7 +44,7 @@ jobs: test-integration: timeout-minutes: 60 - name: integration ${{ matrix.containerd }} ${{ matrix.runner }} + name: rootful | ${{ matrix.containerd }} | ${{ matrix.runner }} runs-on: "${{ matrix.runner }}" strategy: fail-fast: false @@ -119,7 +67,7 @@ jobs: UBUNTU_VERSION: "${{ matrix.ubuntu }}" CONTAINERD_VERSION: "${{ matrix.containerd }}" steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4.2.1 with: fetch-depth: 1 - name: "Prepare integration test environment" @@ -148,7 +96,7 @@ jobs: test-integration-ipv6: timeout-minutes: 60 - name: ipv6 ${{ matrix.containerd }} ${{ matrix.ubuntu }} + name: ipv6 | ${{ matrix.containerd }} | ${{ matrix.ubuntu }} runs-on: "ubuntu-${{ matrix.ubuntu }}" strategy: fail-fast: false @@ -157,11 +105,13 @@ jobs: include: - ubuntu: 24.04 containerd: v1.7.22 + - ubuntu: 24.04 + containerd: v2.0.0-rc.5 env: UBUNTU_VERSION: "${{ matrix.ubuntu }}" CONTAINERD_VERSION: "${{ matrix.containerd }}" steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4.2.1 with: fetch-depth: 1 - name: Enable ipv4 and ipv6 forwarding @@ -200,7 +150,7 @@ jobs: test-integration-rootless: timeout-minutes: 60 - name: rootless ${{ matrix.containerd }} ${{ matrix.rootlesskit }} ${{ matrix.ubuntu }} ${{ matrix.target }} + name: "${{ matrix.target }} | ${{ matrix.containerd }} | ${{ matrix.rootlesskit }} | ${{ matrix.ubuntu }}" runs-on: "ubuntu-${{ matrix.ubuntu }}" strategy: fail-fast: false @@ -210,24 +160,24 @@ jobs: - ubuntu: 20.04 containerd: v1.6.36 rootlesskit: v1.1.1 # Deprecated - target: test-integration-rootless + target: rootless - ubuntu: 22.04 containerd: v1.7.22 rootlesskit: v2.3.1 - target: test-integration-rootless + target: rootless - ubuntu: 24.04 containerd: v2.0.0-rc.5 rootlesskit: v2.3.1 - target: test-integration-rootless + target: rootless - ubuntu: 24.04 containerd: v1.7.22 rootlesskit: v2.3.1 - target: test-integration-rootless-port-slirp4netns + target: rootless-port-slirp4netns env: UBUNTU_VERSION: "${{ matrix.ubuntu }}" CONTAINERD_VERSION: "${{ matrix.containerd }}" ROOTLESSKIT_VERSION: "${{ matrix.rootlesskit }}" - TEST_TARGET: "${{ matrix.target }}" + TEST_TARGET: "test-integration-${{ matrix.target }}" steps: - name: "Set up AppArmor" if: matrix.ubuntu == '24.04' @@ -244,7 +194,7 @@ jobs: } EOT sudo systemctl restart apparmor.service - - uses: actions/checkout@v4 + - uses: actions/checkout@v4.2.1 with: fetch-depth: 1 - name: "Register QEMU (tonistiigi/binfmt)" @@ -271,14 +221,14 @@ jobs: - name: "Test (network driver=slirp4netns, port driver=builtin) (flaky)" run: docker run -t --rm --privileged -e WORKAROUND_ISSUE_622=${WORKAROUND_ISSUE_622} ${TEST_TARGET} /test-integration-rootless.sh ./hack/test-integration.sh -test.only-flaky - cross: + build: timeout-minutes: 5 runs-on: ubuntu-24.04 strategy: matrix: go-version: ["1.22.x", "1.23.x"] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4.2.1 with: fetch-depth: 1 - uses: actions/setup-go@v5 @@ -286,14 +236,15 @@ jobs: go-version: ${{ matrix.go-version }} cache: true check-latest: true - - name: "Cross" + - name: "build" run: GO_VERSION="$(echo ${{ matrix.go-version }} | sed -e s/.x//)" make binaries test-integration-docker-compatibility: timeout-minutes: 60 + name: docker runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4.2.1 with: fetch-depth: 1 - uses: actions/setup-go@v5 @@ -324,16 +275,17 @@ jobs: - name: "Ensure that the IPv6 integration test suite is compatible with Docker" run: ./hack/test-integration.sh -test.target=docker -test.only-ipv6 - name: "Ensure that the integration test suite is compatible with Docker (flaky only)" - run: ./hack/test-integration.sh -test.target=docker -test.only-flaky + run: go test -p 1 -timeout 20m -v -exec sudo ./cmd/nerdctl/... -args -test.target=docker -test.allow-kill-daemon -test.only-flaky test-integration-windows: - timeout-minutes: 60 + timeout-minutes: 30 + name: windows runs-on: windows-2022 defaults: run: shell: bash steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4.2.1 with: fetch-depth: 1 - uses: actions/setup-go@v5 @@ -343,7 +295,7 @@ jobs: check-latest: true - run: go install ./cmd/nerdctl - run: go install -v gotest.tools/gotestsum@v1 - - uses: actions/checkout@v4 + - uses: actions/checkout@v4.2.1 with: repository: containerd/containerd ref: v1.7.22 @@ -357,11 +309,9 @@ jobs: ctrdVersion: 1.7.22 run: powershell hack/configure-windows-ci.ps1 - name: "Run integration tests" - run: | - ./hack/test-integration.sh + run: ./hack/test-integration.sh - name: "Run integration tests (flaky)" - run: | - ./hack/test-integration.sh -test.only-flaky + run: ./hack/test-integration.sh -test.only-flaky test-integration-freebsd: timeout-minutes: 60 @@ -370,7 +320,7 @@ jobs: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4.2.1 - uses: actions/cache@v4 with: path: /root/.vagrant.d diff --git a/cmd/nerdctl/container/container_run_restart_linux_test.go b/cmd/nerdctl/container/container_run_restart_linux_test.go index c3411c6aaeb..3d531f61c50 100644 --- a/cmd/nerdctl/container/container_run_restart_linux_test.go +++ b/cmd/nerdctl/container/container_run_restart_linux_test.go @@ -70,6 +70,7 @@ func TestRunRestart(t *testing.T) { } assert.NilError(t, check(30)) + base.EnsureDaemonActive() base.KillDaemon() base.EnsureDaemonActive() diff --git a/cmd/nerdctl/image/image_history_test.go b/cmd/nerdctl/image/image_history_test.go index 5086b3edb9f..f3f8ceec1b9 100644 --- a/cmd/nerdctl/image/image_history_test.go +++ b/cmd/nerdctl/image/image_history_test.go @@ -76,11 +76,16 @@ func TestImageHistory(t *testing.T) { test.Not(test.Windows), // XXX Currently, history does not work on non-native platform, so, we cannot test reliably on other platforms test.Arm64, - // XXX this here is very likely breaking other tests because of one of the variants of - // https://github.com/containerd/nerdctl/issues/3513 so, making it private to try avoid that + // Because of issues with multi-platform code, temp-reduced-image, this platform specific image here will + // introduce flaky behavior to other tests. + // There is likely complex issues at play, around https://github.com/containerd/nerdctl/issues/3513 nerdtest.Private, ), Setup: func(data test.Data, helpers test.Helpers) { + // XXX: despite efforts to isolate this test, it keeps on having side effects linked to + // https://github.com/containerd/nerdctl/issues/3512 + // Isolating it into a completely different root is the last ditched attempt at avoiding the issue + helpers.Write(nerdtest.DataRoot, test.ConfigValue(data.TempDir())) helpers.Ensure("pull", "--platform", "linux/arm64", testutil.CommonImage) }, SubTests: []*test.Case{ diff --git a/cmd/nerdctl/image/image_list_test.go b/cmd/nerdctl/image/image_list_test.go index b769c4a7810..71e754484bf 100644 --- a/cmd/nerdctl/image/image_list_test.go +++ b/cmd/nerdctl/image/image_list_test.go @@ -127,7 +127,6 @@ func TestImagesFilter(t *testing.T) { Description: "TestImagesFilter", Require: test.Require( nerdtest.Build, - nerdtest.IsFlaky("https://github.com/containerd/nerdctl/issues/3512"), ), Setup: func(data test.Data, helpers test.Helpers) { helpers.Ensure("pull", testutil.CommonImage) @@ -192,6 +191,7 @@ 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{ diff --git a/cmd/nerdctl/image/image_push_linux_test.go b/cmd/nerdctl/image/image_push_linux_test.go index 75c2e75bf60..9d3ae4d8598 100644 --- a/cmd/nerdctl/image/image_push_linux_test.go +++ b/cmd/nerdctl/image/image_push_linux_test.go @@ -51,8 +51,11 @@ func TestPush(t *testing.T) { Cleanup: func(data test.Data, helpers test.Helpers) { if registryNoAuthHTTPRandom != nil { registryNoAuthHTTPRandom.Cleanup(nil) - // XXX might crash + } + if registryNoAuthHTTPDefault != nil { registryNoAuthHTTPDefault.Cleanup(nil) + } + if registryTokenAuthHTTPSRandom != nil { registryTokenAuthHTTPSRandom.Cleanup(nil) } }, diff --git a/cmd/nerdctl/issues/issues_linux_test.go b/cmd/nerdctl/issues/issues_linux_test.go index 0a59126fc13..a371aaa6c0f 100644 --- a/cmd/nerdctl/issues/issues_linux_test.go +++ b/cmd/nerdctl/issues/issues_linux_test.go @@ -24,23 +24,24 @@ import ( "github.com/containerd/nerdctl/v2/pkg/testutil" "github.com/containerd/nerdctl/v2/pkg/testutil/nerdtest" + "github.com/containerd/nerdctl/v2/pkg/testutil/nerdtest/registry" "github.com/containerd/nerdctl/v2/pkg/testutil/test" - "github.com/containerd/nerdctl/v2/pkg/testutil/testregistry" ) func TestIssue3425(t *testing.T) { nerdtest.Setup() - var registry *testregistry.RegistryServer + var reg *registry.Server testCase := &test.Case{ + Require: nerdtest.Registry, Setup: func(data test.Data, helpers test.Helpers) { - base := testutil.NewBase(t) - registry = testregistry.NewWithNoAuth(base, 0, false) + reg = nerdtest.RegistryWithNoAuth(data, helpers, 0, false) + reg.Setup(data, helpers) }, Cleanup: func(data test.Data, helpers test.Helpers) { - if registry != nil { - registry.Cleanup(nil) + if reg != nil { + reg.Cleanup(data, helpers) } }, SubTests: []*test.Case{ @@ -52,14 +53,14 @@ func TestIssue3425(t *testing.T) { helpers.Ensure("run", "-d", "--name", data.Identifier(), testutil.CommonImage) helpers.Ensure("image", "rm", "-f", testutil.CommonImage) helpers.Ensure("image", "pull", testutil.CommonImage) - helpers.Ensure("tag", testutil.CommonImage, fmt.Sprintf("localhost:%d/%s", registry.Port, data.Identifier())) + helpers.Ensure("tag", testutil.CommonImage, fmt.Sprintf("localhost:%d/%s", reg.Port, data.Identifier())) }, Cleanup: func(data test.Data, helpers test.Helpers) { helpers.Anyhow("rm", "-f", data.Identifier()) - helpers.Anyhow("rmi", "-f", fmt.Sprintf("localhost:%d/%s", registry.Port, data.Identifier())) + helpers.Anyhow("rmi", "-f", fmt.Sprintf("localhost:%d/%s", reg.Port, data.Identifier())) }, Command: func(data test.Data, helpers test.Helpers) test.TestableCommand { - return helpers.Command("push", fmt.Sprintf("localhost:%d/%s", registry.Port, data.Identifier())) + return helpers.Command("push", fmt.Sprintf("localhost:%d/%s", reg.Port, data.Identifier())) }, Expected: test.Expects(0, nil, nil), }, @@ -71,14 +72,14 @@ func TestIssue3425(t *testing.T) { helpers.Ensure("run", "-d", "--name", data.Identifier(), testutil.CommonImage, "touch", "/something") helpers.Ensure("image", "rm", "-f", testutil.CommonImage) helpers.Ensure("image", "pull", testutil.CommonImage) - helpers.Ensure("commit", data.Identifier(), fmt.Sprintf("localhost:%d/%s", registry.Port, data.Identifier())) + helpers.Ensure("commit", data.Identifier(), fmt.Sprintf("localhost:%d/%s", reg.Port, data.Identifier())) }, Cleanup: func(data test.Data, helpers test.Helpers) { helpers.Anyhow("rm", "-f", data.Identifier()) - helpers.Anyhow("rmi", "-f", fmt.Sprintf("localhost:%d/%s", registry.Port, data.Identifier())) + helpers.Anyhow("rmi", "-f", fmt.Sprintf("localhost:%d/%s", reg.Port, data.Identifier())) }, Command: func(data test.Data, helpers test.Helpers) test.TestableCommand { - return helpers.Command("push", fmt.Sprintf("localhost:%d/%s", registry.Port, data.Identifier())) + return helpers.Command("push", fmt.Sprintf("localhost:%d/%s", reg.Port, data.Identifier())) }, Expected: test.Expects(0, nil, nil), }, diff --git a/hack/build-integration-kubernetes.sh b/hack/build-integration-kubernetes.sh index e41f13fcf7f..7fcea04c5cb 100755 --- a/hack/build-integration-kubernetes.sh +++ b/hack/build-integration-kubernetes.sh @@ -104,8 +104,10 @@ main(){ # Hack to get go into kind control plane exec::nerdctl rm -f go-kind 2>/dev/null || true - exec::nerdctl run -d --name go-kind golang:"$GO_VERSION" sleep Inf + exec::nerdctl pull --quiet golang:"$GO_VERSION" + exec::nerdctl run -d --pull never --name go-kind golang:"$GO_VERSION" sleep Inf exec::nerdctl cp go-kind:/usr/local/go /tmp/go + exec::nerdctl rm -f go-kind # Create fresh cluster log::info "Creating new cluster" diff --git a/hack/test-integration.sh b/hack/test-integration.sh index cc319f22f59..74f8b81f448 100755 --- a/hack/test-integration.sh +++ b/hack/test-integration.sh @@ -21,7 +21,7 @@ readonly root readonly timeout="60m" # See https://github.com/containerd/nerdctl/blob/main/docs/testing/README.md#about-parallelization -args=(--format=testname --jsonfile /tmp/test-integration.log --packages="$root"/cmd/nerdctl/...) +args=(--format=testname --jsonfile /tmp/test-integration.log --packages="$root"/../cmd/nerdctl/...) for arg in "$@"; do if [ "$arg" == "-test.only-flaky" ]; then @@ -32,5 +32,5 @@ done gotestsum "${args[@]}" -- -timeout="$timeout" -p 1 -args -test.allow-kill-daemon "$@" -echo "These are the tests that took more than 10 seconds:" -gotestsum tool slowest --threshold 10s --jsonfile /tmp/test-integration.log +echo "These are the tests that took more than 20 seconds:" +gotestsum tool slowest --threshold 20s --jsonfile /tmp/test-integration.log diff --git a/pkg/testutil/testutil.go b/pkg/testutil/testutil.go index 46f4459934b..9affc0b398a 100644 --- a/pkg/testutil/testutil.go +++ b/pkg/testutil/testutil.go @@ -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 { @@ -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 {