diff --git a/src/test/external/common.go b/src/test/external/common.go index 0209ddadb2..5fd2e294f2 100644 --- a/src/test/external/common.go +++ b/src/test/external/common.go @@ -5,6 +5,7 @@ package external import ( + "errors" "path" "path/filepath" "strings" @@ -31,7 +32,7 @@ func createPodInfoPackageWithInsecureSources(t *testing.T, temp string) { exec.CmdWithPrint(zarfBinPath, "package", "create", temp, "--confirm", "--output", temp) } -func verifyWaitSuccess(t *testing.T, timeoutMinutes time.Duration, cmd string, args []string, condition string, onTimeout string) bool { +func waitForCondition(t *testing.T, timeoutMinutes time.Duration, cmd string, args []string, condition string) error { timeout := time.After(timeoutMinutes * time.Minute) for { // delay check 3 seconds @@ -39,9 +40,7 @@ func verifyWaitSuccess(t *testing.T, timeoutMinutes time.Duration, cmd string, a select { // on timeout abort case <-timeout: - t.Error(onTimeout) - - return false + return errors.New("timed out waiting for condition") // after delay, try running default: @@ -52,7 +51,7 @@ func verifyWaitSuccess(t *testing.T, timeoutMinutes time.Duration, cmd string, a t.Log(string(stdOut), err) } if strings.Contains(string(stdOut), condition) { - return true + return nil } } } diff --git a/src/test/external/docker-compose.yml b/src/test/external/docker-compose.yml index 7e180fdbab..fcca987da7 100644 --- a/src/test/external/docker-compose.yml +++ b/src/test/external/docker-compose.yml @@ -21,6 +21,11 @@ services: ports: - "3000:3000" - "222:22" + healthcheck: + test: ["CMD", "curl", "-f", "http://gitea.localhost:3000/api/healthz"] + interval: 5s + timeout: 5s + retries: 20 init: image: gitea/gitea:1.18.1 container_name: gitea.init diff --git a/src/test/external/ext_out_cluster_test.go b/src/test/external/ext_out_cluster_test.go index e2cbaccefb..1eee15e718 100644 --- a/src/test/external/ext_out_cluster_test.go +++ b/src/test/external/ext_out_cluster_test.go @@ -81,10 +81,9 @@ func (suite *ExtOutClusterTestSuite) SetupSuite() { suite.NoError(err, "unable to install the gitea-server") // Wait for gitea to deploy properly - giteaArgs := []string{"inspect", "-f", "{{.State.Status}}", "gitea.init"} - giteaErrStr := "unable to verify the gitea container installed successfully" - success := verifyWaitSuccess(suite.T(), 2, "docker", giteaArgs, "exited", giteaErrStr) - suite.True(success, giteaErrStr) + giteaArgs := []string{"inspect", "-f", "{{.State.Health.Status}}", "gitea.localhost"} + err = waitForCondition(suite.T(), 2, "docker", giteaArgs, "healthy") + suite.NoError(err) // Connect gitea to the k3d network err = exec.CmdWithPrint("docker", "network", "connect", "--ip", giteaIP, network, giteaHost)