diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 99607f191b1..b6872c24f78 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -287,7 +287,7 @@ 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: ./hack/test-integration.sh -test.target=docker -test.only-flaky test-integration-windows: timeout-minutes: 30 diff --git a/hack/test-integration.sh b/hack/test-integration.sh index 77f2a791147..220a28f5789 100755 --- a/hack/test-integration.sh +++ b/hack/test-integration.sh @@ -28,8 +28,6 @@ args=(--format=testname --jsonfile /tmp/test-integration.log --packages="$root"/ if [ "$#" == 0 ]; then "$root"/test-integration.sh -test.only-flaky=false "$root"/test-integration.sh -test.only-flaky=true - "$root"/test-integration.sh -test.only-ipv6 - "$root"/test-integration.sh -test.only-kube exit fi diff --git a/pkg/testutil/nerdtest/registry/cesanta.go b/pkg/testutil/nerdtest/registry/cesanta.go index b8924e8c369..595b91ce537 100644 --- a/pkg/testutil/nerdtest/registry/cesanta.go +++ b/pkg/testutil/nerdtest/registry/cesanta.go @@ -82,34 +82,38 @@ func (cc *CesantaConfig) Save(path string) error { return err } +// FIXME: this is a copy of the utility method EnsureContainerStarted +// We cannot reference it (circular dep), so the copy. +// To be fixed later when we will be done migrating test helpers to the new framework and we can split them +// in meaningful subpackages. + func ensureContainerStarted(helpers test.Helpers, con string) { - const maxRetry = 5 - const sleep = time.Second - success := false - for i := 0; i < maxRetry && !success; i++ { - time.Sleep(sleep) - count := i - cmd := helpers.Command("container", "inspect", con) - cmd.Run(&test.Expected{ - Output: func(stdout string, info string, t *testing.T) { - var dc []dockercompat.Container - err := json.Unmarshal([]byte(stdout), &dc) - assert.NilError(t, err, "Unable to unmarshal output\n"+info) - assert.Equal(t, 1, len(dc), "Unexpectedly got multiple results\n"+info) - if dc[0].State.Running { - success = true - return - } - if count == maxRetry-1 { - // FIXME: there is currently no simple way to capture stderr - // Sometimes, it is convenient for debugging, like here - // Here we cheat with unbuffer which will bundle stderr and stdout together - // This is just bad - t.Error(helpers.Err("logs", con)) - t.Fatalf("container %s still not running after %d retries", con, count) - } - }, - }) + started := false + for i := 0; i < 5 && !started; i++ { + helpers.Command("container", "inspect", con). + Run(&test.Expected{ + ExitCode: -2, + Output: func(stdout string, info string, t *testing.T) { + var dc []dockercompat.Container + err := json.Unmarshal([]byte(stdout), &dc) + if err != nil || len(dc) == 0 { + return + } + assert.Equal(t, len(dc), 1, "Unexpectedly got multiple results\n"+info) + started = dc[0].State.Running + }, + }) + time.Sleep(time.Second) + } + + if !started { + ins := helpers.Capture("container", "inspect", con) + lgs := helpers.Capture("logs", con) + ps := helpers.Capture("ps", "-a") + helpers.T().Log(ins) + helpers.T().Log(lgs) + helpers.T().Log(ps) + helpers.T().Fatalf("container %s still not running after %d retries", con, 5) } } diff --git a/pkg/testutil/nerdtest/utilities.go b/pkg/testutil/nerdtest/utilities.go index 9dc13c3f1e2..f4ed4f2d566 100644 --- a/pkg/testutil/nerdtest/utilities.go +++ b/pkg/testutil/nerdtest/utilities.go @@ -111,17 +111,10 @@ func EnsureContainerStarted(helpers test.Helpers, con string) { } if !started { - var dckr string - helpers.Custom("sudo", "journalctl", "-u", "docker", "--no-pager").Run(&test.Expected{ - Output: func(stdout string, info string, t *testing.T) { - dckr = stdout - }, - }) ins := helpers.Capture("container", "inspect", con) lgs := helpers.Capture("logs", con) ps := helpers.Capture("ps", "-a") helpers.T().Log(ins) - helpers.T().Log(dckr) helpers.T().Log(lgs) helpers.T().Log(ps) helpers.T().Fatalf("container %s still not running after %d retries", con, maxRetry)