Skip to content

Commit

Permalink
e2e: Make status check preset-independent
Browse files Browse the repository at this point in the history
Format of the status output depends on the preset. Account for this
without querying for what preset is in use.
  • Loading branch information
jsliacan authored and anjannath committed Jul 10, 2023
1 parent 7cbf68b commit 70316a8
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions test/extended/crc/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,31 +131,16 @@ func WaitForClusterInState(state string) error {
}

func CheckCRCStatus(state string) error {
expressionOpenshift := `.*OpenShift: .*Running \(v\d+\.\d+\.\d+.*\).*`
expressionMicroshift := `.*MicroShift: .*Running \(v\d+\.\d+\.\d+.*\).*`
expressionPodman := `.*Podman: .*\d+\.\d+\.\d+.*`
var expression string

err := util.ExecuteCommand("crc config get preset")
if err != nil {
return err
}

containsPreset := util.GetLastCommandOutput("stdout")
switch {
case strings.Contains(containsPreset, "podman"):
expression = expressionPodman
case strings.Contains(containsPreset, "microshift"):
expression = expressionMicroshift
default:
expression = expressionOpenshift
}
// Podman status does not show Running, so need to OR it separately
expression := `.*CRC VM: *Running\s.*: *Running|.*CRC VM: *Running\s.*Podman: *\d+\.\d+\.\d+`

// Does not apply to Podman preset
if state == "stopped" {
expression = ".*OpenShift: .*Stopped.*"
expression = `.*CRC VM:.*\s.*: .*Stopped.*`
}

err = util.ExecuteCommand(CRC("status").ToString())
err := util.ExecuteCommand(CRC("status").ToString())
if err != nil {
return err
}
Expand Down

0 comments on commit 70316a8

Please sign in to comment.