Skip to content

Commit

Permalink
e2e: Eliminate 10min unnecessary wait for status
Browse files Browse the repository at this point in the history
Check for status directly, no need to wait for stability. Also, make
the Ensure... function asymetric because checking for a "non-running"
cluster is almost never useful: states like Unreachable are rarely
going to be desired states anyways.
  • Loading branch information
jsliacan authored and anjannath committed Jul 10, 2023
1 parent 0ab0245 commit 711d60f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 42 deletions.
2 changes: 1 addition & 1 deletion test/e2e/features/story_openshift.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
73 changes: 32 additions & 41 deletions test/e2e/testsuite/testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -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$`,
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 711d60f

Please sign in to comment.