Skip to content

Commit

Permalink
e2e: Unify namespaces and move their deletion to hooks
Browse files Browse the repository at this point in the history
Namespace deletion should not be part of a Scenario because if any
preceding Step fails, the deletion will not be carried out. Move this
action to Scenario After hooks. Note: namespace creation cannot be
moved to Before hooks because Background is only run after them. So
the cluster may not be up yet.

Unify: I changed all namespaces to 'testproj' for
simplicity. Different project names (now namespaces) were only used to
avoid errors in case deletion failed.
  • Loading branch information
jsliacan authored and anjannath committed Jul 10, 2023
1 parent 70316a8 commit d801b78
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
28 changes: 11 additions & 17 deletions test/e2e/features/story_openshift.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ Feature: 4 Openshift stories

# End-to-end health check

@darwin @linux @windows @startstop @testdata @story_health
@darwin @linux @windows @startstop @testdata @story_health @needs_namespace
Scenario: Overall cluster health
Then executing "oc create namespace testproj" succeeds
And executing "oc project testproj" succeeds
And executing "oc apply -f httpd-example.yaml" succeeds
When executing "oc rollout status deployment httpd-example" succeeds
Given executing "oc create namespace testproj" succeeds
When executing "oc apply -f httpd-example.yaml" succeeds
And executing "oc rollout status deployment httpd-example" succeeds
Then stdout should contain "successfully rolled out"
When executing "oc create configmap www-content --from-file=index.html=httpd-example-index.html" succeeds
Then stdout should contain "configmap/www-content created"
Expand All @@ -32,17 +31,15 @@ Feature: 4 Openshift stories
Then executing "curl -s http://httpd-example-testproj.apps-crc.testing" succeeds
And stdout should contain "Hello CRC!"
Then with up to "4" retries with wait period of "1m" http response from "http://httpd-example-testproj.apps-crc.testing" has status code "200"
And executing "oc delete namespace testproj" succeeds

# Local image to image-registry feature

@darwin @linux @windows @testdata @story_registry @mirror-registry
@darwin @linux @windows @testdata @story_registry @mirror-registry @needs_namespace
Scenario: Mirror image to OpenShift image registry
Given executing "oc create namespace testproj-img" succeeds
And executing "oc project testproj-img" succeeds
Given executing "oc create namespace testproj" succeeds
# mirror
When executing "oc registry login --insecure=true" succeeds
Then executing "oc image mirror quay.io/centos7/httpd-24-centos7:latest=default-route-openshift-image-registry.apps-crc.testing/testproj-img/hello:test --insecure=true --filter-by-os=linux/amd64" succeeds
Then executing "oc image mirror quay.io/centos7/httpd-24-centos7:latest=default-route-openshift-image-registry.apps-crc.testing/testproj/hello:test --insecure=true --filter-by-os=linux/amd64" succeeds
And executing "oc set image-lookup hello" succeeds
# deploy
When executing "oc apply -f hello.yaml" succeeds
Expand All @@ -52,14 +49,11 @@ Feature: 4 Openshift stories
Then stdout should contain "Running"
When executing "oc logs deployment/hello" succeeds
Then stdout should contain "httpd"
# cleanup
And executing "oc delete namespace testproj-img" succeeds

@darwin @linux @windows @testdata @story_registry @local-registry
@darwin @linux @windows @testdata @story_registry @local-registry @needs_namespace
Scenario: Pull image locally, push to registry, deploy
Given podman command is available
And executing "oc create namespace testproj-img" succeeds
And executing "oc project testproj-img" succeeds
And executing "oc create namespace testproj" succeeds
When pulling image "quay.io/centos7/httpd-24-centos7", logging in, and pushing local image to internal registry succeeds
And executing "oc apply -f hello.yaml" succeeds
When executing "oc rollout status deployment hello" succeeds
Expand All @@ -68,12 +62,12 @@ Feature: 4 Openshift stories
Then stdout should contain "Running"
When executing "oc logs deployment/hello" succeeds
Then stdout should contain "httpd"
And executing "oc delete namespace testproj-img" succeeds

# Operator from marketplace

@darwin @linux @windows @testdata @story_marketplace @cleanup
@darwin @linux @windows @testdata @story_marketplace @cleanup @needs_namespace
Scenario: Install new operator
Given executing "oc create namespace testproj" succeeds
When executing "oc apply -f redis-sub.yaml" succeeds
Then with up to "20" retries with wait period of "30s" command "oc get csv" output matches ".*redis-operator\.(.*)Succeeded$"
# install redis operator
Expand Down
13 changes: 11 additions & 2 deletions test/e2e/testsuite/testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,15 @@ func InitializeScenario(s *godog.ScenarioContext) {

for _, tag := range sc.Tags {

// delete testproj namespace after a Scenario that used it
if tag.Name == "@needs_namespace" {
err := util.ExecuteCommand("oc delete namespace testproj")
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}

// move host's date 13 months back and turn timesync on
if tag.Name == "@timesync" {
err := util.ExecuteCommand("sudo date -s '-13 month'")
Expand Down Expand Up @@ -957,12 +966,12 @@ func PullLoginTagPushImageSucceeds(image string) error {
return err
}

_, err = cmd.RunPodmanExpectSuccess("tag", "quay.io/centos7/httpd-24-centos7", "default-route-openshift-image-registry.apps-crc.testing/testproj-img/hello:test")
_, err = cmd.RunPodmanExpectSuccess("tag", "quay.io/centos7/httpd-24-centos7", "default-route-openshift-image-registry.apps-crc.testing/testproj/hello:test")
if err != nil {
return err
}

_, err = cmd.RunPodmanExpectSuccess("push", "default-route-openshift-image-registry.apps-crc.testing/testproj-img/hello:test", "--tls-verify=false")
_, err = cmd.RunPodmanExpectSuccess("push", "default-route-openshift-image-registry.apps-crc.testing/testproj/hello:test", "--tls-verify=false")
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion test/testdata/hello.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ spec:
deployment: hello
spec:
containers:
- image: image-registry.openshift-image-registry.svc:5000/testproj-img/hello:test
- image: image-registry.openshift-image-registry.svc:5000/testproj/hello:test
imagePullPolicy: IfNotPresent
name: hello
ports:
Expand Down

0 comments on commit d801b78

Please sign in to comment.