Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e: Add scenario for microshift preset #3779

Merged
merged 6 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ e2e-story-marketplace: install
@go test $(REPOPATH)/test/e2e --ldflags="$(VERSION_VARIABLES)" -v --godog.tags="$(GOOS) && ~@startstop && @story_marketplace" --cleanup-home=false
e2e-story-registry: install
@go test $(REPOPATH)/test/e2e --ldflags="$(VERSION_VARIABLES)" -v --godog.tags="$(GOOS) && ~@startstop && @story_registry" --cleanup-home=false

e2e-story-microshift: install
@go test $(REPOPATH)/test/e2e -tags "$(BUILDTAGS)" --ldflags="$(VERSION_VARIABLES)" -v $(PULL_SECRET_FILE) $(BUNDLE_LOCATION) $(CRC_BINARY) --godog.tags="$(GOOS) && @microshift" --cleanup-home=false

.PHONY: fmt
fmt: $(TOOLS_BINDIR)/goimports
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func init() {
func TestMain(m *testing.M) {

pflag.Parse()

testsuite.GodogTags = opts.Tags
status := godog.TestSuite{
Name: "crc",
TestSuiteInitializer: testsuite.InitializeTestSuite,
Expand Down
36 changes: 36 additions & 0 deletions test/e2e/features/story_microshift.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@story_microshift
Feature: Microshift test stories

Background:
Given setting config property "preset" to value "microshift" succeeds
And setting config property "network-mode" to value "user" succeeds
And executing single crc setup command succeeds
And starting CRC with default bundle succeeds

# End-to-end health check

@microshift @testdata @linux @windows @darwin
Scenario: Start and expose a basic HTTP service and check after restart
Given executing "oc create namespace testproj" succeeds
And executing "oc config set-context --current --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"
When executing "oc set volume deployment/httpd-example --add --type configmap --configmap-name www-content --name www --mount-path /var/www/html" succeeds
Then stdout should contain "deployment.apps/httpd-example volume updated"
When executing "oc expose deployment httpd-example --port 8080" succeeds
Then stdout should contain "httpd-example exposed"
When executing "oc expose svc httpd-example" succeeds
Then stdout should contain "httpd-example exposed"
When with up to "20" retries with wait period of "5s" http response from "http://httpd-example-testproj.apps.crc.testing" has status code "200"
Then executing "curl -s http://httpd-example-testproj.apps.crc.testing" succeeds
And stdout should contain "Hello CRC!"
When executing "crc stop" succeeds
And starting CRC with default bundle succeeds
gbraad marked this conversation as resolved.
Show resolved Hide resolved
And checking that CRC is running
And with up to "4" retries with wait period of "1m" http response from "http://httpd-example-testproj.apps.crc.testing" has status code "200"
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"
13 changes: 4 additions & 9 deletions test/e2e/testsuite/testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,17 @@ var (
testWithShell string
CRCVersion string

GodogFormat string
GodogTags string
GodogShowStepDefinitions bool
GodogStopOnFailure bool
GodogNoColors bool
GodogPaths string
GodogTags string
)

func ParseFlags() {

pflag.StringVar(&util.TestDir, "test-dir", "out", "Path to the directory in which to execute the tests")
pflag.StringVar(&testWithShell, "test-shell", "", "Specifies shell to be used for the testing.")

pflag.StringVar(&bundleLocation, "bundle-location", "/path/to/bundle.crcbundle", "Path to the bundle to be used in tests")
pflag.StringVar(&bundleLocation, "bundle-location", "", "Path to the bundle to be used in tests")
gbraad marked this conversation as resolved.
Show resolved Hide resolved
pflag.StringVar(&pullSecretFile, "pull-secret-file", "/path/to/pull-secret", "Path to the file containing pull secret")
pflag.StringVar(&CRCExecutable, "crc-binary", "/path/to/binary/crc", "Path to the CRC executable to be tested")
pflag.StringVar(&CRCExecutable, "crc-binary", "", "Path to the CRC executable to be tested")
gbraad marked this conversation as resolved.
Show resolved Hide resolved
pflag.BoolVar(&cleanupHome, "cleanup-home", false, "Try to remove crc home folder before starting the suite") // TODO: default=true
pflag.StringVar(&CRCVersion, "crc-version", "", "Version of CRC to be tested")
}
Expand Down Expand Up @@ -94,10 +89,10 @@ func InitializeTestSuite(tctx *godog.TestSuiteContext) {
}

if bundleLocation == "" {
fmt.Println("Expecting the bundle provided by the user")
userProvidedBundle = false
bundleName = constants.GetDefaultBundle(preset.OpenShift)
} else {
fmt.Println("Expecting the bundle provided by the user")
userProvidedBundle = true
_, bundleName = filepath.Split(bundleLocation)
}
Expand Down
4 changes: 3 additions & 1 deletion test/testdata/httpd-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,6 @@ spec:
schedulerName: default-scheduler
securityContext:
runAsNonRoot: true
terminationGracePeriodSeconds: 30
seccompProfile:
type: "RuntimeDefault"
terminationGracePeriodSeconds: 30