Skip to content

Commit

Permalink
Prep, rearrange, format and reword
Browse files Browse the repository at this point in the history
  • Loading branch information
jsliacan authored and cfergeau committed Oct 22, 2019
1 parent 42991df commit 57ae9ea
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
27 changes: 26 additions & 1 deletion test/integration/crcsuite/crcsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ func FeatureContext(s *godog.Suite) {
LoginToOcClusterSucceedsOrFails)
s.Step(`^with up to "(\d+)" retries with wait period of "(\d*(?:ms|s|m))" all cluster operators are running$`,
CheckClusterOperatorsWithRetry)
s.Step(`^with up to "(\d+)" retries with wait period of "(\d*(?:ms|s|m))" http response from "(.*)" should have status code "(\d+)"$`,
s.Step(`^with up to "(\d+)" retries with wait period of "(\d*(?:ms|s|m))" http response from "(.*)" has status code "(\d+)"$`,
CheckHTTPResponseWithRetry)
s.Step(`^with up to "(\d+)" retries with wait period of "(\d*(?:ms|s|m))" command "(.*)" output (?:should match|matches) "(.*)"$`,
CheckOutputMatchWithRetry)

// CRC file operations
s.Step(`^file "([^"]*)" exists in CRC home folder$`,
Expand Down Expand Up @@ -159,6 +161,29 @@ func CheckHTTPResponseWithRetry(retryCount int, retryWait string, address string
return fmt.Errorf("Got %d as Status Code instead of expected %d.", resp.StatusCode, expectedStatusCode)
}

func CheckOutputMatchWithRetry(retryCount int, retryTime string, command string, expected string) error {

retryDuration, err := time.ParseDuration(retryTime)
if err != nil {
return err
}

var match_err error

for i := 0; i < retryCount; i++ {
exec_err := clicumber.ExecuteCommand(command)
if exec_err == nil {
match_err = clicumber.CommandReturnShouldMatch("stdout", expected)
if match_err == nil {
return nil
}
}
time.Sleep(retryDuration)
}

return match_err
}

func DeleteFileFromCRCHome(fileName string) error {

theFile := filepath.Join(CRCHome, fileName)
Expand Down
2 changes: 0 additions & 2 deletions test/integration/features/basic.feature
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ Feature: Basic test
And stdout should contain "Setting up KVM"
And stdout should contain "Installing libvirt service and dependencies"
And stdout should contain "Adding user to libvirt group"
And stdout should contain "Will use root access: add user to libvirt group"
And stdout should contain "Enabling libvirt"
And stdout should contain "Starting libvirt service"
And stdout should contain "Will use root access: start libvirtd service"
And stdout should contain "Installing crc-driver-libvirt"
And stdout should contain "Removing older system-wide crc-driver-libvirt"
And stdout should contain "Setting up libvirt 'crc' network"
Expand Down
7 changes: 4 additions & 3 deletions test/integration/features/story_health.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Feature:
When starting CRC with default bundle and hypervisor "<vm-driver>" succeeds
Then stdout should contain "The OpenShift cluster is running"
And executing "eval $(crc oc-env)" succeeds
When with up to "4" retries with wait period of "2m" command "crc status" output should contain "Running (v4."
When with up to "4" retries with wait period of "2m" command "crc status" output matches ".*Running \(v\d+\.\d+\.\d+.*\).*"
Then login to the oc cluster succeeds

@darwin
Expand All @@ -25,7 +25,7 @@ Feature:
@darwin @linux
Scenario: Check cluster health
Given executing "crc status" succeeds
And stdout contains "Running (v4."
And stdout should match ".*Running \(v\d+\.\d+\.\d+.*\).*"
When executing "oc get nodes"
Then stdout contains "Ready"
And stdout does not contain "Not ready"
Expand All @@ -52,8 +52,9 @@ Feature:
When executing "oc rollout status dc/httpd-ex" succeeds
Then stdout should contain "successfully rolled out"
And executing "oc expose svc/httpd-ex" succeeds
And with up to "2" retries with wait period of "60s" http response from "http://httpd-ex-testproj.apps-crc.testing" should have status code "200"
And with up to "2" retries with wait period of "60s" http response from "http://httpd-ex-testproj.apps-crc.testing" has status code "200"

@darwin @linux
Scenario: Clean up
Given executing "oc delete project testproj" succeeds
When executing "crc stop -f" succeeds
Expand Down
2 changes: 1 addition & 1 deletion test/integration/features/story_registry.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Feature: Local image to image-registry to deployment
When starting CRC with default bundle and hypervisor "<vm-driver>" succeeds
Then stdout should contain "The OpenShift cluster is running"
And executing "eval $(crc oc-env)" succeeds
When with up to "4" retries with wait period of "2m" command "crc status" output should contain "Running (v4."
When with up to "4" retries with wait period of "2m" command "crc status" output matches ".*Running \(v\d+\.\d+\.\d+.*\).*"
Then login to the oc cluster succeeds

Examples:
Expand Down

0 comments on commit 57ae9ea

Please sign in to comment.