Skip to content

Commit

Permalink
e2e: wait for cluster in running state for openshift stories
Browse files Browse the repository at this point in the history
  • Loading branch information
jsliacan authored and adrianriobo committed Feb 1, 2023
1 parent bb030d1 commit 0f38e69
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions test/e2e/testsuite/testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -646,12 +646,28 @@ func StartCRCWithDefaultBundleAndNameServerSucceedsOrFails(nameserver string, ex
}
func EnsureCRCIsRunningSucceedsOrFails(expected string) error {

err := crcCmd.CheckCRCStatus("running")
if err == nil {
return err // exit if cluster running already
err := crcCmd.WaitForClusterInState("running")

// (1) If cluster is NOT expected to be Running and it is NOT running
if expected == "fails" && err != nil {
return nil
}

// (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 {
return err
}
return nil
}

// if cluster NOT running, start it with 12000 memory
// (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
Expand All @@ -667,8 +683,20 @@ func EnsureCRCIsRunningSucceedsOrFails(expected string) error {
} else {
err = StartCRCWithDefaultBundleSucceedsOrFails(expected)
}
if err != nil {
return err
}

return err
// We're not testing if the cluster comes up fast enough, just need it Running
err = crcCmd.WaitForClusterInState("running")
if err != nil {
err = crcCmd.WaitForClusterInState("running")
if err != nil {
return err
}
}

return nil
}

func EnsureUserIsLoggedIntoClusterSucceedsOrFails(expected string) error {
Expand Down

0 comments on commit 0f38e69

Please sign in to comment.