diff --git a/test/e2e/features/story_openshift.feature b/test/e2e/features/story_openshift.feature index beb4c4c8a6..b9e1495b48 100644 --- a/test/e2e/features/story_openshift.feature +++ b/test/e2e/features/story_openshift.feature @@ -2,7 +2,7 @@ Feature: 4 Openshift stories Background: - Given ensuring CRC cluster is running succeeds + Given ensuring CRC cluster is running And ensuring user is logged in succeeds # End-to-end health check diff --git a/test/e2e/testsuite/testsuite.go b/test/e2e/testsuite/testsuite.go index b11ce21ebf..0aa6f62a82 100644 --- a/test/e2e/testsuite/testsuite.go +++ b/test/e2e/testsuite/testsuite.go @@ -495,8 +495,8 @@ func InitializeScenario(s *godog.ScenarioContext) { ExecuteSingleCommandWithExpectedExitStatus) s.Step(`^execut(?:e|ing) podman command (.*) (succeeds|fails)$`, ExecutingPodmanCommandSucceedsFails) - s.Step(`^ensuring CRC cluster is running (succeeds|fails)$`, - EnsureCRCIsRunningSucceedsOrFails) + s.Step(`^ensuring CRC cluster is running$`, + EnsureCRCIsRunning) s.Step(`^ensuring user is logged in (succeeds|fails)`, EnsureUserIsLoggedIntoClusterSucceedsOrFails) s.Step(`^podman command is available$`, @@ -800,58 +800,49 @@ func StartCRCWithDefaultBundleAndNameServerSucceedsOrFails(nameserver string, ex cmd := fmt.Sprintf("%s -n %s -p '%s' %s", crcStart, nameserver, pullSecretFile, extraBundleArgs) return util.ExecuteCommandSucceedsOrFails(cmd, expected) } -func EnsureCRCIsRunningSucceedsOrFails(expected string) error { - err := crcCmd.WaitForClusterInState("running") +func EnsureCRCIsRunning() error { - // (1) If cluster is NOT expected to be Running and it is NOT running - if expected == "fails" && err != nil { - return nil - } + err := crcCmd.CheckCRCStatus("running") - // (2) If cluster is NOT expected to be Running but it IS running, stop it - if expected == "fails" && err == nil { - miniErr := util.ExecuteCommandSucceedsOrFails("crc stop", "succeeds") - if miniErr != nil { + // if cluster is not in a Running state + if err != nil { + // make sure cluster doesn't exist in unexpected state + err = ExecuteCRCCommand("cleanup") + if err != nil { return err } - return nil - } - // (3) If cluster IS expected to be Running and it IS - if expected == "succeeds" && err == nil { - return nil - } - - // (4) If cluster IS expected to be Running but is NOT, start it with 12000 memory - err = SetConfigPropertyToValueSucceedsOrFails("memory", "12000", expected) - if err != nil { - return err - } + // set up and start the cluster with lots of memory + err = SetConfigPropertyToValueSucceedsOrFails("memory", "12000", "succeeds") + if err != nil { + return err + } - err = ExecuteSingleCommandWithExpectedExitStatus("setup", expected) // uses the right bundle argument if needed - if err != nil { - return err - } + err = ExecuteSingleCommandWithExpectedExitStatus("setup", "succeeds") // uses the right bundle argument if needed + if err != nil { + return err + } - if runtime.GOOS == "windows" { - err = StartCRCWithDefaultBundleAndNameServerSucceedsOrFails("10.75.5.25", expected) - } else { - err = StartCRCWithDefaultBundleSucceedsOrFails(expected) - } - if err != nil { - return err - } + if runtime.GOOS == "windows" { + err = StartCRCWithDefaultBundleAndNameServerSucceedsOrFails("10.75.5.25", "succeeds") + } else { + err = StartCRCWithDefaultBundleSucceedsOrFails("succeeds") + } + if err != nil { + return err + } - // We're not testing if the cluster comes up fast enough, just need it Running - err = crcCmd.WaitForClusterInState("running") - if err != nil { + // We're not testing if the cluster comes up fast enough, just need it Running err = crcCmd.WaitForClusterInState("running") if err != nil { - return err + err = crcCmd.WaitForClusterInState("running") + if err != nil { + return err + } } - } + } return nil }