From d82c1eaf28b205ff1bf3d7b0235d4793eec62fed Mon Sep 17 00:00:00 2001 From: amitkrout Date: Thu, 14 Feb 2019 16:43:51 +0530 Subject: [PATCH] Issue #1205 Update test suite to handle stderr (#1307) --- pkg/log/status.go | 4 +- tests/e2e/component.go | 171 ++++++++--------- tests/e2e/e2e.go | 44 +++-- tests/e2e/e2e_test.go | 391 +++++++++++++++++++------------------- tests/e2e/java_test.go | 82 ++++---- tests/e2e/json_test.go | 26 +-- tests/e2e/link_test.go | 53 +++--- tests/e2e/login_test.go | 32 ++-- tests/e2e/service_test.go | 24 +-- tests/e2e/source_test.go | 55 +++--- tests/e2e/utils.go | 3 +- tests/e2e/watch_test.go | 244 ++++++++++++------------ 12 files changed, 570 insertions(+), 559 deletions(-) diff --git a/pkg/log/status.go b/pkg/log/status.go index a10662b66a5..68fccb7930b 100644 --- a/pkg/log/status.go +++ b/pkg/log/status.go @@ -164,13 +164,13 @@ func Successf(format string, a ...interface{}) { // Errorf will output in an appropriate "progress" manner func Errorf(format string, a ...interface{}) { red := color.New(color.FgRed).SprintFunc() - fmt.Printf("%s%s%s%s\n", prefixSpacing, red("✗"), suffixSpacing, fmt.Sprintf(format, a...)) + fmt.Fprintf(os.Stderr, " %s%s%s\n", red("✗"), suffixSpacing, fmt.Sprintf(format, a...)) } // Error will output in an appropriate "progress" manner func Error(a ...interface{}) { red := color.New(color.FgRed).SprintFunc() - fmt.Printf("%s%s%s%s\n", prefixSpacing, red("✗"), suffixSpacing, fmt.Sprintln(a...)) + fmt.Fprintf(os.Stderr, " %s%s%s\n", red("✗"), suffixSpacing, fmt.Sprintln(a...)) } // Info will simply print out information on a new (bolded) line diff --git a/tests/e2e/component.go b/tests/e2e/component.go index 038d585b4d0..6cdef37e08f 100644 --- a/tests/e2e/component.go +++ b/tests/e2e/component.go @@ -2,12 +2,13 @@ package e2e import ( "fmt" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" "io/ioutil" "strconv" "strings" "time" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" ) // SourceTest checks the component-source-type and the source url in the annotation of the bc and dc @@ -16,11 +17,11 @@ import ( // source is the source of the component i.e gitURL or path to the directory or binary file func SourceTest(appTestName string, sourceType string, source string) { // checking for source-type in dc - getDc := runCmd("oc get dc wildfly-" + appTestName + " -o go-template='{{index .metadata.annotations \"app.kubernetes.io/component-source-type\"}}'") + getDc := runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='{{index .metadata.annotations \"app.kubernetes.io/component-source-type\"}}'") Expect(getDc).To(ContainSubstring(sourceType)) // checking for source in dc - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='{{index .metadata.annotations \"app.kubernetes.io/url\"}}'") + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='{{index .metadata.annotations \"app.kubernetes.io/url\"}}'") Expect(getDc).To(ContainSubstring(source)) } @@ -43,28 +44,28 @@ func componentTests(componentCmdPrefix string) { It("creating a component without an application should create one", func() { // new project == no app projectName := generateTimeBasedName("project") - runCmd("odo project create " + projectName) - Expect(runCmd("odo app list")).To(ContainSubstring("no applications")) + runCmdShouldPass("odo project create " + projectName) + Expect(runCmdShouldPass("odo app list")).To(ContainSubstring("no applications")) const frontend = "frontend" // create a frontend component, an app should have been created - runCmd(componentCmdPrefix + " create nodejs " + frontend) + runCmdShouldPass(componentCmdPrefix + " create nodejs " + frontend) appName := getActiveElementFromCommandOutput("odo app list") Expect(appName).ToNot(BeEmpty()) // check that we can get the component - Expect(runCmd("odo component get")).To(ContainSubstring("The current component is: " + frontend)) + Expect(runCmdShouldPass("odo component get")).To(ContainSubstring("The current component is: " + frontend)) const backend = "backend" - runCmd(componentCmdPrefix + " create python " + backend) - Expect(runCmd("odo component get")).To(ContainSubstring("The current component is: " + backend)) + runCmdShouldPass(componentCmdPrefix + " create python " + backend) + Expect(runCmdShouldPass("odo component get")).To(ContainSubstring("The current component is: " + backend)) // switch back to frontend component - Expect(runCmd("odo component set " + frontend)).To(ContainSubstring("Switched to component: " + frontend)) + Expect(runCmdShouldPass("odo component set " + frontend)).To(ContainSubstring("Switched to component: " + frontend)) // clean up - runCmd("odo app delete " + appName + " -f") - runCmd("odo project delete " + projectName + " -f") + runCmdShouldPass("odo app delete " + appName + " -f") + runCmdShouldPass("odo project delete " + projectName + " -f") waitForDeleteCmd("odo project list", projectName) }) }) @@ -72,42 +73,42 @@ func componentTests(componentCmdPrefix string) { Context("odo component creation", func() { It("should create the project and application", func() { - runCmd("odo project create " + projName) - runCmd("odo app create " + appTestName) + runCmdShouldPass("odo project create " + projName) + runCmdShouldPass("odo app create " + appTestName) }) It("should show an error when ref flag is provided with sources except git", func() { - output := runFailCmd(fmt.Sprintf(componentCmdPrefix+" create nodejs cmp-git-%s --local test --ref test", t), 1) - Expect(output).To(ContainSubstring("The --ref flag is only valid for --git flag")) + outputErr := runCmdShouldFail(fmt.Sprintf(componentCmdPrefix+" create nodejs cmp-git-%s --local test --ref test", t)) + Expect(outputErr).To(ContainSubstring("The --ref flag is only valid for --git flag")) }) It("should create the component from the branch ref when provided", func() { - runCmd(fmt.Sprintf(componentCmdPrefix+" create ruby ref-test-%s --git https://github.com/girishramnani/ruby-ex.git --ref develop", t)) - runCmd(fmt.Sprintf("odo url create ref-test-%s", t)) + runCmdShouldPass(fmt.Sprintf(componentCmdPrefix+" create ruby ref-test-%s --git https://github.com/girishramnani/ruby-ex.git --ref develop", t)) + runCmdShouldPass(fmt.Sprintf("odo url create ref-test-%s", t)) routeURL := determineRouteURL() + "/health" waitForEqualCmd("curl -s "+routeURL+" | grep 'develop' | wc -l | tr -d '\n'", "1", 10) }) It("should be able to create a component with git source", func() { - runCmd(componentCmdPrefix + " create nodejs cmp-git --git https://github.com/openshift/nodejs-ex --min-memory 100Mi --max-memory 300Mi --min-cpu 0.1 --max-cpu 2") - getMemoryLimit := runCmd("oc get dc cmp-git-" + + runCmdShouldPass(componentCmdPrefix + " create nodejs cmp-git --git https://github.com/openshift/nodejs-ex --min-memory 100Mi --max-memory 300Mi --min-cpu 0.1 --max-cpu 2") + getMemoryLimit := runCmdShouldPass("oc get dc cmp-git-" + appTestName + " -o go-template='{{range .spec.template.spec.containers}}{{.resources.limits.memory}}{{end}}'", ) Expect(getMemoryLimit).To(ContainSubstring("300Mi")) - getMemoryRequest := runCmd("oc get dc cmp-git-" + + getMemoryRequest := runCmdShouldPass("oc get dc cmp-git-" + appTestName + " -o go-template='{{range .spec.template.spec.containers}}{{.resources.requests.memory}}{{end}}'", ) Expect(getMemoryRequest).To(ContainSubstring("100Mi")) - getCPULimit := runCmd("oc get dc cmp-git-" + + getCPULimit := runCmdShouldPass("oc get dc cmp-git-" + appTestName + " -o go-template='{{range .spec.template.spec.containers}}{{.resources.limits.cpu}}{{end}}'", ) Expect(getCPULimit).To(ContainSubstring("2")) - getCPURequest := runCmd("oc get dc cmp-git-" + + getCPURequest := runCmdShouldPass("oc get dc cmp-git-" + appTestName + " -o go-template='{{range .spec.template.spec.containers}}{{.resources.requests.cpu}}{{end}}'", ) @@ -115,22 +116,22 @@ func componentTests(componentCmdPrefix string) { }) It("should list the component", func() { - cmpList := runCmd(componentCmdPrefix + " list") + cmpList := runCmdShouldPass(componentCmdPrefix + " list") Expect(cmpList).To(ContainSubstring("cmp-git")) }) It("should be in component description", func() { - cmpDesc := runCmd(componentCmdPrefix + " describe cmp-git") + cmpDesc := runCmdShouldPass(componentCmdPrefix + " describe cmp-git") Expect(cmpDesc).To(ContainSubstring("Source: https://github.com/openshift/nodejs-ex")) }) It("should be in application description", func() { - appDesc := runCmd(componentCmdPrefix + " describe") + appDesc := runCmdShouldPass(componentCmdPrefix + " describe") Expect(appDesc).To(ContainSubstring("Source: https://github.com/openshift/nodejs-ex")) }) It("should list the components in the catalog", func() { - getProj := runCmd("odo catalog list components") + getProj := runCmdShouldPass("odo catalog list components") Expect(getProj).To(ContainSubstring("wildfly")) Expect(getProj).To(ContainSubstring("ruby")) Expect(getProj).To(ContainSubstring("nodejs")) @@ -147,55 +148,55 @@ func componentTests(componentCmdPrefix string) { Context("updating the component", func() { It("should be able to create binary component", func() { - runCmd("curl -L -o " + tmpDir + "/sample-binary-testing-1.war " + + runCmdShouldPass("curl -L -o " + tmpDir + "/sample-binary-testing-1.war " + "https://gist.github.com/mik-dass/f95bd818ddba508ff76a386f8d984909/raw/e5bc575ac8b14ba2b23d66b5cb4873657e1a1489/sample.war") - runCmd(componentCmdPrefix + " create wildfly wildfly --binary " + tmpDir + "/sample-binary-testing-1.war --memory 500Mi") + runCmdShouldPass(componentCmdPrefix + " create wildfly wildfly --binary " + tmpDir + "/sample-binary-testing-1.war --memory 500Mi") // TODO: remove this once https://github.com/redhat-developer/odo/issues/943 is implemented time.Sleep(90 * time.Second) // Run push - runCmd(componentCmdPrefix + " push -v 4") + runCmdShouldPass(componentCmdPrefix + " push -v 4") // Verify memory limits to be same as configured - getMemoryLimit := runCmd("oc get dc wildfly-" + + getMemoryLimit := runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='{{range .spec.template.spec.containers}}{{.resources.limits.memory}}{{end}}'", ) Expect(getMemoryLimit).To(ContainSubstring("500Mi")) - getMemoryRequest := runCmd("oc get dc wildfly-" + + getMemoryRequest := runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='{{range .spec.template.spec.containers}}{{.resources.requests.memory}}{{end}}'", ) Expect(getMemoryRequest).To(ContainSubstring("500Mi")) - cmpList := runCmd(componentCmdPrefix + " list") + cmpList := runCmdShouldPass(componentCmdPrefix + " list") Expect(cmpList).To(ContainSubstring("wildfly")) - runCmd("oc get dc") + runCmdShouldPass("oc get dc") }) It("should update component from binary to binary", func() { - runCmd("curl -L -o " + tmpDir + "/sample-binary-testing-2.war " + + runCmdShouldPass("curl -L -o " + tmpDir + "/sample-binary-testing-2.war " + "'https://gist.github.com/mik-dass/f95bd818ddba508ff76a386f8d984909/raw/85354d9ee8583a9c1e64a331425eede235b07a9e/sample%2520(1).war'") waitForDCOfComponentToRolloutCompletely("wildfly") - runCmd(componentCmdPrefix + " update wildfly --binary " + tmpDir + "/sample-binary-testing-2.war") + runCmdShouldPass(componentCmdPrefix + " update wildfly --binary " + tmpDir + "/sample-binary-testing-2.war") // checking for init containers - getDc := runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc := runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.initContainers}}" + "{{.name}}{{end}}'") Expect(getDc).To(ContainSubstring(initContainerName)) // checking for volumes - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.volumes}}" + "{{.name}}{{end}}'") Expect(getDc).To(ContainSubstring("wildfly" + appRootVolumeName)) // checking for volumes mounts - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.containers}}{{range .volumeMounts}}{{.name}}" + "{{.name}}{{end}}{{end}}'") Expect(getDc).To(ContainSubstring("wildfly" + appRootVolumeName)) @@ -204,37 +205,37 @@ func componentTests(componentCmdPrefix string) { }) It("should update component from binary to local", func() { - runCmd("git clone " + wildflyURI1 + " " + + runCmdShouldPass("git clone " + wildflyURI1 + " " + tmpDir + "/katacoda-odo-backend-1") waitForDCOfComponentToRolloutCompletely("wildfly") - runCmd(componentCmdPrefix + " update wildfly --local " + tmpDir + "/katacoda-odo-backend-1") + runCmdShouldPass(componentCmdPrefix + " update wildfly --local " + tmpDir + "/katacoda-odo-backend-1") // checking for init containers - getDc := runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc := runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.initContainers}}" + "{{.name}}{{end}}'") Expect(getDc).To(ContainSubstring(initContainerName)) // checking for volumes - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.volumes}}" + "{{.name}}{{end}}'") Expect(getDc).To(ContainSubstring("wildfly" + appRootVolumeName)) // checking for volumes mounts - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.containers}}{{range .volumeMounts}}{{.name}}" + "{{.name}}{{end}}{{end}}'") Expect(getDc).To(ContainSubstring("wildfly" + appRootVolumeName)) // Verify memory limits to be same as configured - getMemoryLimit := runCmd("oc get dc wildfly-" + + getMemoryLimit := runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='{{range .spec.template.spec.containers}}{{.resources.limits.memory}}{{end}}'", ) Expect(getMemoryLimit).To(ContainSubstring("500Mi")) - getMemoryRequest := runCmd("oc get dc wildfly-" + + getMemoryRequest := runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='{{range .spec.template.spec.containers}}{{.resources.requests.memory}}{{end}}'", ) @@ -244,26 +245,26 @@ func componentTests(componentCmdPrefix string) { }) It("should update component from local to local", func() { - runCmd("git clone " + wildflyURI2 + " " + + runCmdShouldPass("git clone " + wildflyURI2 + " " + tmpDir + "/katacoda-odo-backend-2") waitForDCOfComponentToRolloutCompletely("wildfly") - runCmd(componentCmdPrefix + " update wildfly --local " + tmpDir + "/katacoda-odo-backend-2") + runCmdShouldPass(componentCmdPrefix + " update wildfly --local " + tmpDir + "/katacoda-odo-backend-2") // checking for init containers - getDc := runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc := runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.initContainers}}" + "{{.name}}{{end}}'") Expect(getDc).To(ContainSubstring(initContainerName)) // checking for volumes - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.volumes}}" + "{{.name}}{{end}}'") Expect(getDc).To(ContainSubstring("wildfly" + appRootVolumeName)) // checking for volumes mounts - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.containers}}{{range .volumeMounts}}{{.name}}" + "{{.name}}{{end}}{{end}}'") Expect(getDc).To(ContainSubstring("wildfly" + appRootVolumeName)) @@ -273,26 +274,26 @@ func componentTests(componentCmdPrefix string) { It("should update component from local to git", func() { waitForDCOfComponentToRolloutCompletely("wildfly") - runCmd(componentCmdPrefix + " update wildfly --git " + wildflyURI1) + runCmdShouldPass(componentCmdPrefix + " update wildfly --git " + wildflyURI1) // checking bc for updates - getBc := runCmd("oc get bc wildfly-" + appTestName + " -o go-template={{.spec.source.git.uri}}") + getBc := runCmdShouldPass("oc get bc wildfly-" + appTestName + " -o go-template={{.spec.source.git.uri}}") Expect(getBc).To(Equal(wildflyURI1)) // checking for init containers - getDc := runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc := runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.initContainers}}" + "{{.name}}{{end}}'") Expect(getDc).NotTo(ContainSubstring(initContainerName)) // checking for volumes - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.volumes}}" + "{{.name}}{{end}}'") Expect(getDc).NotTo(ContainSubstring("wildfly" + appRootVolumeName)) // checking for volumes mounts - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.containers}}{{range .volumeMounts}}{{.name}}" + "{{.name}}{{end}}{{end}}'") Expect(getDc).NotTo(ContainSubstring("wildfly" + appRootVolumeName)) @@ -301,26 +302,26 @@ func componentTests(componentCmdPrefix string) { }) It("should update component from git to git", func() { waitForDCOfComponentToRolloutCompletely("wildfly") - runCmd(componentCmdPrefix + " update wildfly --git " + wildflyURI2) + runCmdShouldPass(componentCmdPrefix + " update wildfly --git " + wildflyURI2) // checking bc for updates - getBc := runCmd("oc get bc wildfly-" + appTestName + " -o go-template={{.spec.source.git.uri}}") + getBc := runCmdShouldPass("oc get bc wildfly-" + appTestName + " -o go-template={{.spec.source.git.uri}}") Expect(getBc).To(Equal(wildflyURI2)) // checking for init containers - getDc := runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc := runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.initContainers}}" + "{{.name}}{{end}}'") Expect(getDc).NotTo(ContainSubstring(initContainerName)) // checking for volumes - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.volumes}}" + "{{.name}}{{end}}'") Expect(getDc).NotTo(ContainSubstring("wildfly" + appRootVolumeName)) // checking for volumes mounts - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.containers}}{{range .volumeMounts}}{{.name}}" + "{{.name}}{{end}}{{end}}'") Expect(getDc).NotTo(ContainSubstring("wildfly" + appRootVolumeName)) @@ -330,28 +331,28 @@ func componentTests(componentCmdPrefix string) { // This is expected to be removed at the time of fixing https://github.com/redhat-developer/odo/issues/1008 It("should create a wildfly git component", func() { - runCmd(componentCmdPrefix + " delete wildfly -f") - runCmd(componentCmdPrefix + " create wildfly wildfly --git " + wildflyURI1) + runCmdShouldPass(componentCmdPrefix + " delete wildfly -f") + runCmdShouldPass(componentCmdPrefix + " create wildfly wildfly --git " + wildflyURI1) }) It("should update component from git to local", func() { waitForDCOfComponentToRolloutCompletely("wildfly") - runCmd(componentCmdPrefix + " update wildfly --local " + tmpDir + "/katacoda-odo-backend-1") + runCmdShouldPass(componentCmdPrefix + " update wildfly --local " + tmpDir + "/katacoda-odo-backend-1") // checking for init containers - getDc := runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc := runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.initContainers}}" + "{{.name}}{{end}}'") Expect(getDc).To(ContainSubstring(initContainerName)) // checking for volumes - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.volumes}}" + "{{.name}}{{end}}'") Expect(getDc).To(ContainSubstring("wildfly" + appRootVolumeName)) // checking for volumes mounts - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.containers}}{{range .volumeMounts}}{{.name}}" + "{{.name}}{{end}}{{end}}'") Expect(getDc).To(ContainSubstring("wildfly" + appRootVolumeName)) @@ -361,22 +362,22 @@ func componentTests(componentCmdPrefix string) { It("should update component from local to binary", func() { waitForDCOfComponentToRolloutCompletely("wildfly") - runCmd(componentCmdPrefix + " update wildfly --binary " + tmpDir + "/sample-binary-testing-1.war") + runCmdShouldPass(componentCmdPrefix + " update wildfly --binary " + tmpDir + "/sample-binary-testing-1.war") // checking for init containers - getDc := runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc := runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.initContainers}}" + "{{.name}}{{end}}'") Expect(getDc).To(ContainSubstring(initContainerName)) // checking for volumes - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.volumes}}" + "{{.name}}{{end}}'") Expect(getDc).To(ContainSubstring("wildfly" + appRootVolumeName)) // checking for volumes mounts - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.containers}}{{range .volumeMounts}}{{.name}}" + "{{.name}}{{end}}{{end}}'") Expect(getDc).To(ContainSubstring("wildfly" + appRootVolumeName)) @@ -385,28 +386,28 @@ func componentTests(componentCmdPrefix string) { }) It("should create a wildfly git component", func() { - runCmd(componentCmdPrefix + " delete wildfly -f") - runCmd(componentCmdPrefix + " create wildfly wildfly --git " + wildflyURI1) + runCmdShouldPass(componentCmdPrefix + " delete wildfly -f") + runCmdShouldPass(componentCmdPrefix + " create wildfly wildfly --git " + wildflyURI1) }) It("should update component from git to binary", func() { waitForDCOfComponentToRolloutCompletely("wildfly") - runCmd(componentCmdPrefix + " update wildfly --binary " + tmpDir + "/sample-binary-testing-1.war") + runCmdShouldPass(componentCmdPrefix + " update wildfly --binary " + tmpDir + "/sample-binary-testing-1.war") // checking for init containers - getDc := runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc := runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.initContainers}}" + "{{.name}}{{end}}'") Expect(getDc).To(ContainSubstring(initContainerName)) // checking for volumes - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.volumes}}" + "{{.name}}{{end}}'") Expect(getDc).To(ContainSubstring("wildfly" + appRootVolumeName)) // checking for volumes mounts - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.containers}}{{range .volumeMounts}}{{.name}}" + "{{.name}}{{end}}{{end}}'") Expect(getDc).To(ContainSubstring("wildfly" + appRootVolumeName)) @@ -416,26 +417,26 @@ func componentTests(componentCmdPrefix string) { It("should update component from binary to git", func() { waitForDCOfComponentToRolloutCompletely("wildfly") - runCmd(componentCmdPrefix + " update wildfly --git " + wildflyURI1) + runCmdShouldPass(componentCmdPrefix + " update wildfly --git " + wildflyURI1) // checking bc for updates - getBc := runCmd("oc get bc wildfly-" + appTestName + " -o go-template={{.spec.source.git.uri}}") + getBc := runCmdShouldPass("oc get bc wildfly-" + appTestName + " -o go-template={{.spec.source.git.uri}}") Expect(getBc).To(Equal(wildflyURI1)) // checking for init containers - getDc := runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc := runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.initContainers}}" + "{{.name}}{{end}}'") Expect(getDc).NotTo(ContainSubstring(initContainerName)) // checking for volumes - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.volumes}}" + "{{.name}}{{end}}'") Expect(getDc).NotTo(ContainSubstring("wildfly" + appRootVolumeName)) // checking for volumes mounts - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.containers}}{{range .volumeMounts}}{{.name}}" + "{{.name}}{{end}}{{end}}'") Expect(getDc).NotTo(ContainSubstring("wildfly" + appRootVolumeName)) @@ -447,9 +448,9 @@ func componentTests(componentCmdPrefix string) { Context("cleaning up", func() { It("should delete the application", func() { - runCmd("odo app delete " + appTestName + " -f") + runCmdShouldPass("odo app delete " + appTestName + " -f") - runCmd("odo project delete " + projName + " -f") + runCmdShouldPass("odo project delete " + projName + " -f") waitForDeleteCmd("odo project list", projName) }) }) diff --git a/tests/e2e/e2e.go b/tests/e2e/e2e.go index e7cef0d7e00..43e79f90168 100644 --- a/tests/e2e/e2e.go +++ b/tests/e2e/e2e.go @@ -19,36 +19,40 @@ func generateTimeBasedName(prefix string) string { } func getActiveElementFromCommandOutput(command string) string { - result := runCmd(command + " | sed -n '1!p' | awk 'FNR==2 { print $2 }'") + result := runCmdShouldPass(command + " | sed -n '1!p' | awk 'FNR==2 { print $2 }'") return strings.TrimSpace(result) } -func runCmd(cmdS string) string { +// cmdRunner runs a command +// and returns the stdout, stderr and exitcode +func cmdRunner(cmdS string) (string, string, int) { cmd := exec.Command("/bin/sh", "-c", cmdS) fmt.Fprintf(GinkgoWriter, "Running command: %s\n", cmdS) session, err := gexec.Start(cmd, GinkgoWriter, GinkgoWriter) // wait for the command execution to complete <-session.Exited - Expect(session.ExitCode()).To(Equal(0)) - Expect(err).NotTo(HaveOccurred()) - return string(session.Out.Contents()) + Expect(err).NotTo(HaveOccurred()) + return string(session.Out.Contents()), string(session.Err.Contents()), session.ExitCode() } -// runFailCmd runs a failing command -// and returns the stdout -func runFailCmd(cmdS string, exitCode int) string { - cmd := exec.Command("/bin/sh", "-c", cmdS) - fmt.Fprintf(GinkgoWriter, "Running command: %s\n", cmdS) - session, err := gexec.Start(cmd, GinkgoWriter, GinkgoWriter) - - // wait for the command execution to complete - <-session.Exited - Expect(session.ExitCode()).To(Equal(exitCode)) - Expect(err).NotTo(HaveOccurred()) +// runCmdShouldPass runs a command +// and returns stdout if passes, +// error out otherwise +func runCmdShouldPass(cmd string) string { + stdout, _, exitcode := cmdRunner(cmd) + Expect(exitcode).To(Equal(0)) + return stdout +} - return string(session.Out.Contents()) +// runCmdShouldFail runs a command +// and returns stderr if fails, +// error out otherwise +func runCmdShouldFail(cmd string) string { + _, stderr, exitcode := cmdRunner(cmd) + Expect(exitcode).To(Not(Equal(0))) + return stderr } // waitForCmdOut runs a command until it gets @@ -87,11 +91,11 @@ func waitForCmdOut(cmd string, timeout int, check func(output string) bool) bool // this is very useful to avoid race conditions that can occur when // updating the component func waitForDCOfComponentToRolloutCompletely(componentName string) { - fullDCName := runCmd(fmt.Sprintf("oc get dc -l app.kubernetes.io/component-name=%s -o name | tr -d '\n'", componentName)) + fullDCName := runCmdShouldPass(fmt.Sprintf("oc get dc -l app.kubernetes.io/component-name=%s -o name | tr -d '\n'", componentName)) // oc rollout status ensures that the existing DC is fully rolled out before it terminates // we need this because a rolling DC could cause odo update to fail due to its use // of the read/update-in-memory/write-changes pattern - runCmd("oc rollout status " + fullDCName) + runCmdShouldPass("oc rollout status " + fullDCName) simpleDCName := strings.Replace(fullDCName, "deploymentconfig.apps.openshift.io/", "", -1) // ensure that no more changes will occur to the name DC by waiting until there is only one pod running (the old one has terminated) @@ -185,7 +189,7 @@ func cleanUpAfterProjects(projects []string) { deleteProject(p) } // Logout of current user to ensure state - runCmd("oc logout") + runCmdShouldPass("oc logout") } // deletes a specified project diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index 1cf6e9d704a..bff04849a38 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -29,12 +29,12 @@ func EnvVarTest(resourceName string, sourceType string, envString string) { if sourceType == "git" { // checking the values of the env vars pairs in bc - envVars := runCmd("oc get bc " + resourceName + " -o go-template='{{range .spec.strategy.sourceStrategy.env}}{{.name}}{{.value}}{{end}}'") + envVars := runCmdShouldPass("oc get bc " + resourceName + " -o go-template='{{range .spec.strategy.sourceStrategy.env}}{{.name}}{{.value}}{{end}}'") Expect(envVars).To(Equal(envString)) } // checking the values of the env vars pairs in dc - envVars := runCmd("oc get dc " + resourceName + " -o go-template='{{range .spec.template.spec.containers}}{{range .env}}{{.name}}{{.value}}{{end}}{{end}}'") + envVars := runCmdShouldPass("oc get dc " + resourceName + " -o go-template='{{range .spec.template.spec.containers}}{{range .env}}{{.name}}{{.value}}{{end}}{{end}}'") Expect(envVars).To(Equal(envString)) } @@ -45,7 +45,7 @@ func TestOdo(t *testing.T) { var _ = BeforeSuite(func() { // Save the current project - curProj = runCmd("oc project -q") + curProj = runCmdShouldPass("oc project -q") }) var _ = Describe("odoe2e", func() { @@ -59,72 +59,72 @@ var _ = Describe("odoe2e", func() { Context("odo service create", func() { It("should return error if the cluster has no service catalog deployed", func() { - loginOutput := runCmd("odo login --username developer --password developer") + loginOutput := runCmdShouldPass("odo login --username developer --password developer") Expect(loginOutput).To(ContainSubstring("Login successful")) - sessionOutput := runFailCmd("odo service create", 1) - Expect(sessionOutput).To(ContainSubstring("unable to retrieve service classes")) + sessionErrOutput := runCmdShouldFail("odo service create") + Expect(sessionErrOutput).To(ContainSubstring("unable to retrieve service classes")) }) }) // TODO: Create component without creating application Context("odo project", func() { It("should create a new project", func() { - session := runCmd("odo project create " + projName) + session := runCmdShouldPass("odo project create " + projName) Expect(session).To(ContainSubstring(projName)) }) It("should get the project", func() { - getProj := runCmd("odo project get --short") + getProj := runCmdShouldPass("odo project get --short") Expect(getProj).To(Equal(projName)) }) // Issue #630 It("should list the project", func() { - listProj := runCmd("sleep 5s && odo project list") + listProj := runCmdShouldPass("sleep 5s && odo project list") Expect(listProj).To(ContainSubstring(projName)) }) }) Context("odo utils config", func() { It("should get blank for updatenotification by default globally as its not set", func() { - configOutput := runCmd("odo utils config view --global") + configOutput := runCmdShouldPass("odo utils config view --global") Expect(configOutput).To(ContainSubstring(config.UpdateNotificationSetting)) Expect(configOutput).To(ContainSubstring(config.NamePrefixSetting)) Expect(configOutput).To(ContainSubstring(config.TimeoutSetting)) }) It("should be checking to see if timeout is shown as blank globally as its not set", func() { - configOutput := runCmd("odo utils config view --global|grep Timeout") + configOutput := runCmdShouldPass("odo utils config view --global|grep Timeout") Expect(configOutput).To(ContainSubstring(fmt.Sprintf("Timeout"))) }) It("should be checking to see if global config values are the same as the configured ones", func() { - runCmd("odo utils config set --global updatenotification false") - runCmd("odo utils config set --global timeout 5") - configOutput := runCmd("odo utils config view --global |grep UpdateNotification") + runCmdShouldPass("odo utils config set --global updatenotification false") + runCmdShouldPass("odo utils config set --global timeout 5") + configOutput := runCmdShouldPass("odo utils config view --global |grep UpdateNotification") Expect(configOutput).To(ContainSubstring("false")) Expect(configOutput).To(ContainSubstring("UpdateNotification")) - configOutput = runCmd("odo utils config view --global |grep Timeout") + configOutput = runCmdShouldPass("odo utils config view --global |grep Timeout") Expect(configOutput).To(ContainSubstring("5")) }) It("should be checking to see if local config values are the same as the configured ones", func() { - runCmd("odo utils config set componenttype java") - configOutput := runCmd("odo utils config view|grep ComponentType") + runCmdShouldPass("odo utils config set componenttype java") + configOutput := runCmdShouldPass("odo utils config view|grep ComponentType") Expect(configOutput).To(ContainSubstring("java")) Expect(configOutput).To(ContainSubstring("ComponentType")) }) It("should allow unsetting a config locally", func() { - runCmd("odo utils config set componenttype java") - configOutput := runCmd("odo utils config unset -f componentType") + runCmdShouldPass("odo utils config set componenttype java") + configOutput := runCmdShouldPass("odo utils config unset -f componentType") Expect(configOutput).To(ContainSubstring("Local config was successfully updated.")) - configOutput = runCmd("odo utils config view|grep ComponentType") + configOutput = runCmdShouldPass("odo utils config view|grep ComponentType") Expect(configOutput).NotTo(ContainSubstring("java")) }) It("should allow unsetting a config globally", func() { - runCmd("odo utils config set --global timeout 5") - configOutput := runCmd("odo utils config unset -f --global timeout") + runCmdShouldPass("odo utils config set --global timeout 5") + configOutput := runCmdShouldPass("odo utils config unset -f --global timeout") Expect(configOutput).To(ContainSubstring("Global config was successfully updated.")) - configOutput = runCmd("odo utils config view --global |grep Timeout") + configOutput = runCmdShouldPass("odo utils config view --global |grep Timeout") Expect(configOutput).NotTo(ContainSubstring("5")) }) @@ -132,19 +132,19 @@ var _ = Describe("odoe2e", func() { Context("creating component without an application", func() { It("should create the component in default application", func() { - runCmd("odo create php testcmp") + runCmdShouldPass("odo create php testcmp") - getCmp := runCmd("odo component get --short") + getCmp := runCmdShouldPass("odo component get --short") Expect(getCmp).To(Equal("testcmp")) - getApp := runCmd("odo app get --short") + getApp := runCmdShouldPass("odo app get --short") Expect(getApp).To(ContainSubstring("e2e-")) }) It("should be able to delete the component", func() { - runCmd("odo delete testcmp -f") + runCmdShouldPass("odo delete testcmp -f") - getCmp := runCmd("odo list") + getCmp := runCmdShouldPass("odo list") Expect(getCmp).NotTo(ContainSubstring("testcmp")) }) }) @@ -152,38 +152,38 @@ var _ = Describe("odoe2e", func() { Describe("creating an application", func() { Context("when application by the same name doesn't exist", func() { It("should create an application", func() { - appName := runCmd("odo app create " + appTestName) + appName := runCmdShouldPass("odo app create " + appTestName) Expect(appName).To(ContainSubstring(appTestName)) }) It("should get the current application", func() { - appName := runCmd("odo app get --short") + appName := runCmdShouldPass("odo app get --short") Expect(appName).To(Equal(appTestName)) }) It("should be created within the project", func() { - projName := runCmd("odo project get --short") + projName := runCmdShouldPass("odo project get --short") Expect(projName).To(Equal(projName)) }) It("should be able to create another application", func() { - appName := runCmd("odo app create " + appTestName + "-2") + appName := runCmdShouldPass("odo app create " + appTestName + "-2") Expect(appName).To(ContainSubstring(appTestName + "-2")) }) It("should be able to list applications in current project", func() { - appNames := runCmd("odo app list") + appNames := runCmdShouldPass("odo app list") Expect(appNames).To(ContainSubstring(appTestName)) Expect(appNames).To(ContainSubstring(appTestName + "-2")) }) It("should be able to delete an application", func() { // Cleanup - runCmd("odo app delete " + appTestName + "-2 -f") + runCmdShouldPass("odo app delete " + appTestName + "-2 -f") }) It("should be able to set an application as current", func() { - appName := runCmd("odo app set " + appTestName) + appName := runCmdShouldPass("odo app set " + appTestName) Expect(appName).To(ContainSubstring(appTestName)) }) }) @@ -194,33 +194,33 @@ var _ = Describe("odoe2e", func() { Context("should list applications in other project", func() { newProjName := strings.Replace(projName, "odo", "odo2", -1) It("should create a new project", func() { - session := runCmd("odo project create " + newProjName) + session := runCmdShouldPass("odo project create " + newProjName) Expect(session).To(ContainSubstring(newProjName)) }) It("should get the project", func() { - getProj := runCmd("odo project get --short") + getProj := runCmdShouldPass("odo project get --short") Expect(strings.TrimSpace(getProj)).To(Equal(newProjName)) }) It("should show nice message when there is no application in project", func() { - appNames := runCmd("odo app list") + appNames := runCmdShouldPass("odo app list") Expect(strings.TrimSpace(appNames)).To( Equal("There are no applications deployed in the project '" + newProjName + "'.")) }) It("should be able to list applications in other project", func() { - appNames := runCmd("odo app list --project " + projName) + appNames := runCmdShouldPass("odo app list --project " + projName) Expect(appNames).To(ContainSubstring(appTestName)) }) It("should set the other project as active", func() { - setProj := runCmd("odo project set --short " + projName) + setProj := runCmdShouldPass("odo project set --short " + projName) Expect(strings.TrimSpace(setProj)).To(Equal(projName)) }) It("should be able to set an application as current", func() { - appName := runCmd("odo app set " + appTestName) + appName := runCmdShouldPass("odo app set " + appTestName) Expect(appName).To(ContainSubstring(appTestName)) }) }) @@ -230,107 +230,109 @@ var _ = Describe("odoe2e", func() { var autoGenNodeJSCompName string It("should be able to create new imagestream and find it in catalog list", func() { - curProj = strings.TrimSuffix(runCmd("oc project -q"), "\n") + curProj = runCmdShouldPass("oc project -q") + curProj = strings.TrimSuffix(curProj, "\n") cmd := fmt.Sprintf("oc create -f "+testNamespacedImage+" -n %s", curProj) - runCmd(cmd) - cmpList := runCmd("odo catalog list components") + runCmdShouldPass(cmd) + cmpList := runCmdShouldPass("odo catalog list components") Expect(cmpList).To(ContainSubstring(curProj)) }) It("should create a named component", func() { - runCmd("git clone https://github.com/openshift/nodejs-ex " + + runCmdShouldPass("git clone https://github.com/openshift/nodejs-ex " + tmpDir + "/nodejs-ex") // TODO: add tests for --git - curProj = strings.TrimSuffix(runCmd("oc project -q"), "\n") + curProj = runCmdShouldPass("oc project -q") + curProj = strings.TrimSuffix(curProj, "\n") // Sleep until status tags and their annotations are created time.Sleep(15 * time.Second) - runCmd("odo create " + curProj + "/nodejs nodejs --local " + tmpDir + "/nodejs-ex") - runCmd("odo push") + runCmdShouldPass("odo create " + curProj + "/nodejs nodejs --local " + tmpDir + "/nodejs-ex") + runCmdShouldPass("odo push") }) It("should create a component with auto-generated name", func() { - runCmd("odo create " + curProj + "/nodejs --local " + tmpDir + "/nodejs-ex") - runCmd("odo push") + runCmdShouldPass("odo create " + curProj + "/nodejs --local " + tmpDir + "/nodejs-ex") + runCmdShouldPass("odo push") }) It("should be the get the component created as active component", func() { - autoGenNodeJSCompName = runCmd("odo component get --short") + autoGenNodeJSCompName = runCmdShouldPass("odo component get --short") Expect(autoGenNodeJSCompName).To(ContainSubstring(fmt.Sprintf("nodejs-ex-%s-nodejs", curProj))) }) It("should create the component within the application", func() { - getApp := runCmd("odo app get --short") + getApp := runCmdShouldPass("odo app get --short") Expect(getApp).To(Equal(appTestName)) }) It("should list the components within the application", func() { - cmpList := runCmd("odo list") + cmpList := runCmdShouldPass("odo list") Expect(cmpList).To(ContainSubstring("nodejs")) }) It("should be able to create multiple components within the same application", func() { - runCmd("odo create php php") + runCmdShouldPass("odo create php php") }) It("should list the newly created second component", func() { - cmpList := runCmd("odo list") + cmpList := runCmdShouldPass("odo list") Expect(cmpList).To(ContainSubstring("php")) }) It("should get the application "+appTestName, func() { - appGet := runCmd("odo app get --short") + appGet := runCmdShouldPass("odo app get --short") Expect(appGet).To(Equal(appTestName)) }) It("should be able to set a component as active", func() { - cmpSet := runCmd(fmt.Sprintf("odo component set %s", autoGenNodeJSCompName)) + cmpSet := runCmdShouldPass(fmt.Sprintf("odo component set %s", autoGenNodeJSCompName)) Expect(cmpSet).To(ContainSubstring(autoGenNodeJSCompName)) }) It("should be able to retrieve logs", func() { - runCmd("odo log") - runCmd(fmt.Sprintf("odo log %s", autoGenNodeJSCompName)) + runCmdShouldPass("odo log") + runCmdShouldPass(fmt.Sprintf("odo log %s", autoGenNodeJSCompName)) }) It("should be able to create git component with required ports", func() { - runCmd("odo create nodejs nodejs-git --git https://github.com/openshift/nodejs-ex --port 8080/tcp,9100/udp") + runCmdShouldPass("odo create nodejs nodejs-git --git https://github.com/openshift/nodejs-ex --port 8080/tcp,9100/udp") // checking port names - portsNames := runCmd("oc get services nodejs-git-" + appTestName + " -o go-template='{{range .spec.ports}}{{.name}}{{end}}'") + portsNames := runCmdShouldPass("oc get services nodejs-git-" + appTestName + " -o go-template='{{range .spec.ports}}{{.name}}{{end}}'") Expect(portsNames).To(ContainSubstring("8080-tcp")) Expect(portsNames).To(ContainSubstring("9100-udp")) // checking port numbers - ports := runCmd("oc get services nodejs-git-" + appTestName + " -o go-template='{{range .spec.ports}}{{.port}}{{end}}'") + ports := runCmdShouldPass("oc get services nodejs-git-" + appTestName + " -o go-template='{{range .spec.ports}}{{.port}}{{end}}'") Expect(ports).To(ContainSubstring("8080")) Expect(ports).To(ContainSubstring("9100")) // checking protocols - protocols := runCmd("oc get services nodejs-git-" + appTestName + " -o go-template='{{range .spec.ports}}{{.protocol}}{{end}}'") + protocols := runCmdShouldPass("oc get services nodejs-git-" + appTestName + " -o go-template='{{range .spec.ports}}{{.protocol}}{{end}}'") Expect(protocols).To(ContainSubstring("TCP")) Expect(protocols).To(ContainSubstring("UDP")) // deleting the component - runCmd("odo delete -f") + runCmdShouldPass("odo delete -f") - getCmp := runCmd("odo list") + getCmp := runCmdShouldPass("odo list") Expect(getCmp).NotTo(ContainSubstring("nodejs-git")) }) It("should be able to create git component with required env vars", func() { - runCmd("odo create nodejs nodejs-git --git https://github.com/openshift/nodejs-ex --env key=value,key1=value1") + runCmdShouldPass("odo create nodejs nodejs-git --git https://github.com/openshift/nodejs-ex --env key=value,key1=value1") // checking the values of the env vars pairs in bc - envVars := runCmd("oc get bc nodejs-git-" + appTestName + " -o go-template='{{range .spec.strategy.sourceStrategy.env}}{{.name}}{{.value}}{{end}}'") + envVars := runCmdShouldPass("oc get bc nodejs-git-" + appTestName + " -o go-template='{{range .spec.strategy.sourceStrategy.env}}{{.name}}{{.value}}{{end}}'") Expect(envVars).To(Equal("keyvaluekey1value1")) // checking the values of the env vars pairs in dc - envVars = runCmd("oc get dc nodejs-git-" + appTestName + " -o go-template='{{range .spec.template.spec.containers}}{{range .env}}{{.name}}{{.value}}{{end}}{{end}}'") + envVars = runCmdShouldPass("oc get dc nodejs-git-" + appTestName + " -o go-template='{{range .spec.template.spec.containers}}{{range .env}}{{.name}}{{.value}}{{end}}{{end}}'") Expect(envVars).To(Equal("keyvaluekey1value1")) // deleting the component - runCmd("odo delete -f") + runCmdShouldPass("odo delete -f") }) }) }) @@ -338,25 +340,25 @@ var _ = Describe("odoe2e", func() { Describe("Creating odo url", func() { Context("using odo url", func() { It("should create route without url name provided", func() { - runCmd("odo component set nodejs") - getURLOut := runCmd("odo url create") + runCmdShouldPass("odo component set nodejs") + getURLOut := runCmdShouldPass("odo url create") Expect(getURLOut).To(ContainSubstring("nodejs-8080-" + appTestName + "-" + projName)) // check the port number of the created URL - port := runCmd("oc get route nodejs-8080-" + appTestName + " -o go-template='{{index .spec.port.targetPort}}'") + port := runCmdShouldPass("oc get route nodejs-8080-" + appTestName + " -o go-template='{{index .spec.port.targetPort}}'") Expect(port).To(Equal("8080")) // delete the url - runCmd("odo url delete nodejs-8080 -f") + runCmdShouldPass("odo url delete nodejs-8080 -f") }) It("should create route without port in case of single service port component", func() { - runCmd("odo component set nodejs") - getURLOut := runCmd("odo url create nodejs") + runCmdShouldPass("odo component set nodejs") + getURLOut := runCmdShouldPass("odo url create nodejs") Expect(getURLOut).To(ContainSubstring("nodejs-" + appTestName + "-" + projName)) // check the port number of the created URL - port := runCmd("oc get route nodejs-" + appTestName + " -o go-template='{{index .spec.port.targetPort}}'") + port := runCmdShouldPass("oc get route nodejs-" + appTestName + " -o go-template='{{index .spec.port.targetPort}}'") Expect(port).To(Equal("8080")) }) @@ -366,22 +368,22 @@ var _ = Describe("odoe2e", func() { // Check the labels in `oc get route` routeName := "nodejs-" + appTestName - getRouteLabel := runCmd("oc get route/" + routeName + " -o jsonpath='" + + getRouteLabel := runCmdShouldPass("oc get route/" + routeName + " -o jsonpath='" + "{.metadata.labels.app\\.kubernetes\\.io/component-name}'") Expect(getRouteLabel).To(Equal("nodejs")) }) It("should create route with required port", func() { - runCmd("odo create httpd httpd-test --git https://github.com/openshift/httpd-ex.git") - getURLOut := runCmd("odo url create example-url --port 8443") + runCmdShouldPass("odo create httpd httpd-test --git https://github.com/openshift/httpd-ex.git") + getURLOut := runCmdShouldPass("odo url create example-url --port 8443") Expect(getURLOut).To(ContainSubstring("example-url-" + appTestName + "-" + projName)) // check the port number of the created URL - port := runCmd("oc get route example-url-" + appTestName + " -o go-template='{{index .spec.port.targetPort}}'") + port := runCmdShouldPass("oc get route example-url-" + appTestName + " -o go-template='{{index .spec.port.targetPort}}'") Expect(port).To(Equal("8443")) // delete the component - runCmd("odo delete httpd-test -f") + runCmdShouldPass("odo delete httpd-test -f") }) }) }) @@ -390,21 +392,21 @@ var _ = Describe("odoe2e", func() { Context("When push is made", func() { It("should push the changes", func() { // Switch to nodejs component - runCmd("odo component set nodejs") + runCmdShouldPass("odo component set nodejs") getRoute := getActiveElementFromCommandOutput("odo url list") curlRoute := waitForEqualCmd("curl -s "+getRoute+" | grep 'Welcome to your Node.js application on OpenShift' | wc -l | tr -d '\n'", "1", 10) if curlRoute { - grepBeforePush := runCmd("curl -s " + getRoute + " | grep 'Welcome to your Node.js application on OpenShift'") + grepBeforePush := runCmdShouldPass("curl -s " + getRoute + " | grep 'Welcome to your Node.js application on OpenShift'") log.Printf("Text before odo push: %s", strings.TrimSpace(grepBeforePush)) } // Make changes to the html file - runCmd("sed -i 's/Welcome to your Node.js application on OpenShift/Welcome to your Node.js on ODO/g' " + tmpDir + "/nodejs-ex/views/index.html") + runCmdShouldPass("sed -i 's/Welcome to your Node.js application on OpenShift/Welcome to your Node.js on ODO/g' " + tmpDir + "/nodejs-ex/views/index.html") // Push the changes - runCmd("odo push --local " + tmpDir + "/nodejs-ex") + runCmdShouldPass("odo push --local " + tmpDir + "/nodejs-ex") }) It("should reflect the changes pushed", func() { @@ -413,7 +415,7 @@ var _ = Describe("odoe2e", func() { curlRoute := waitForEqualCmd("curl -s "+getRoute+" | grep -i odo | wc -l | tr -d '\n'", "1", 10) if curlRoute { - grepAfterPush := runCmd("curl -s " + getRoute + " | grep -i odo") + grepAfterPush := runCmdShouldPass("curl -s " + getRoute + " | grep -i odo") log.Printf("Text after odo push: %s", strings.TrimSpace(grepAfterPush)) Expect(grepAfterPush).To(ContainSubstring("ODO")) } @@ -421,16 +423,16 @@ var _ = Describe("odoe2e", func() { It("should be able to create the url with same name in different application", func() { appTestName_new := appTestName + "-1" - runCmd("odo app create " + appTestName_new) - runCmd("odo create nodejs nodejs-1 --git https://github.com/sclorg/nodejs-ex") - runCmd("odo url create nodejs --port 8080") + runCmdShouldPass("odo app create " + appTestName_new) + runCmdShouldPass("odo create nodejs nodejs-1 --git https://github.com/sclorg/nodejs-ex") + runCmdShouldPass("odo url create nodejs --port 8080") getRoute := getActiveElementFromCommandOutput("odo url list") Expect(getRoute).To(ContainSubstring("nodejs-" + appTestName_new + "-" + projName)) // Check the labels in `oc get route` routeName := "nodejs-" + appTestName_new - getRouteLabel := runCmd("oc get route/" + routeName + " -o jsonpath='" + + getRouteLabel := runCmdShouldPass("oc get route/" + routeName + " -o jsonpath='" + "{.metadata.labels.app\\.kubernetes\\.io/component-name}'") Expect(getRouteLabel).To(Equal("nodejs-1")) }) @@ -438,15 +440,15 @@ var _ = Describe("odoe2e", func() { // Check if url is deleted It("should be able to delete the url added", func() { appTestName_new := appTestName + "-1" - runCmd("odo app set " + appTestName_new) - runCmd("odo component set nodejs-1") - runCmd("odo url delete nodejs -f") + runCmdShouldPass("odo app set " + appTestName_new) + runCmdShouldPass("odo component set nodejs-1") + runCmdShouldPass("odo url delete nodejs -f") getRoute := getActiveElementFromCommandOutput("odo url list") Expect(getRoute).NotTo(ContainSubstring("nodejs-1-" + appTestName_new + "-" + projName)) - runCmd("odo delete -f") - runCmd("odo app delete " + appTestName_new + " -f") + runCmdShouldPass("odo delete -f") + runCmdShouldPass("odo app delete " + appTestName_new + " -f") }) }) @@ -456,21 +458,21 @@ var _ = Describe("odoe2e", func() { Context("when storage is added", func() { It("should default to active component when no component name is passed", func() { - runCmd("odo app set " + appTestName) - runCmd("odo component set nodejs") + runCmdShouldPass("odo app set " + appTestName) + runCmdShouldPass("odo component set nodejs") - storAdd := runCmd("odo storage create pv1 --path /mnt/pv1 --size 5Gi") + storAdd := runCmdShouldPass("odo storage create pv1 --path /mnt/pv1 --size 5Gi") Expect(storAdd).To(ContainSubstring("nodejs")) // Check against path and name against dc - getDc := runCmd("oc get dc/nodejs-" + appTestName + " -o go-template='" + + getDc := runCmdShouldPass("oc get dc/nodejs-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.containers}}" + "{{range .volumeMounts}}{{.name}}{{end}}{{end}}'") Expect(getDc).To(ContainSubstring("pv1")) // Check if the storage is added on the path provided - getMntPath := runCmd("oc get dc/nodejs-" + appTestName + " -o go-template='" + + getMntPath := runCmdShouldPass("oc get dc/nodejs-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.containers}}" + "{{range .volumeMounts}}{{.mountPath}} {{end}}{{end}}'") @@ -478,25 +480,25 @@ var _ = Describe("odoe2e", func() { }) It("should be able to list the storage added", func() { - storList := runCmd("odo storage list") + storList := runCmdShouldPass("odo storage list") Expect(storList).To(ContainSubstring("pv1")) }) It("should be able add storage to a component specified", func() { - runCmd("odo storage create pv2 --path /mnt/pv2 --size 5Gi --component php") + runCmdShouldPass("odo storage create pv2 --path /mnt/pv2 --size 5Gi --component php") - storList := runCmd("odo storage list --component php") + storList := runCmdShouldPass("odo storage list --component php") Expect(storList).To(ContainSubstring("pv2")) // Verify with deploymentconfig - getDc := runCmd("oc get dc/php-" + appTestName + " -o go-template='" + + getDc := runCmdShouldPass("oc get dc/php-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.containers}}" + "{{range .volumeMounts}}{{.name}}{{end}}{{end}}'") Expect(getDc).To(ContainSubstring("pv2")) // Check if the storage is added on the path provided - getMntPath := runCmd("oc get dc/php-" + appTestName + " -o go-template='" + + getMntPath := runCmdShouldPass("oc get dc/php-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.containers}}" + "{{range .volumeMounts}}{{.mountPath}} {{end}}{{end}}'") @@ -504,24 +506,24 @@ var _ = Describe("odoe2e", func() { }) It("should be able to list all storage in all components", func() { - storList := runCmd("odo storage list --all") + storList := runCmdShouldPass("odo storage list --all") Expect(storList).To(ContainSubstring("pv1")) Expect(storList).To(ContainSubstring("pv2")) }) // TODO: Verify if the storage removed using odo deletes pvc It("should be able to delete the storage added", func() { - runCmd("odo storage delete pv1 -f") + runCmdShouldPass("odo storage delete pv1 -f") - storList := runCmd("odo storage list") + storList := runCmdShouldPass("odo storage list") Expect(storList).NotTo(ContainSubstring("pv1")) }) It("should be able to unmount the storage using the storage name", func() { - runCmd("odo storage unmount pv2 --component php") + runCmdShouldPass("odo storage unmount pv2 --component php") // Verify with deploymentconfig - getDc := runCmd("oc get dc/php-" + appTestName + " -o go-template='" + + getDc := runCmdShouldPass("oc get dc/php-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.containers}}" + "{{range .volumeMounts}}{{.name}}{{end}}{{end}}'") @@ -529,17 +531,17 @@ var _ = Describe("odoe2e", func() { }) It("should be able to mount the storage to the path specified", func() { - runCmd("odo storage mount pv2 --path /mnt/pv2 --component php") + runCmdShouldPass("odo storage mount pv2 --path /mnt/pv2 --component php") // Verify with deploymentconfig - getDc := runCmd("oc get dc/php-" + appTestName + " -o go-template='" + + getDc := runCmdShouldPass("oc get dc/php-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.containers}}" + "{{range .volumeMounts}}{{.name}}{{end}}{{end}}'") Expect(getDc).To(ContainSubstring("pv2")) // Check if the storage is added on the path provided - getMntPath := runCmd("oc get dc/php-" + appTestName + " -o go-template='" + + getMntPath := runCmdShouldPass("oc get dc/php-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.containers}}" + "{{range .volumeMounts}}{{.mountPath}} {{end}}{{end}}'") @@ -547,10 +549,10 @@ var _ = Describe("odoe2e", func() { }) It("should be able to unmount the storage", func() { - runCmd("odo storage unmount /mnt/pv2 --component php") + runCmdShouldPass("odo storage unmount /mnt/pv2 --component php") // Verify with deploymentconfig - getDc := runCmd("oc get dc/php-" + appTestName + " -o go-template='" + + getDc := runCmdShouldPass("oc get dc/php-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.containers}}" + "{{range .volumeMounts}}{{.name}}{{end}}{{end}}'") @@ -561,19 +563,19 @@ var _ = Describe("odoe2e", func() { Context("deploying a component with a specific image name", func() { It("should deploy the component", func() { - runCmd("odo create nodejs:latest testversioncmp") + runCmdShouldPass("odo create nodejs:latest testversioncmp") }) It("should delete the deployed image-specific component", func() { - runCmd("odo delete testversioncmp") + runCmdShouldPass("odo delete testversioncmp") }) }) Context("deleting the application", func() { // Check if url is deleted It("should be able to delete the url added to the component", func() { - runCmd("odo component set nodejs") - runCmd("odo url delete nodejs -f") + runCmdShouldPass("odo component set nodejs") + runCmdShouldPass("odo url delete nodejs -f") urlList := getActiveElementFromCommandOutput("odo url list") Expect(urlList).NotTo(ContainSubstring("nodejs")) @@ -581,25 +583,25 @@ var _ = Describe("odoe2e", func() { It("should delete application and component", func() { - runCmd("odo app delete " + appTestName + " -f") + runCmdShouldPass("odo app delete " + appTestName + " -f") - appGet := runCmd("odo app get --short") + appGet := runCmdShouldPass("odo app get --short") Expect(appGet).NotTo(ContainSubstring(appTestName)) - appList := runCmd("odo app list") + appList := runCmdShouldPass("odo app list") Expect(appList).NotTo(ContainSubstring(appTestName)) - cmpList := runCmd("odo list") + cmpList := runCmdShouldPass("odo list") Expect(cmpList).NotTo(ContainSubstring("nodejs")) - runCmd("odo project delete " + projName + " -f") + runCmdShouldPass("odo project delete " + projName + " -f") waitForDeleteCmd("odo project list", projName) }) }) Context("validate odo version cmd with other major components version", func() { It("should show the version of odo major components", func() { - odoVersion := runCmd("odo version") + odoVersion := runCmdShouldPass("odo version") reOdoVersion := regexp.MustCompile(`^odo\s*v[0-9]+.[0-9]+.[0-9]+\s*\(\w+\)`) odoVersionStringMatch := reOdoVersion.MatchString(odoVersion) rekubernetesVersion := regexp.MustCompile(`Kubernetes:\s*v[0-9]+.[0-9]+.[0-9]+\+\w+`) @@ -609,7 +611,7 @@ var _ = Describe("odoe2e", func() { }) It("should show server login URL", func() { - odoVersion := runCmd("odo version") + odoVersion := runCmdShouldPass("odo version") reServerURL := regexp.MustCompile(`Server:\s*https:\/\/([0-9]+.){3}[0-9]+:8443`) serverURLStringMatch := reServerURL.MatchString(odoVersion) Expect(serverURLStringMatch).Should(BeTrue()) @@ -635,12 +637,12 @@ var _ = Describe("updateE2e", func() { Describe("creating the project", func() { Context("odo project", func() { It("should create a new project", func() { - session := runCmd("odo project create " + projName + "-1") + session := runCmdShouldPass("odo project create " + projName + "-1") Expect(session).To(ContainSubstring(projName)) }) It("should get the project", func() { - getProj := runCmd("odo project get --short") + getProj := runCmdShouldPass("odo project get --short") Expect(strings.TrimSpace(getProj)).To(Equal(projName + "-1")) }) }) @@ -649,7 +651,7 @@ var _ = Describe("updateE2e", func() { Describe("creating an application", func() { Context("when application by the same name doesn't exist", func() { It("should create an application", func() { - appName := runCmd("odo app create " + appTestName) + appName := runCmdShouldPass("odo app create " + appTestName) Expect(appName).To(ContainSubstring(appTestName)) }) }) @@ -657,41 +659,41 @@ var _ = Describe("updateE2e", func() { Context("updating the component", func() { It("should be able to create binary component", func() { - runCmd("curl -L -o " + tmpDir + "/sample-binary-testing-1.war " + + runCmdShouldPass("curl -L -o " + tmpDir + "/sample-binary-testing-1.war " + "https://gist.github.com/mik-dass/f95bd818ddba508ff76a386f8d984909/raw/e5bc575ac8b14ba2b23d66b5cb4873657e1a1489/sample.war") - runCmd("odo create wildfly --binary " + tmpDir + "/sample-binary-testing-1.war --env key=value,key1=value1") - cmpList := runCmd("odo list") + runCmdShouldPass("odo create wildfly --binary " + tmpDir + "/sample-binary-testing-1.war --env key=value,key1=value1") + cmpList := runCmdShouldPass("odo list") Expect(cmpList).To(ContainSubstring("wildfly")) - runCmd("oc get dc") - runCmd("oc get bc") + runCmdShouldPass("oc get dc") + runCmdShouldPass("oc get bc") }) It("should update component from binary to binary", func() { - runCmd("curl -L -o " + tmpDir + "/sample-binary-testing-2.war " + + runCmdShouldPass("curl -L -o " + tmpDir + "/sample-binary-testing-2.war " + "'https://gist.github.com/mik-dass/f95bd818ddba508ff76a386f8d984909/raw/85354d9ee8583a9c1e64a331425eede235b07a9e/sample%2520(1).war'") waitForDCOfComponentToRolloutCompletely("wildfly") - runCmd("odo update wildfly --binary " + tmpDir + "/sample-binary-testing-2.war") + runCmdShouldPass("odo update wildfly --binary " + tmpDir + "/sample-binary-testing-2.war") // checking bc for updates - getBc := runCmd("oc get bc wildfly-" + appTestName + " -o go-template={{.spec.source.git.uri}}") + getBc := runCmdShouldPass("oc get bc wildfly-" + appTestName + " -o go-template={{.spec.source.git.uri}}") Expect(getBc).To(Equal(bootStrapSupervisorURI)) // checking for init containers - getDc := runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc := runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.initContainers}}" + "{{.name}}{{end}}'") Expect(getDc).To(ContainSubstring(initContainerName)) // checking for volumes - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.volumes}}" + "{{.name}}{{end}}'") Expect(getDc).To(ContainSubstring("wildfly" + appRootVolumeName)) // checking for volumes mounts - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.containers}}{{range .volumeMounts}}{{.name}}" + "{{.name}}{{end}}{{end}}'") Expect(getDc).To(ContainSubstring("wildfly" + appRootVolumeName)) @@ -701,30 +703,30 @@ var _ = Describe("updateE2e", func() { }) It("should update component from binary to local", func() { - runCmd("git clone " + wildflyURI1 + " " + + runCmdShouldPass("git clone " + wildflyURI1 + " " + tmpDir + "/katacoda-odo-backend-1") waitForDCOfComponentToRolloutCompletely("wildfly") - runCmd("odo update wildfly --local " + tmpDir + "/katacoda-odo-backend-1") + runCmdShouldPass("odo update wildfly --local " + tmpDir + "/katacoda-odo-backend-1") // checking bc for updates - getBc := runCmd("oc get bc wildfly-" + appTestName + " -o go-template={{.spec.source.git.uri}}") + getBc := runCmdShouldPass("oc get bc wildfly-" + appTestName + " -o go-template={{.spec.source.git.uri}}") Expect(getBc).To(Equal(bootStrapSupervisorURI)) // checking for init containers - getDc := runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc := runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.initContainers}}" + "{{.name}}{{end}}'") Expect(getDc).To(ContainSubstring(initContainerName)) // checking for volumes - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.volumes}}" + "{{.name}}{{end}}'") Expect(getDc).To(ContainSubstring("wildfly" + appRootVolumeName)) // checking for volumes mounts - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.containers}}{{range .volumeMounts}}{{.name}}" + "{{.name}}{{end}}{{end}}'") Expect(getDc).To(ContainSubstring("wildfly" + appRootVolumeName)) @@ -734,30 +736,30 @@ var _ = Describe("updateE2e", func() { }) It("should update component from local to local", func() { - runCmd("git clone " + wildflyURI2 + " " + + runCmdShouldPass("git clone " + wildflyURI2 + " " + tmpDir + "/katacoda-odo-backend-2") waitForDCOfComponentToRolloutCompletely("wildfly") - runCmd("odo update wildfly --local " + tmpDir + "/katacoda-odo-backend-2") + runCmdShouldPass("odo update wildfly --local " + tmpDir + "/katacoda-odo-backend-2") // checking bc for updates - getBc := runCmd("oc get bc wildfly-" + appTestName + " -o go-template={{.spec.source.git.uri}}") + getBc := runCmdShouldPass("oc get bc wildfly-" + appTestName + " -o go-template={{.spec.source.git.uri}}") Expect(getBc).To(Equal(bootStrapSupervisorURI)) // checking for init containers - getDc := runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc := runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.initContainers}}" + "{{.name}}{{end}}'") Expect(getDc).To(ContainSubstring(initContainerName)) // checking for volumes - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.volumes}}" + "{{.name}}{{end}}'") Expect(getDc).To(ContainSubstring("wildfly" + appRootVolumeName)) // checking for volumes mounts - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.containers}}{{range .volumeMounts}}{{.name}}" + "{{.name}}{{end}}{{end}}'") Expect(getDc).To(ContainSubstring("wildfly" + appRootVolumeName)) @@ -768,26 +770,26 @@ var _ = Describe("updateE2e", func() { It("should update component from local to git", func() { waitForDCOfComponentToRolloutCompletely("wildfly") - runCmd("odo update wildfly --git " + wildflyURI1) + runCmdShouldPass("odo update wildfly --git " + wildflyURI1) // checking bc for updates - getBc := runCmd("oc get bc wildfly-" + appTestName + " -o go-template={{.spec.source.git.uri}}") + getBc := runCmdShouldPass("oc get bc wildfly-" + appTestName + " -o go-template={{.spec.source.git.uri}}") Expect(getBc).To(Equal(wildflyURI1)) // checking for init containers - getDc := runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc := runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.initContainers}}" + "{{.name}}{{end}}'") Expect(getDc).NotTo(ContainSubstring(initContainerName)) // checking for volumes - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.volumes}}" + "{{.name}}{{end}}'") Expect(getDc).NotTo(ContainSubstring("wildfly" + appRootVolumeName)) // checking for volumes mounts - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.containers}}{{range .volumeMounts}}{{.name}}" + "{{.name}}{{end}}{{end}}'") Expect(getDc).NotTo(ContainSubstring("wildfly" + appRootVolumeName)) @@ -798,26 +800,26 @@ var _ = Describe("updateE2e", func() { It("should update component from git to git", func() { waitForDCOfComponentToRolloutCompletely("wildfly") - runCmd("odo update wildfly --git " + wildflyURI2) + runCmdShouldPass("odo update wildfly --git " + wildflyURI2) // checking bc for updates - getBc := runCmd("oc get bc wildfly-" + appTestName + " -o go-template={{.spec.source.git.uri}}") + getBc := runCmdShouldPass("oc get bc wildfly-" + appTestName + " -o go-template={{.spec.source.git.uri}}") Expect(getBc).To(Equal(wildflyURI2)) // checking for init containers - getDc := runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc := runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.initContainers}}" + "{{.name}}{{end}}'") Expect(getDc).NotTo(ContainSubstring(initContainerName)) // checking for volumes - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.volumes}}" + "{{.name}}{{end}}'") Expect(getDc).NotTo(ContainSubstring("wildfly" + appRootVolumeName)) // checking for volumes mounts - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.containers}}{{range .volumeMounts}}{{.name}}" + "{{.name}}{{end}}{{end}}'") Expect(getDc).NotTo(ContainSubstring("wildfly" + appRootVolumeName)) @@ -828,26 +830,26 @@ var _ = Describe("updateE2e", func() { It("should update component from git to binary", func() { waitForDCOfComponentToRolloutCompletely("wildfly") - runCmd("odo update wildfly --binary " + tmpDir + "/sample-binary-testing-1.war") + runCmdShouldPass("odo update wildfly --binary " + tmpDir + "/sample-binary-testing-1.war") // checking bc for updates - getBc := runCmd("oc get bc wildfly-" + appTestName + " -o go-template={{.spec.source.git.uri}}") + getBc := runCmdShouldPass("oc get bc wildfly-" + appTestName + " -o go-template={{.spec.source.git.uri}}") Expect(getBc).To(Equal(bootStrapSupervisorURI)) // checking for init containers - getDc := runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc := runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.initContainers}}" + "{{.name}}{{end}}'") Expect(getDc).To(ContainSubstring(initContainerName)) // checking for volumes - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.volumes}}" + "{{.name}}{{end}}'") Expect(getDc).To(ContainSubstring("wildfly" + appRootVolumeName)) // checking for volumes mounts - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.containers}}{{range .volumeMounts}}{{.name}}" + "{{.name}}{{end}}{{end}}'") Expect(getDc).To(ContainSubstring("wildfly" + appRootVolumeName)) @@ -858,26 +860,26 @@ var _ = Describe("updateE2e", func() { It("should update component from binary to git", func() { waitForDCOfComponentToRolloutCompletely("wildfly") - runCmd("odo update wildfly --git " + wildflyURI1) + runCmdShouldPass("odo update wildfly --git " + wildflyURI1) // checking bc for updates - getBc := runCmd("oc get bc wildfly-" + appTestName + " -o go-template={{.spec.source.git.uri}}") + getBc := runCmdShouldPass("oc get bc wildfly-" + appTestName + " -o go-template={{.spec.source.git.uri}}") Expect(getBc).To(Equal(wildflyURI1)) // checking for init containers - getDc := runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc := runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.initContainers}}" + "{{.name}}{{end}}'") Expect(getDc).NotTo(ContainSubstring(initContainerName)) // checking for volumes - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.volumes}}" + "{{.name}}{{end}}'") Expect(getDc).NotTo(ContainSubstring("wildfly" + appRootVolumeName)) // checking for volumes mounts - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.containers}}{{range .volumeMounts}}{{.name}}" + "{{.name}}{{end}}{{end}}'") Expect(getDc).NotTo(ContainSubstring("wildfly" + appRootVolumeName)) @@ -888,26 +890,26 @@ var _ = Describe("updateE2e", func() { It("should update component from git to local", func() { waitForDCOfComponentToRolloutCompletely("wildfly") - runCmd("odo update wildfly --local " + tmpDir + "/katacoda-odo-backend-1") + runCmdShouldPass("odo update wildfly --local " + tmpDir + "/katacoda-odo-backend-1") // checking bc for updates - getBc := runCmd("oc get bc wildfly-" + appTestName + " -o go-template={{.spec.source.git.uri}}") + getBc := runCmdShouldPass("oc get bc wildfly-" + appTestName + " -o go-template={{.spec.source.git.uri}}") Expect(getBc).To(Equal(bootStrapSupervisorURI)) // checking for init containers - getDc := runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc := runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.initContainers}}" + "{{.name}}{{end}}'") Expect(getDc).To(ContainSubstring(initContainerName)) // checking for volumes - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.volumes}}" + "{{.name}}{{end}}'") Expect(getDc).To(ContainSubstring("wildfly" + appRootVolumeName)) // checking for volumes mounts - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.containers}}{{range .volumeMounts}}{{.name}}" + "{{.name}}{{end}}{{end}}'") Expect(getDc).To(ContainSubstring("wildfly" + appRootVolumeName)) @@ -918,26 +920,26 @@ var _ = Describe("updateE2e", func() { It("should update component from local to binary", func() { waitForDCOfComponentToRolloutCompletely("wildfly") - runCmd("odo update wildfly --binary " + tmpDir + "/sample-binary-testing-1.war") + runCmdShouldPass("odo update wildfly --binary " + tmpDir + "/sample-binary-testing-1.war") // checking bc for updates - getBc := runCmd("oc get bc wildfly-" + appTestName + " -o go-template={{.spec.source.git.uri}}") + getBc := runCmdShouldPass("oc get bc wildfly-" + appTestName + " -o go-template={{.spec.source.git.uri}}") Expect(getBc).To(Equal(bootStrapSupervisorURI)) // checking for init containers - getDc := runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc := runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.initContainers}}" + "{{.name}}{{end}}'") Expect(getDc).To(ContainSubstring(initContainerName)) // checking for volumes - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.volumes}}" + "{{.name}}{{end}}'") Expect(getDc).To(ContainSubstring("wildfly" + appRootVolumeName)) // checking for volumes mounts - getDc = runCmd("oc get dc wildfly-" + appTestName + " -o go-template='" + + getDc = runCmdShouldPass("oc get dc wildfly-" + appTestName + " -o go-template='" + "{{range .spec.template.spec.containers}}{{range .volumeMounts}}{{.name}}" + "{{.name}}{{end}}{{end}}'") Expect(getDc).To(ContainSubstring("wildfly" + appRootVolumeName)) @@ -948,31 +950,32 @@ var _ = Describe("updateE2e", func() { }) Context("odo login", func() { It("should login with username and password", func() { - runCmd("oc logout") - runCmd("odo login --username developer --password developer") - userName := runCmd("oc whoami") + runCmdShouldPass("oc logout") + runCmdShouldPass("odo login --username developer --password developer") + userName := runCmdShouldPass("oc whoami") Expect(userName).To(ContainSubstring("developer")) }) It("should login with token", func() { - userToken := runCmd("oc whoami -t") - runCmd("oc logout") - runCmd("odo login -t" + userToken) - token := runCmd("oc whoami -t") + userToken := runCmdShouldPass("oc whoami -t") + runCmdShouldPass("oc logout") + runCmdShouldPass("odo login -t" + userToken) + token := runCmdShouldPass("oc whoami -t") Expect(token).To(ContainSubstring(userToken)) }) }) Context("logout of the cluster", func() { // test for odo logout It("should logout the user from the cluster", func() { - logoutMsg := runCmd("odo logout") + logoutMsg := runCmdShouldPass("odo logout") Expect(logoutMsg).To(ContainSubstring("Logged")) Expect(logoutMsg).To(ContainSubstring("out on")) // validate using oc whoami - runFailCmd("oc whoami", 1) + outputErr := runCmdShouldFail("oc whoami") + Expect(outputErr).To(ContainSubstring("cannot get users.user.openshift.io at the cluster scope")) }) - It("should throw error if user is not logged in", func() { - logoutMsg := runFailCmd("odo logout", 1) - Expect(logoutMsg).To(Equal("Please log in to the cluster\n")) + It("Logout should throw error if user is not logged in", func() { + logoutErrMsg := runCmdShouldFail("odo logout") + Expect(logoutErrMsg).To(Equal("Please log in to the cluster\n")) }) }) }) diff --git a/tests/e2e/java_test.go b/tests/e2e/java_test.go index ddd402f6e04..b747e48c0ed 100644 --- a/tests/e2e/java_test.go +++ b/tests/e2e/java_test.go @@ -23,7 +23,7 @@ var _ = Describe("odoJavaE2e", func() { // Create a separate project for Java Context("create java project", func() { It("should create a new java project", func() { - session := runCmd("odo project create " + projName) + session := runCmdShouldPass("odo project create " + projName) Expect(session).To(ContainSubstring(projName)) }) }) @@ -33,21 +33,21 @@ var _ = Describe("odoJavaE2e", func() { It("Should be able to deploy a git repo that contains a wildfly application", func() { // Deploy the git repo / wildfly example - cmpCreateLog := runCmd("odo create wildfly javaee-git-test --git " + warGitRepo + " -w") + cmpCreateLog := runCmdShouldPass("odo create wildfly javaee-git-test --git " + warGitRepo + " -w") Expect(cmpCreateLog).ShouldNot(ContainSubstring("This may take few moments to be ready")) - buildName := runCmd("oc get builds --output='name' | grep javaee-git-test | cut -d '/' -f 2") + buildName := runCmdShouldPass("oc get builds --output='name' | grep javaee-git-test | cut -d '/' -f 2") Expect(buildName).To(ContainSubstring("javaee-git-test")) - buildStatus := runCmd("oc get build " + buildName) + buildStatus := runCmdShouldPass("oc get build " + buildName) Expect(buildStatus).To(ContainSubstring("Complete")) - cmpList := runCmd("odo list") + cmpList := runCmdShouldPass("odo list") Expect(cmpList).To(ContainSubstring("javaee-git-test")) // Push changes - runCmd("odo push") + runCmdShouldPass("odo push") // Create a URL - runCmd("odo url create") + runCmdShouldPass("odo url create") routeURL := determineRouteURL() // Ping said URL @@ -55,39 +55,39 @@ var _ = Describe("odoJavaE2e", func() { Expect(pingValue).To(Equal(true)) // Delete the component - runCmd("odo delete javaee-git-test -f") + runCmdShouldPass("odo delete javaee-git-test -f") }) It("Should be able to deploy a git repo that contains a wildfly application without wait flag", func() { // Deploy the git repo / wildfly example - cmpCreateLog := runCmd("odo create wildfly wo-wait-javaee-git-test --git " + warGitRepo) + cmpCreateLog := runCmdShouldPass("odo create wildfly wo-wait-javaee-git-test --git " + warGitRepo) Expect(cmpCreateLog).Should(ContainSubstring("This may take few moments to be ready")) - buildName := runCmd("oc get builds --output='name' | grep wo-wait-javaee-git-test | cut -d '/' -f 2") + buildName := runCmdShouldPass("oc get builds --output='name' | grep wo-wait-javaee-git-test | cut -d '/' -f 2") Expect(buildName).To(ContainSubstring("wo-wait-javaee-git-test")) - buildStatus := runCmd("oc get builds | grep wo-wait-javaee-git-test") + buildStatus := runCmdShouldPass("oc get builds | grep wo-wait-javaee-git-test") Expect(buildStatus).To(ContainSubstring("Pending")) - dcName := runCmd("oc get dc | grep wo-wait-javaee-git-test | cut -f 1 -d ' '") + dcName := runCmdShouldPass("oc get dc | grep wo-wait-javaee-git-test | cut -f 1 -d ' '") // For waiting until the deployment starts for { time.Sleep(5 * time.Second) - dcStatus := runCmd("oc get dc |grep wo-wait-javaee-git-test | cut -f 4 -d ' '") + dcStatus := runCmdShouldPass("oc get dc |grep wo-wait-javaee-git-test | cut -f 4 -d ' '") if dcStatus == "1\n" { break } } // following the logs and waiting for the build to finish - _ = runCmd("oc logs --version=1 dc/" + dcName) + runCmdShouldPass("oc logs --version=1 dc/" + dcName) - cmpList := runCmd("odo list") + cmpList := runCmdShouldPass("odo list") Expect(cmpList).To(ContainSubstring("wo-wait-javaee-git-test")) // Push changes - runCmd("odo push") + runCmdShouldPass("odo push") // Create a URL - runCmd("odo url create") + runCmdShouldPass("odo url create") routeURL := determineRouteURL() // Ping said URL @@ -95,24 +95,24 @@ var _ = Describe("odoJavaE2e", func() { Expect(pingValue).To(Equal(true)) // Delete the component - runCmd("odo delete wo-wait-javaee-git-test -f") + runCmdShouldPass("odo delete wo-wait-javaee-git-test -f") }) It("Should be able to deploy a .war file using wildfly", func() { - cmpCreateLog := runCmd("odo create wildfly javaee-war-test --binary " + javaFiles + "/wildfly/ROOT.war -w") + cmpCreateLog := runCmdShouldPass("odo create wildfly javaee-war-test --binary " + javaFiles + "/wildfly/ROOT.war -w") Expect(cmpCreateLog).ShouldNot(ContainSubstring("This may take few moments to be ready")) - dcName := runCmd("oc get dc | grep javaee-war-test| cut -f 1 -d ' '") + dcName := runCmdShouldPass("oc get dc | grep javaee-war-test| cut -f 1 -d ' '") // Following the logs - _ = runCmd("oc logs --version=1 dc/" + dcName) + runCmdShouldPass("oc logs --version=1 dc/" + dcName) - cmpList := runCmd("odo list") + cmpList := runCmdShouldPass("odo list") Expect(cmpList).To(ContainSubstring("javaee-war-test")) // Push changes - runCmd("odo push") + runCmdShouldPass("odo push") // Create a URL - runCmd("odo url create") + runCmdShouldPass("odo url create") routeURL := determineRouteURL() // Ping said URL @@ -120,28 +120,28 @@ var _ = Describe("odoJavaE2e", func() { Expect(pingValue).To(Equal(true)) // Delete the component - runCmd("odo delete javaee-war-test -f") + runCmdShouldPass("odo delete javaee-war-test -f") }) It("Should be able to deploy a git repo that contains a java uberjar application using openjdk", func() { importOpenJDKImage() // Deploy the git repo / wildfly example - cmpCreateLog := runCmd("odo create openjdk18 uberjar-git-test --git " + jarGitRepo + " -w") + cmpCreateLog := runCmdShouldPass("odo create openjdk18 uberjar-git-test --git " + jarGitRepo + " -w") Expect(cmpCreateLog).ShouldNot(ContainSubstring("This may take few moments to be ready")) - buildName := runCmd("oc get builds --output='name' | grep uberjar-git-test | cut -d '/' -f 2") + buildName := runCmdShouldPass("oc get builds --output='name' | grep uberjar-git-test | cut -d '/' -f 2") Expect(buildName).To(ContainSubstring("uberjar-git-test")) - buildStatus := runCmd("oc get build " + buildName) + buildStatus := runCmdShouldPass("oc get build " + buildName) Expect(buildStatus).To(ContainSubstring("Complete")) - cmpList := runCmd("odo list") + cmpList := runCmdShouldPass("odo list") Expect(cmpList).To(ContainSubstring("uberjar-git-test")) // Push changes - runCmd("odo push") + runCmdShouldPass("odo push") // Create a URL - runCmd("odo url create --port 8080") + runCmdShouldPass("odo url create --port 8080") routeURL := determineRouteURL() // Ping said URL @@ -149,26 +149,26 @@ var _ = Describe("odoJavaE2e", func() { Expect(pingValue).To(Equal(true)) // Delete the component - runCmd("odo delete uberjar-git-test -f") + runCmdShouldPass("odo delete uberjar-git-test -f") }) It("Should be able to deploy a spring boot uberjar file using openjdk", func() { importOpenJDKImage() - cmpCreateLog := runCmd("odo create openjdk18 sb-jar-test --binary " + javaFiles + "/openjdk/sb.jar -w") + cmpCreateLog := runCmdShouldPass("odo create openjdk18 sb-jar-test --binary " + javaFiles + "/openjdk/sb.jar -w") Expect(cmpCreateLog).ShouldNot(ContainSubstring("This may take few moments to be ready")) - dcName := runCmd("oc get dc | grep sb-jar-test| cut -f 1 -d ' '") + dcName := runCmdShouldPass("oc get dc | grep sb-jar-test| cut -f 1 -d ' '") Expect(dcName).To(ContainSubstring("sb-jar-test")) - cmpList := runCmd("odo list") + cmpList := runCmdShouldPass("odo list") Expect(cmpList).To(ContainSubstring("sb-jar-test")) // Push changes - runCmd("odo push") + runCmdShouldPass("odo push") // Create a URL - runCmd("odo url create --port 8080") + runCmdShouldPass("odo url create --port 8080") routeURL := determineRouteURL() // Ping said URL @@ -176,7 +176,7 @@ var _ = Describe("odoJavaE2e", func() { Expect(pingValue).To(Equal(true)) // Delete the component - runCmd("odo delete sb-jar-test -f") + runCmdShouldPass("odo delete sb-jar-test -f") }) }) @@ -184,7 +184,7 @@ var _ = Describe("odoJavaE2e", func() { // Delete the project Context("java project delete", func() { It("should delete java project", func() { - session := runCmd("odo project delete " + projName + " -f") + session := runCmdShouldPass("odo project delete " + projName + " -f") Expect(session).To(ContainSubstring(projName)) }) }) @@ -192,6 +192,6 @@ var _ = Describe("odoJavaE2e", func() { func importOpenJDKImage() { // we need to import the openjdk image which is used for jars because it's not available by default - runCmd("oc import-image openjdk18 --from=registry.access.redhat.com/redhat-openjdk-18/openjdk18-openshift:1.5 --confirm") - runCmd("oc annotate istag/openjdk18:latest tags=builder --overwrite") + runCmdShouldPass("oc import-image openjdk18 --from=registry.access.redhat.com/redhat-openjdk-18/openjdk18-openshift:1.5 --confirm") + runCmdShouldPass("oc annotate istag/openjdk18:latest tags=builder --overwrite") } diff --git a/tests/e2e/json_test.go b/tests/e2e/json_test.go index 318de3560af..b390b6b9639 100644 --- a/tests/e2e/json_test.go +++ b/tests/e2e/json_test.go @@ -14,23 +14,23 @@ var _ = Describe("odojsonoutput", func() { Context("odo machine readable output", func() { // // Basic creation It("Pre-Test Creation", func() { - runCmd("odo project create json-test") - runCmd("odo app create myapp") - runCmd("odo create nodejs nodejs --git https://github.com/openshift/nodejs-ex") - runCmd("odo url create myurl") - runCmd("odo storage create mystorage --path=/opt/app-root/src/storage/ --size=1Gi") + runCmdShouldPass("odo project create json-test") + runCmdShouldPass("odo app create myapp") + runCmdShouldPass("odo create nodejs nodejs --git https://github.com/openshift/nodejs-ex") + runCmdShouldPass("odo url create myurl") + runCmdShouldPass("odo storage create mystorage --path=/opt/app-root/src/storage/ --size=1Gi") }) // odo app describe myapp -o json It("should be able to describe app", func() { desired := `{"kind":"app","apiVersion":"odo.openshift.io/v1alpha1","metadata":{"name":"myapp","namespace":"json-test","creationTimestamp":null},"spec":{"components":["nodejs"]},"status":{"active":true}}` - actual := runCmd("odo app describe myapp -o json") + actual := runCmdShouldPass("odo app describe myapp -o json") areEqual, _ := compareJSON(desired, actual) Expect(areEqual).To(BeTrue()) }) // odo app list -o json It("should be able to list the apps", func() { - actual := runCmd("odo app list -o json") + actual := runCmdShouldPass("odo app list -o json") desired := `{"kind":"List","apiVersion":"odo.openshift.io/v1alpha1","metadata":{},"items":[{"kind":"app","apiVersion":"odo.openshift.io/v1alpha1","metadata":{"name":"myapp","namespace":"json-test","creationTimestamp":null},"spec":{"components":["nodejs"]},"status":{"active":true}}]}` areEqual, _ := compareJSON(desired, actual) Expect(areEqual).To(BeTrue()) @@ -38,14 +38,14 @@ var _ = Describe("odojsonoutput", func() { }) // odo describe nodejs -o json It("should be able to describe component", func() { - actual := runCmd("odo describe nodejs -o json") + actual := runCmdShouldPass("odo describe nodejs -o json") desired := `{"kind":"Component","apiVersion":"odo.openshift.io/v1alpha1","metadata":{"name":"nodejs","creationTimestamp":null},"spec":{"type":"nodejs","source":"https://github.com/openshift/nodejs-ex","url":["myurl"],"storage":["mystorage"]},"status":{"active":true}}` areEqual, _ := compareJSON(desired, actual) Expect(areEqual).To(BeTrue()) }) // odo list -o json It("should be able to list components", func() { - actual := runCmd("odo list -o json") + actual := runCmdShouldPass("odo list -o json") desired := `{"kind":"List","apiVersion":"odo.openshift.io/v1alpha1","metadata":{},"items":[{"kind":"Component","apiVersion":"odo.openshift.io/v1alpha1","metadata":{"name":"nodejs","creationTimestamp":null},"spec":{"type":"nodejs","source":"https://github.com/openshift/nodejs-ex","url":["myurl"],"storage":["mystorage"]},"status":{"active":true}}]}` areEqual, _ := compareJSON(desired, actual) Expect(areEqual).To(BeTrue()) @@ -53,8 +53,8 @@ var _ = Describe("odojsonoutput", func() { }) // odo url list -o json It("should be able to list url", func() { - actual := runCmd("odo url list -o json") - url := runCmd("oc get routes myurl-myapp -o jsonpath={.spec.host}") + actual := runCmdShouldPass("odo url list -o json") + url := runCmdShouldPass("oc get routes myurl-myapp -o jsonpath={.spec.host}") desired := fmt.Sprintf(`{"kind":"List","apiVersion":"odo.openshift.io/v1alpha1","metadata":{},"items":[{"kind":"url","apiVersion":"odo.openshift.io/v1alpha1","metadata":{"name":"myurl","creationTimestamp":null},"spec":{"path":"%s","port":8080}}]}`, url) areEqual, _ := compareJSON(desired, actual) Expect(areEqual).To(BeTrue()) @@ -62,7 +62,7 @@ var _ = Describe("odojsonoutput", func() { }) // odo storage list -o json It("should be able to list storage", func() { - actual := runCmd("odo storage list -o json") + actual := runCmdShouldPass("odo storage list -o json") desired := `{"kind":"List","apiVersion":"odo.openshift.io/v1aplha1","metadata":{},"items":[{"kind":"Storage","apiVersion":"odo.openshift.io/v1alpha1","metadata":{"name":"mystorage","creationTimestamp":null},"spec":{"size":"1Gi","path":"/opt/app-root/src/storage/"},"status":{"mounted":true}}]}` areEqual, _ := compareJSON(desired, actual) @@ -71,7 +71,7 @@ var _ = Describe("odojsonoutput", func() { }) // cleanup It("Cleanup", func() { - runCmd("odo project delete json-test -f") + runCmdShouldPass("odo project delete json-test -f") }) }) diff --git a/tests/e2e/link_test.go b/tests/e2e/link_test.go index d5f289dd672..63aa1c45c54 100644 --- a/tests/e2e/link_test.go +++ b/tests/e2e/link_test.go @@ -1,9 +1,10 @@ package e2e import ( + "strings" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "strings" ) var _ = Describe("odoLinkE2e", func() { @@ -13,39 +14,39 @@ var _ = Describe("odoLinkE2e", func() { // Create a separate project for Java Context("create separate project", func() { It("should create a new test project", func() { - session := runCmd("odo project create " + projName) + session := runCmdShouldPass("odo project create " + projName) Expect(session).To(ContainSubstring(projName)) - runCmd("odo app create " + appTestName) + runCmdShouldPass("odo app create " + appTestName) }) }) Context("odo link/unlink handling between components and service", func() { It("create a frontend and backend application", func() { - runCmd("odo create nodejs frontend") - runCmd("odo create python backend") + runCmdShouldPass("odo create nodejs frontend") + runCmdShouldPass("odo create python backend") - cmpList := runCmd("odo list") + cmpList := runCmdShouldPass("odo list") Expect(cmpList).To(ContainSubstring("frontend")) Expect(cmpList).To(ContainSubstring("backend")) }) It("reports error when using wrong port", func() { - output := runFailCmd("odo link backend --component frontend --port 1234", 1) - Expect(output).To(ContainSubstring("8080")) + outputErr := runCmdShouldFail("odo link backend --component frontend --port 1234") + Expect(outputErr).To(ContainSubstring("8080")) }) It("link the frontend application to the backend", func() { - runCmd("odo link backend --component frontend") + runCmdShouldPass("odo link backend --component frontend") // ensure that the proper envFrom entry was created envFromOutput := - runCmd("oc get dc frontend-testing -o jsonpath='{.spec.template.spec.containers[0].envFrom}'") + runCmdShouldPass("oc get dc frontend-testing -o jsonpath='{.spec.template.spec.containers[0].envFrom}'") Expect(envFromOutput).To(ContainSubstring("backend")) }) It("describe on the frontend should show the linked backend component", func() { - describeOutput := runCmd("odo describe frontend") + describeOutput := runCmdShouldPass("odo describe frontend") // ensure that the output contains the component and port Expect(describeOutput).To(ContainSubstring("backend")) @@ -53,12 +54,12 @@ var _ = Describe("odoLinkE2e", func() { }) It("link should fail when linking to the same component again", func() { - output := runFailCmd("odo link backend --component frontend", 1) - Expect(output).To(ContainSubstring("been linked")) + outputErr := runCmdShouldFail("odo link backend --component frontend") + Expect(outputErr).To(ContainSubstring("been linked")) }) It("should be able to create a service", func() { - runCmd("odo service create mysql-persistent") + runCmdShouldPass("odo service create mysql-persistent") waitForCmdOut("oc get serviceinstance -o name", 1, func(output string) bool { return strings.Contains(output, "mysql-persistent") @@ -66,53 +67,53 @@ var _ = Describe("odoLinkE2e", func() { }) It("app describe should show the mysql service", func() { - describeOutput := runCmd("odo app describe") + describeOutput := runCmdShouldPass("odo app describe") // ensure that the output contains the service Expect(describeOutput).To(ContainSubstring("mysql-persistent")) }) It("should link backend to service", func() { - runCmd("odo link mysql-persistent -w --component backend") + runCmdShouldPass("odo link mysql-persistent -w --component backend") // ensure that the proper envFrom entry was created envFromOutput := - runCmd("oc get dc backend-testing -o jsonpath='{.spec.template.spec.containers[0].envFrom}'") + runCmdShouldPass("oc get dc backend-testing -o jsonpath='{.spec.template.spec.containers[0].envFrom}'") Expect(envFromOutput).To(ContainSubstring("mysql-persistent")) }) It("link should fail when linking to the same service again", func() { - output := runFailCmd("odo link mysql-persistent --component backend", 1) - Expect(output).To(ContainSubstring("been linked")) + outputErr := runCmdShouldFail("odo link mysql-persistent --component backend") + Expect(outputErr).To(ContainSubstring("been linked")) }) It("describe on the backend should show the linked mysql service", func() { - describeOutput := runCmd("odo describe backend") + describeOutput := runCmdShouldPass("odo describe backend") // ensure that the output contains the service Expect(describeOutput).To(ContainSubstring("mysql-persistent")) }) It("delete the service", func() { - runCmd("odo service delete mysql-persistent -f") + runCmdShouldPass("odo service delete mysql-persistent -f") // ensure that the backend no longer has an envFrom value backendEnvFromOutput := - runCmd("oc get dc backend-testing -o jsonpath='{.spec.template.spec.containers[0].envFrom}'") + runCmdShouldPass("oc get dc backend-testing -o jsonpath='{.spec.template.spec.containers[0].envFrom}'") Expect(backendEnvFromOutput).To(BeEmpty()) // ensure that the frontend envFrom was not changed frontEndEnvFromOutput := - runCmd("oc get dc frontend-testing -o jsonpath='{.spec.template.spec.containers[0].envFrom}'") + runCmdShouldPass("oc get dc frontend-testing -o jsonpath='{.spec.template.spec.containers[0].envFrom}'") Expect(frontEndEnvFromOutput).To(ContainSubstring("backend")) }) It("unlink the backend from the frontend", func() { - runCmd("odo unlink backend --component frontend") + runCmdShouldPass("odo unlink backend --component frontend") // ensure that the proper envFrom entry was created envFromOutput := - runCmd("oc get dc frontend-testing -o jsonpath='{.spec.template.spec.containers[0].envFrom}'") + runCmdShouldPass("oc get dc frontend-testing -o jsonpath='{.spec.template.spec.containers[0].envFrom}'") Expect(envFromOutput).To(BeEmpty()) }) }) @@ -120,7 +121,7 @@ var _ = Describe("odoLinkE2e", func() { // Delete the project Context("delete delete", func() { It("should delete test project", func() { - session := runCmd("odo project delete " + projName + " -f") + session := runCmdShouldPass("odo project delete " + projName + " -f") Expect(session).To(ContainSubstring(projName)) }) }) diff --git a/tests/e2e/login_test.go b/tests/e2e/login_test.go index f94bef5dadb..10dea655db2 100644 --- a/tests/e2e/login_test.go +++ b/tests/e2e/login_test.go @@ -22,40 +22,40 @@ var _ = Describe("odoLoginE2e", func() { Context("Initialize", func() { It("Should initialize some variables", func() { // Logout of current user to ensure state - runCmd("oc logout") + runCmdShouldPass("oc logout") }) }) Context("Run login tests with no active projects, having default is also considered as not having active project", func() { AfterEach(func() { // Logout of current user to ensure state - runCmd("oc logout") + runCmdShouldPass("oc logout") }) It("Should login successfully with username and password without any projects with appropriate message", func() { - session = runCmd(fmt.Sprintf("odo login -u %s -p %s", loginTestUserForNoProject, loginTestUserPassword)) + session = runCmdShouldPass(fmt.Sprintf("odo login -u %s -p %s", loginTestUserForNoProject, loginTestUserPassword)) Expect(session).To(ContainSubstring("Login successful")) Expect(session).To(ContainSubstring("You don't have any projects. You can try to create a new project, by running")) Expect(session).To(ContainSubstring("odo project create ")) - session = runCmd("oc whoami") + session = runCmdShouldPass("oc whoami") Expect(session).To(ContainSubstring(loginTestUserForNoProject)) // One initialization needs one login, hence it happens here - testUserToken = runCmd("oc whoami -t") + testUserToken = runCmdShouldPass("oc whoami -t") }) It("Should login successfully with token without any projects with appropriate message", func() { - session = runCmd(fmt.Sprintf("odo login -t %s", testUserToken)) + session = runCmdShouldPass(fmt.Sprintf("odo login -t %s", testUserToken)) Expect(session).To(ContainSubstring("Logged into")) Expect(session).To(ContainSubstring("You don't have any projects. You can try to create a new project, by running")) Expect(session).To(ContainSubstring("odo project create ")) - session = runCmd("oc whoami") + session = runCmdShouldPass("oc whoami") Expect(session).To(ContainSubstring(loginTestUserForNoProject)) }) It("Should fail login on invalid token with appropriate message", func() { - session = runFailCmd("odo login -t verybadtoken", 1) - Expect(session).To(ContainSubstring("The token provided is invalid or expired")) - runCmd(fmt.Sprintf("oc login --token %s", testUserToken)) + sessionErr := runCmdShouldFail("odo login -t verybadtoken") + Expect(sessionErr).To(ContainSubstring("The token provided is invalid or expired")) + runCmdShouldPass(fmt.Sprintf("oc login --token %s", testUserToken)) }) }) @@ -66,16 +66,16 @@ var _ = Describe("odoLoginE2e", func() { It("Should login successfully with username and password single project with appropriate message", func() { // Initialise for test - runCmd(fmt.Sprintf("oc login -u %s -p %s", loginTestUserForSingleProject1, loginTestUserPassword)) - runCmd(fmt.Sprintf("odo project create %s", odoTestProjectForSingleProject1)) + runCmdShouldPass(fmt.Sprintf("oc login -u %s -p %s", loginTestUserForSingleProject1, loginTestUserPassword)) + runCmdShouldPass(fmt.Sprintf("odo project create %s", odoTestProjectForSingleProject1)) //make sure that project has been created - runCmd("oc project") - runCmd("oc logout") + runCmdShouldPass("oc project") + runCmdShouldPass("oc logout") - session = runCmd(fmt.Sprintf("odo login -u %s -p %s", loginTestUserForSingleProject1, loginTestUserPassword)) + session = runCmdShouldPass(fmt.Sprintf("odo login -u %s -p %s", loginTestUserForSingleProject1, loginTestUserPassword)) Expect(session).To(ContainSubstring("Login successful")) Expect(session).To(ContainSubstring(odoTestProjectForSingleProject1)) - session = runCmd("oc whoami") + session = runCmdShouldPass("oc whoami") Expect(session).To(ContainSubstring(loginTestUserForSingleProject1)) }) }) diff --git a/tests/e2e/service_test.go b/tests/e2e/service_test.go index fe9f9b55774..c29edf70154 100644 --- a/tests/e2e/service_test.go +++ b/tests/e2e/service_test.go @@ -13,7 +13,7 @@ var _ = Describe("odoServiceE2e", func() { Context("odo service creation", func() { It("should be able to create a service", func() { - runCmd("odo service create mysql-persistent -w") + runCmdShouldPass("odo service create mysql-persistent -w") waitForCmdOut("oc get serviceinstance -o name", 1, func(output string) bool { return strings.Contains(output, "mysql-persistent") }) @@ -29,7 +29,7 @@ var _ = Describe("odoServiceE2e", func() { }) It("should be able to delete a service", func() { - runCmd("odo service delete mysql-persistent -f") + runCmdShouldPass("odo service delete mysql-persistent -f") cmd := serviceInstanceStatusCmd("mysql-persistent") waitForServiceStatusCmd(cmd, "Deprovisioning") }) @@ -41,7 +41,7 @@ var _ = Describe("odoServiceE2e", func() { } else { Context("odo service create with a spring boot application", func() { It("should be able to create postgresql", func() { - runCmd("odo service create dh-postgresql-apb --plan dev -p postgresql_user=luke -p postgresql_password=secret -p postgresql_database=my_data -p postgresql_version=9.6") + runCmdShouldPass("odo service create dh-postgresql-apb --plan dev -p postgresql_user=luke -p postgresql_password=secret -p postgresql_database=my_data -p postgresql_version=9.6") waitForCmdOut("oc get serviceinstance -o name", 1, func(output string) bool { return strings.Contains(output, "dh-postgresql-apb") }) @@ -50,17 +50,17 @@ var _ = Describe("odoServiceE2e", func() { It("Should be able to deploy an openjdk source application", func() { importOpenJDKImage() - runCmd("odo create openjdk18 sb-app --local " + sourceExamples + "/openjdk-sb-postgresql/") + runCmdShouldPass("odo create openjdk18 sb-app --local " + sourceExamples + "/openjdk-sb-postgresql/") // Push changes - runCmd("odo push") + runCmdShouldPass("odo push") // Create a URL - runCmd("odo url create --port 8080") + runCmdShouldPass("odo url create --port 8080") }) It("Should be able to link the spring boot application to the postgresql DB", func() { - runCmd("odo link dh-postgresql-apb -w") + runCmdShouldPass("odo link dh-postgresql-apb -w") waitForCmdOut("odo service list | sed 1d", 1, func(output string) bool { return strings.Contains(output, "dh-postgresql-apb") && @@ -77,18 +77,18 @@ var _ = Describe("odoServiceE2e", func() { It("Should be able to delete everything", func() { // Delete the component - runCmd("odo delete sb-app -f") + runCmdShouldPass("odo delete sb-app -f") // Delete the service - runCmd("odo service delete dh-postgresql-apb -f") + runCmdShouldPass("odo service delete dh-postgresql-apb -f") }) }) Context("odo hides a hidden service in service catalog", func() { It("not show a hidden service in the catalog", func() { - runCmd("oc apply -f https://github.com/openshift/library/raw/master/official/sso/templates/sso72-https.json -n openshift") - output := runFailCmd("odo catalog search service sso72-https", 1) - Expect(output).To(ContainSubstring("No service matched the query: sso72-https")) + runCmdShouldPass("oc apply -f https://github.com/openshift/library/raw/master/official/sso/templates/sso72-https.json -n openshift") + outputErr := runCmdShouldFail("odo catalog search service sso72-https") + Expect(outputErr).To(ContainSubstring("No service matched the query: sso72-https")) }) }) } diff --git a/tests/e2e/source_test.go b/tests/e2e/source_test.go index f80cf6909d0..02521917537 100644 --- a/tests/e2e/source_test.go +++ b/tests/e2e/source_test.go @@ -2,6 +2,7 @@ package e2e import ( "fmt" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) @@ -15,7 +16,7 @@ var _ = Describe("odoSourceE2e", func() { // Create a separate project for source Context("create source project", func() { It("should create a new source project", func() { - session := runCmd("odo project create " + projName) + session := runCmdShouldPass("odo project create " + projName) Expect(session).To(ContainSubstring(projName)) }) }) @@ -23,100 +24,100 @@ var _ = Describe("odoSourceE2e", func() { Context("odo component creation", func() { It("Should be able to deploy a python source application", func() { - runCmd("odo create python python-app --local " + sourceExamples + "/python/") - cmpList := runCmd("odo list") + runCmdShouldPass("odo create python python-app --local " + sourceExamples + "/python/") + cmpList := runCmdShouldPass("odo list") Expect(cmpList).To(ContainSubstring("python-app")) // Push changes - runCmd("odo push") + runCmdShouldPass("odo push") // Create a URL - runCmd("odo url create --port 8080") + runCmdShouldPass("odo url create --port 8080") routeURL := determineRouteURL() // Ping said URL waitForEqualCmd("curl -s "+routeURL+" | grep 'WSGI' | wc -l | tr -d '\n'", "1", 10) // Delete the component - runCmd("odo delete python-app -f") + runCmdShouldPass("odo delete python-app -f") }) It("Should be able to deploy an openjdk source application", func() { importOpenJDKImage() - runCmd("odo create openjdk18 openjdk-app --local " + sourceExamples + "/openjdk/") - cmpList := runCmd("odo list") + runCmdShouldPass("odo create openjdk18 openjdk-app --local " + sourceExamples + "/openjdk/") + cmpList := runCmdShouldPass("odo list") Expect(cmpList).To(ContainSubstring("openjdk-app")) // Push changes - runCmd("odo push") + runCmdShouldPass("odo push") // Create a URL - runCmd("odo url create --port 8080") + runCmdShouldPass("odo url create --port 8080") routeURL := determineRouteURL() // Ping said URL waitForEqualCmd("curl -s "+routeURL+" | grep 'Javalin' | wc -l | tr -d '\n'", "1", 10) // Delete the component - runCmd("odo delete openjdk-app -f") + runCmdShouldPass("odo delete openjdk-app -f") }) It("Should be able to deploy a wildfly source application", func() { - runCmd("odo create wildfly wildfly-app --local " + sourceExamples + "/wildfly/") - cmpList := runCmd("odo list") + runCmdShouldPass("odo create wildfly wildfly-app --local " + sourceExamples + "/wildfly/") + cmpList := runCmdShouldPass("odo list") Expect(cmpList).To(ContainSubstring("wildfly-app")) // Push changes - runCmd("odo push") + runCmdShouldPass("odo push") // Create a URL - runCmd("odo url create --port 8080") + runCmdShouldPass("odo url create --port 8080") routeURL := determineRouteURL() // Ping said URL waitForEqualCmd("curl -s "+routeURL+" | grep 'Insult' | wc -l | tr -d '\n'", "1", 10) // Delete the component - runCmd("odo delete wildfly-app -f") + runCmdShouldPass("odo delete wildfly-app -f") }) It("Should be able to deploy a nodejs source application", func() { - runCmd("odo create nodejs nodejs-app --local " + sourceExamples + "/nodejs/") - cmpList := runCmd("odo list") + runCmdShouldPass("odo create nodejs nodejs-app --local " + sourceExamples + "/nodejs/") + cmpList := runCmdShouldPass("odo list") Expect(cmpList).To(ContainSubstring("nodejs-app")) // Push changes - runCmd("odo push") + runCmdShouldPass("odo push") // Create a URL - runCmd("odo url create --port 8080") + runCmdShouldPass("odo url create --port 8080") routeURL := determineRouteURL() // Ping said URL waitForEqualCmd("curl -s "+routeURL+" | grep 'node.js' | wc -l | tr -d '\n'", "1", 10) // Delete the component - runCmd("odo delete nodejs-app -f") + runCmdShouldPass("odo delete nodejs-app -f") }) It("Should be able to deploy a dotnet source application", func() { - runCmd("odo create dotnet dotnet-app --local " + sourceExamples + "/dotnet/") - cmpList := runCmd("odo list") + runCmdShouldPass("odo create dotnet dotnet-app --local " + sourceExamples + "/dotnet/") + cmpList := runCmdShouldPass("odo list") Expect(cmpList).To(ContainSubstring("dotnet-app")) // Push changes - runCmd("odo push") + runCmdShouldPass("odo push") // Create a URL - runCmd("odo url create --port 8080") + runCmdShouldPass("odo url create --port 8080") routeURL := determineRouteURL() // Ping said URL waitForEqualCmd("curl -s "+routeURL+" | grep 'dotnet' | wc -l | tr -d '\n'", "1", 10) // Delete the component - runCmd("odo delete dotnet-app -f") + runCmdShouldPass("odo delete dotnet-app -f") }) }) @@ -124,7 +125,7 @@ var _ = Describe("odoSourceE2e", func() { // Delete the project Context("source project delete", func() { It("should delete source project", func() { - session := runCmd("odo project delete " + projName + " -f") + session := runCmdShouldPass("odo project delete " + projName + " -f") Expect(session).To(ContainSubstring(projName)) }) }) diff --git a/tests/e2e/utils.go b/tests/e2e/utils.go index 44ce36c5376..eef7c000b2a 100644 --- a/tests/e2e/utils.go +++ b/tests/e2e/utils.go @@ -6,5 +6,6 @@ import "strings" // this URL can then be used in order to interact with the deployed service running in Openshift // keeping with the spirit of the e2e tests, this expects, odo, sed and awk to be on the PATH func determineRouteURL() string { - return strings.TrimSpace(runCmd("odo url list | sed -n '1!p' | awk 'FNR==2 { print $2 }'")) + output := runCmdShouldPass("odo url list | sed -n '1!p' | awk 'FNR==2 { print $2 }'") + return strings.TrimSpace(output) } diff --git a/tests/e2e/watch_test.go b/tests/e2e/watch_test.go index 4b39a93de8a..098857b5ca1 100644 --- a/tests/e2e/watch_test.go +++ b/tests/e2e/watch_test.go @@ -28,18 +28,18 @@ var _ = Describe("odoWatchE2e", func() { Context("watch component created from local source or binary", func() { It("should create the project and application", func() { - runCmd("odo project create " + projName) - runCmd("odo app create " + appTestName) + runCmdShouldPass("odo project create " + projName) + runCmdShouldPass("odo app create " + appTestName) importOpenJDKImage() }) It("watch nodejs component created from local source", func() { - runCmd("git clone " + nodejsURI + " " + tmpDir + "/nodejs-ex") - runCmd("odo create nodejs nodejs-watch --local " + tmpDir + "/nodejs-ex --min-memory 400Mi --max-memory 700Mi") - runCmd("odo push -v 4") + runCmdShouldPass("git clone " + nodejsURI + " " + tmpDir + "/nodejs-ex") + runCmdShouldPass("odo create nodejs nodejs-watch --local " + tmpDir + "/nodejs-ex --min-memory 400Mi --max-memory 700Mi") + runCmdShouldPass("odo push -v 4") // Test multiple push so as to avoid regressions like: https://github.com/redhat-developer/odo/issues/1054 - runCmd("odo push -v 4") - runCmd("odo url create --port 8080") + runCmdShouldPass("odo push -v 4") + runCmdShouldPass("odo url create --port 8080") startSimulationCh := make(chan bool) go func() { @@ -57,33 +57,33 @@ var _ = Describe("odoWatchE2e", func() { fileModificationPath, ) fmt.Println("Received signal, starting file modification simulation") - runCmd("mkdir -p " + tmpDir + "/nodejs-ex" + "/'.a b'") - runCmd("mkdir -p " + tmpDir + "/nodejs-ex" + "/'a b'") - runCmd("touch " + tmpDir + "/nodejs-ex" + "/'a b.txt'") + runCmdShouldPass("mkdir -p " + tmpDir + "/nodejs-ex" + "/'.a b'") + runCmdShouldPass("mkdir -p " + tmpDir + "/nodejs-ex" + "/'a b'") + runCmdShouldPass("touch " + tmpDir + "/nodejs-ex" + "/'a b.txt'") - runCmd(fmt.Sprintf("mkdir -p %s/nodejs-ex/tests/sample-tests", tmpDir)) - runCmd(fmt.Sprintf("touch %s/nodejs-ex/tests/sample-tests/test_1.js", tmpDir)) + runCmdShouldPass(fmt.Sprintf("mkdir -p %s/nodejs-ex/tests/sample-tests", tmpDir)) + runCmdShouldPass(fmt.Sprintf("touch %s/nodejs-ex/tests/sample-tests/test_1.js", tmpDir)) // Delete during watch - runCmd(fmt.Sprintf("rm -fr %s/nodejs-ex/tests/sample-tests", tmpDir)) - runCmd("rm -fr " + tmpDir + "/nodejs-ex/'a b.txt'") + runCmdShouldPass(fmt.Sprintf("rm -fr %s/nodejs-ex/tests/sample-tests", tmpDir)) + runCmdShouldPass("rm -fr " + tmpDir + "/nodejs-ex/'a b.txt'") - runCmd(fileModificationCmd) + runCmdShouldPass(fileModificationCmd) } }() success, err := pollNonRetCmdStdOutForString( "odo watch nodejs-watch -v 4", time.Duration(20)*time.Minute, func(output string) bool { - url := runCmd("odo url list | grep `odo component get -q` | grep 8080 | awk '{print $2}' | tr -d '\n'") + url := runCmdShouldPass("odo url list | grep `odo component get -q` | grep 8080 | awk '{print $2}' | tr -d '\n'") url = fmt.Sprintf("%s/pagecount", url) - curlOp := runCmd(fmt.Sprintf("curl %s", url)) + curlOp := runCmdShouldPass(fmt.Sprintf("curl %s", url)) if strings.Contains(curlOp, "Hello odo") { // Verify delete from component pod - podName := runCmd("oc get pods | grep nodejs-watch | awk '{print $1}' | tr -d '\n'") - runFailCmd("oc exec "+podName+" -c nodejs-watch-testing -- ls -lai /tmp/src/tests/sample-tests/test_1.js /opt/app-root/src-backup/src/tests/sample-tests;exit", 2) - runCmd("oc exec " + podName + " -c nodejs-watch-testing -- ls -lai /tmp/src/ | grep 'a b';exit") - runFailCmd("oc exec "+podName+" -c nodejs-watch-testing -- ls -lai /tmp/src/ | grep 'a b.txt';exit", 1) + podName := runCmdShouldPass("oc get pods | grep nodejs-watch | awk '{print $1}' | tr -d '\n'") + runCmdShouldFail("oc exec " + podName + " -c nodejs-watch-testing -- ls -lai /tmp/src/tests/sample-tests/test_1.js /opt/app-root/src-backup/src/tests/sample-tests;exit") + runCmdShouldPass("oc exec " + podName + " -c nodejs-watch-testing -- ls -lai /tmp/src/ | grep 'a b';exit") + runCmdShouldFail("oc exec " + podName + " -c nodejs-watch-testing -- ls -lai /tmp/src/ | grep 'a b.txt';exit") } return strings.Contains(curlOp, "Hello odo") }, @@ -95,12 +95,12 @@ var _ = Describe("odoWatchE2e", func() { Expect(err).To(BeNil()) // Verify memory limits to be same as configured - getMemoryLimit := runCmd("oc get dc nodejs-watch-" + + getMemoryLimit := runCmdShouldPass("oc get dc nodejs-watch-" + appTestName + " -o go-template='{{range .spec.template.spec.containers}}{{.resources.limits.memory}}{{end}}'", ) Expect(getMemoryLimit).To(ContainSubstring("700Mi")) - getMemoryRequest := runCmd("oc get dc nodejs-watch-" + + getMemoryRequest := runCmdShouldPass("oc get dc nodejs-watch-" + appTestName + " -o go-template='{{range .spec.template.spec.containers}}{{.resources.requests.memory}}{{end}}'", ) @@ -108,12 +108,12 @@ var _ = Describe("odoWatchE2e", func() { }) It("should watch python component local sources for any changes", func() { - runCmd("git clone " + pythonURI + " " + tmpDir + "/os-sample-python") - runCmd("odo create python python-watch --local " + tmpDir + "/os-sample-python --memory 400Mi") - runCmd("odo push -v 4") + runCmdShouldPass("git clone " + pythonURI + " " + tmpDir + "/os-sample-python") + runCmdShouldPass("odo create python python-watch --local " + tmpDir + "/os-sample-python --memory 400Mi") + runCmdShouldPass("odo push -v 4") // Test multiple push so as to avoid regressions like: https://github.com/redhat-developer/odo/issues/1054 - runCmd("odo push -v 4") - runCmd("odo url create") + runCmdShouldPass("odo push -v 4") + runCmdShouldPass("odo url create") startSimulationCh := make(chan bool) go func() { @@ -122,33 +122,33 @@ var _ = Describe("odoWatchE2e", func() { fmt.Println("Received signal, starting file modification simulation") fileModificationCmd := fmt.Sprintf("sed -i 's/World/odo/g' %s", filepath.Join(tmpDir, "os-sample-python", "wsgi.py")) - runCmd(fmt.Sprintf("mkdir -p %s/os-sample-python/tests", tmpDir)) - runCmd(fmt.Sprintf("touch %s/os-sample-python/tests/test_1.py", tmpDir)) - runCmd("mkdir -p " + tmpDir + "/os-sample-python" + "/'.a b'") - runCmd("mkdir -p " + tmpDir + "/os-sample-python" + "/'a b'") - runCmd("touch " + tmpDir + "/os-sample-python" + "/'a b.txt'") + runCmdShouldPass(fmt.Sprintf("mkdir -p %s/os-sample-python/tests", tmpDir)) + runCmdShouldPass(fmt.Sprintf("touch %s/os-sample-python/tests/test_1.py", tmpDir)) + runCmdShouldPass("mkdir -p " + tmpDir + "/os-sample-python" + "/'.a b'") + runCmdShouldPass("mkdir -p " + tmpDir + "/os-sample-python" + "/'a b'") + runCmdShouldPass("touch " + tmpDir + "/os-sample-python" + "/'a b.txt'") // Delete during watch - runCmd(fmt.Sprintf("rm -fr %s/os-sample-python/tests", tmpDir)) - runCmd("rm -fr " + tmpDir + "/os-sample-python/'a b.txt'") - runCmd(fileModificationCmd) + runCmdShouldPass(fmt.Sprintf("rm -fr %s/os-sample-python/tests", tmpDir)) + runCmdShouldPass("rm -fr " + tmpDir + "/os-sample-python/'a b.txt'") + runCmdShouldPass(fileModificationCmd) } }() success, err := pollNonRetCmdStdOutForString( "odo watch python-watch -v 4", time.Duration(5)*time.Minute, func(output string) bool { - url := runCmd("odo url list | grep `odo component get -q` | grep 8080 | awk '{print $2}'") - curlOp := runCmd(fmt.Sprintf("curl %s", url)) + url := runCmdShouldPass("odo url list | grep `odo component get -q` | grep 8080 | awk '{print $2}'") + curlOp := runCmdShouldPass(fmt.Sprintf("curl %s", url)) if strings.Contains(curlOp, "Hello odo") { - podName := runCmd("oc get pods | grep python-watch | awk '{print $1}' | tr -d '\n'") - runCmd("oc exec " + podName + " -c python-watch-testing -- ls -lai /tmp/src/ | grep 'a b';exit") + podName := runCmdShouldPass("oc get pods | grep python-watch | awk '{print $1}' | tr -d '\n'") + runCmdShouldPass("oc exec " + podName + " -c python-watch-testing -- ls -lai /tmp/src/ | grep 'a b';exit") // Verify delete from component pod - runFailCmd("oc exec "+podName+" -c python-watch-testing -- ls -lai /tmp/src/tests;exit", 2) - runFailCmd("oc exec "+podName+" -c python-watch-testing -- ls -lai /opt/app-root/src-backup/src/tests;exit", 2) - runFailCmd("oc exec "+podName+" -c python-watch-testing -- ls -lai /tmp/src/ | grep 'a b.txt';exit", 1) + runCmdShouldFail("oc exec " + podName + " -c python-watch-testing -- ls -lai /tmp/src/tests;exit") + runCmdShouldFail("oc exec " + podName + " -c python-watch-testing -- ls -lai /opt/app-root/src-backup/src/tests;exit") + runCmdShouldFail("oc exec " + podName + " -c python-watch-testing -- ls -lai /tmp/src/ | grep 'a b.txt';exit") } return strings.Contains(curlOp, "Hello odo") @@ -161,24 +161,24 @@ var _ = Describe("odoWatchE2e", func() { Expect(err).To(BeNil()) // Verify memory limits to be same as configured - getMemoryLimit := runCmd("oc get dc python-watch-" + + getMemoryLimit := runCmdShouldPass("oc get dc python-watch-" + appTestName + " -o go-template='{{range .spec.template.spec.containers}}{{.resources.limits.memory}}{{end}}'", ) Expect(getMemoryLimit).To(ContainSubstring("400Mi")) - getMemoryRequest := runCmd("oc get dc python-watch-" + + getMemoryRequest := runCmdShouldPass("oc get dc python-watch-" + appTestName + " -o go-template='{{range .spec.template.spec.containers}}{{.resources.requests.memory}}{{end}}'", ) Expect(getMemoryRequest).To(ContainSubstring("400Mi")) }) It("watch wildfly component created from local source", func() { - runCmd("git clone " + wildflyURI + " " + tmpDir + "/katacoda-odo-backend") - runCmd("odo create wildfly wildfly-watch --local " + tmpDir + "/katacoda-odo-backend --min-memory 400Mi --max-memory 700Mi") - runCmd("odo push -v 4") + runCmdShouldPass("git clone " + wildflyURI + " " + tmpDir + "/katacoda-odo-backend") + runCmdShouldPass("odo create wildfly wildfly-watch --local " + tmpDir + "/katacoda-odo-backend --min-memory 400Mi --max-memory 700Mi") + runCmdShouldPass("odo push -v 4") // Test multiple push so as to avoid regressions like: https://github.com/redhat-developer/odo/issues/1054 - runCmd("odo push -v 4") - runCmd("odo url create --port 8080") + runCmdShouldPass("odo push -v 4") + runCmdShouldPass("odo url create --port 8080") startSimulationCh := make(chan bool) go func() { @@ -186,14 +186,14 @@ var _ = Describe("odoWatchE2e", func() { if startMsg { fmt.Println("Received signal, starting file modification simulation") - runCmd(fmt.Sprintf("mkdir -p %s/katacoda-odo-backend/tests", tmpDir)) - runCmd(fmt.Sprintf("touch %s/katacoda-odo-backend/tests/test_1.java", tmpDir)) - runCmd("mkdir -p " + tmpDir + "/katacoda-odo-backend/src" + "/'.a b'") - runCmd("mkdir -p " + tmpDir + "/katacoda-odo-backend/src" + "/'a b'") - runCmd("touch " + tmpDir + "/katacoda-odo-backend/src" + "/'a b.txt'") + runCmdShouldPass(fmt.Sprintf("mkdir -p %s/katacoda-odo-backend/tests", tmpDir)) + runCmdShouldPass(fmt.Sprintf("touch %s/katacoda-odo-backend/tests/test_1.java", tmpDir)) + runCmdShouldPass("mkdir -p " + tmpDir + "/katacoda-odo-backend/src" + "/'.a b'") + runCmdShouldPass("mkdir -p " + tmpDir + "/katacoda-odo-backend/src" + "/'a b'") + runCmdShouldPass("touch " + tmpDir + "/katacoda-odo-backend/src" + "/'a b.txt'") // Delete during watch - runCmd(fmt.Sprintf("rm -fr %s/katacoda-odo-backend/tests", tmpDir)) - runCmd("rm -fr " + tmpDir + "/katacoda-odo-backend/src/'a b.txt'") + runCmdShouldPass(fmt.Sprintf("rm -fr %s/katacoda-odo-backend/tests", tmpDir)) + runCmdShouldPass("rm -fr " + tmpDir + "/katacoda-odo-backend/src/'a b.txt'") fileModificationPath := filepath.Join( tmpDir, @@ -212,24 +212,24 @@ var _ = Describe("odoWatchE2e", func() { "sed -i 's/response.getWriter().println(counter.toString())/response.getWriter().println(\"Hello odo\" + counter.toString())/g' %s", fileModificationPath, ) - runCmd(fileModificationCmd) + runCmdShouldPass(fileModificationCmd) } }() success, err := pollNonRetCmdStdOutForString( "odo watch wildfly-watch -v 4", time.Duration(5)*time.Minute, func(output string) bool { - url := runCmd("odo url list | grep `odo component get -q` | grep 8080 | awk '{print $2}' | tr -d '\n'") + url := runCmdShouldPass("odo url list | grep `odo component get -q` | grep 8080 | awk '{print $2}' | tr -d '\n'") url = fmt.Sprintf("%s/counter", url) - curlOp := runCmd(fmt.Sprintf("curl %s", url)) + curlOp := runCmdShouldPass(fmt.Sprintf("curl %s", url)) if strings.Contains(curlOp, "Hello odo") { // Verify delete from component pod - podName := runCmd("oc get pods | grep wildfly-watch | awk '{print $1}' | tr -d '\n'") - runFailCmd("oc exec "+podName+" -c wildfly-watch-testing -- ls -lai /opt/s2i/destination/src/tests /opt/app-root/src-backup/src/tests; exit", 2) - runCmd("oc exec " + podName + " -c wildfly-watch-testing -- ls -lai /opt/s2i/destination/src/src/ | grep 'a b';exit") - runFailCmd("oc exec "+podName+" -c wildfly-watch-testing -- ls -lai /opt/s2i/destination/src/src/tests;exit", 2) - runFailCmd("oc exec "+podName+" -c wildfly-watch-testing -- ls -lai /opt/app-root/src-backup/src/tests;exit", 2) - runFailCmd("oc exec "+podName+" -c wildfly-watch-testing -- ls -lai /opt/s2i/destination/src/src/ | grep 'a b.txt';exit", 1) + podName := runCmdShouldPass("oc get pods | grep wildfly-watch | awk '{print $1}' | tr -d '\n'") + runCmdShouldFail("oc exec " + podName + " -c wildfly-watch-testing -- ls -lai /opt/s2i/destination/src/tests /opt/app-root/src-backup/src/tests; exit") + runCmdShouldPass("oc exec " + podName + " -c wildfly-watch-testing -- ls -lai /opt/s2i/destination/src/src/ | grep 'a b';exit") + runCmdShouldFail("oc exec " + podName + " -c wildfly-watch-testing -- ls -lai /opt/s2i/destination/src/src/tests;exit") + runCmdShouldFail("oc exec " + podName + " -c wildfly-watch-testing -- ls -lai /opt/app-root/src-backup/src/tests;exit") + runCmdShouldFail("oc exec " + podName + " -c wildfly-watch-testing -- ls -lai /opt/s2i/destination/src/src/ | grep 'a b.txt';exit") } return strings.Contains(curlOp, "Hello odo") }, @@ -241,12 +241,12 @@ var _ = Describe("odoWatchE2e", func() { Expect(err).To(BeNil()) // Verify memory limits to be same as configured - getMemoryLimit := runCmd("oc get dc wildfly-watch-" + + getMemoryLimit := runCmdShouldPass("oc get dc wildfly-watch-" + appTestName + " -o go-template='{{range .spec.template.spec.containers}}{{.resources.limits.memory}}{{end}}'", ) Expect(getMemoryLimit).To(ContainSubstring("700Mi")) - getMemoryRequest := runCmd("oc get dc wildfly-watch-" + + getMemoryRequest := runCmdShouldPass("oc get dc wildfly-watch-" + appTestName + " -o go-template='{{range .spec.template.spec.containers}}{{.resources.requests.memory}}{{end}}'", ) @@ -254,27 +254,27 @@ var _ = Describe("odoWatchE2e", func() { }) It("watch openjdk component created from local source", func() { - runCmd("git clone " + openjdkURI + " " + tmpDir + "/javalin-helloworld") - runCmd("odo create openjdk18 openjdk-watch --local " + tmpDir + "/javalin-helloworld --min-memory 400Mi --max-memory 700Mi") - runCmd("odo push -v 4") + runCmdShouldPass("git clone " + openjdkURI + " " + tmpDir + "/javalin-helloworld") + runCmdShouldPass("odo create openjdk18 openjdk-watch --local " + tmpDir + "/javalin-helloworld --min-memory 400Mi --max-memory 700Mi") + runCmdShouldPass("odo push -v 4") // Test multiple push so as to avoid regressions like: https://github.com/redhat-developer/odo/issues/1054 - runCmd("odo push -v 4") - runCmd("odo url create --port 8080") + runCmdShouldPass("odo push -v 4") + runCmdShouldPass("odo url create --port 8080") startSimulationCh := make(chan bool) go func() { startMsg := <-startSimulationCh if startMsg { fmt.Println("Received signal, starting file modification simulation") - runCmd("mkdir -p " + tmpDir + "/javalin-helloworld/src" + "/'.a b'") - runCmd("mkdir -p " + tmpDir + "/javalin-helloworld/src" + "/'a b'") - runCmd("touch " + tmpDir + "/javalin-helloworld/src" + "/'a b.txt'") - runCmd(fmt.Sprintf("mkdir -p %s/javalin-helloworld/tests", tmpDir)) - runCmd(fmt.Sprintf("touch %s/javalin-helloworld/tests/test_1.java", tmpDir)) + runCmdShouldPass("mkdir -p " + tmpDir + "/javalin-helloworld/src" + "/'.a b'") + runCmdShouldPass("mkdir -p " + tmpDir + "/javalin-helloworld/src" + "/'a b'") + runCmdShouldPass("touch " + tmpDir + "/javalin-helloworld/src" + "/'a b.txt'") + runCmdShouldPass(fmt.Sprintf("mkdir -p %s/javalin-helloworld/tests", tmpDir)) + runCmdShouldPass(fmt.Sprintf("touch %s/javalin-helloworld/tests/test_1.java", tmpDir)) // Delete during watch - runCmd(fmt.Sprintf("rm -fr %s/javalin-helloworld/tests", tmpDir)) - runCmd("rm -fr " + tmpDir + "/javalin-helloworld/src/'a b.txt'") + runCmdShouldPass(fmt.Sprintf("rm -fr %s/javalin-helloworld/tests", tmpDir)) + runCmdShouldPass("rm -fr " + tmpDir + "/javalin-helloworld/src/'a b.txt'") fileModificationPath := filepath.Join( tmpDir, @@ -288,23 +288,23 @@ var _ = Describe("odoWatchE2e", func() { "sed -i 's/Hello World/Hello odo/g' %s", fileModificationPath, ) - runCmd(fileModificationCmd) + runCmdShouldPass(fileModificationCmd) } }() success, err := pollNonRetCmdStdOutForString( "odo watch openjdk-watch -v 4", time.Duration(5)*time.Minute, func(output string) bool { - url := runCmd("odo url list | grep `odo component get -q` | grep 8080 | awk '{print $2}' | tr -d '\n'") - curlOp := runCmd(fmt.Sprintf("curl %s", url)) + url := runCmdShouldPass("odo url list | grep `odo component get -q` | grep 8080 | awk '{print $2}' | tr -d '\n'") + curlOp := runCmdShouldPass(fmt.Sprintf("curl %s", url)) if strings.Contains(curlOp, "Hello odo") { // Verify delete from component pod - podName := runCmd("oc get pods | grep openjdk-watch | awk '{print $1}' | tr -d '\n'") - runFailCmd("oc exec "+podName+" -c openjdk-watch-testing -- ls -lai /tmp/src/tests/test_1.java /opt/app-root/src-backup/src/tests/test_1.java;exit", 2) - runCmd("oc exec " + podName + " -c openjdk-watch-testing -- ls -lai /tmp/src/src/ | grep 'a b';exit") - runFailCmd("oc exec "+podName+" -c openjdk-watch-testing -- ls -lai /tmp/src/tests;exit", 2) - runFailCmd("oc exec "+podName+" -c openjdk-watch-testing -- ls -lai /opt/app-root/src-backup/src/tests;exit", 2) - runFailCmd("oc exec "+podName+" -c openjdk-watch-testing -- ls -lai /tmp/src/src/ | grep 'a b.txt';exit", 1) + podName := runCmdShouldPass("oc get pods | grep openjdk-watch | awk '{print $1}' | tr -d '\n'") + runCmdShouldFail("oc exec " + podName + " -c openjdk-watch-testing -- ls -lai /tmp/src/tests/test_1.java /opt/app-root/src-backup/src/tests/test_1.java;exit") + runCmdShouldPass("oc exec " + podName + " -c openjdk-watch-testing -- ls -lai /tmp/src/src/ | grep 'a b';exit") + runCmdShouldFail("oc exec " + podName + " -c openjdk-watch-testing -- ls -lai /tmp/src/tests;exit") + runCmdShouldFail("oc exec " + podName + " -c openjdk-watch-testing -- ls -lai /opt/app-root/src-backup/src/tests;exit") + runCmdShouldFail("oc exec " + podName + " -c openjdk-watch-testing -- ls -lai /tmp/src/src/ | grep 'a b.txt';exit") } return strings.Contains(curlOp, "Hello odo") }, @@ -316,12 +316,12 @@ var _ = Describe("odoWatchE2e", func() { Expect(err).To(BeNil()) // Verify memory limits to be same as configured - getMemoryLimit := runCmd("oc get dc openjdk-watch-" + + getMemoryLimit := runCmdShouldPass("oc get dc openjdk-watch-" + appTestName + " -o go-template='{{range .spec.template.spec.containers}}{{.resources.limits.memory}}{{end}}'", ) Expect(getMemoryLimit).To(ContainSubstring("700Mi")) - getMemoryRequest := runCmd("oc get dc openjdk-watch-" + + getMemoryRequest := runCmdShouldPass("oc get dc openjdk-watch-" + appTestName + " -o go-template='{{range .spec.template.spec.containers}}{{.resources.requests.memory}}{{end}}'", ) @@ -329,13 +329,13 @@ var _ = Describe("odoWatchE2e", func() { }) It("watch openjdk component created from local binary", func() { - runCmd("git clone " + openjdkURI + " " + tmpDir + "/binary/javalin-helloworld") - runCmd("mvn package -f " + tmpDir + "/binary/javalin-helloworld") - runCmd("odo create openjdk18 openjdk-watch-binary --binary " + tmpDir + "/binary/javalin-helloworld/target/javalin-hello-world-0.1-SNAPSHOT.jar --min-memory 400Mi --max-memory 700Mi") - runCmd("odo push -v 4") + runCmdShouldPass("git clone " + openjdkURI + " " + tmpDir + "/binary/javalin-helloworld") + runCmdShouldPass("mvn package -f " + tmpDir + "/binary/javalin-helloworld") + runCmdShouldPass("odo create openjdk18 openjdk-watch-binary --binary " + tmpDir + "/binary/javalin-helloworld/target/javalin-hello-world-0.1-SNAPSHOT.jar --min-memory 400Mi --max-memory 700Mi") + runCmdShouldPass("odo push -v 4") // Test multiple push so as to avoid regressions like: https://github.com/redhat-developer/odo/issues/1054 - runCmd("odo push -v 4") - runCmd("odo url create --port 8080") + runCmdShouldPass("odo push -v 4") + runCmdShouldPass("odo url create --port 8080") startSimulationCh := make(chan bool) go func() { @@ -357,16 +357,16 @@ var _ = Describe("odoWatchE2e", func() { "sed -i 's/Hello World/Hello odo/g' %s", fileModificationPath, ) - runCmd(fileModificationCmd) - runCmd("mvn package -f " + tmpDir + "/binary/javalin-helloworld") + runCmdShouldPass(fileModificationCmd) + runCmdShouldPass("mvn package -f " + tmpDir + "/binary/javalin-helloworld") } }() success, err := pollNonRetCmdStdOutForString( "odo watch openjdk-watch-binary -v 4", time.Duration(5)*time.Minute, func(output string) bool { - url := runCmd("odo url list | grep `odo component get -q` | grep 8080 | awk '{print $2}' | tr -d '\n'") - curlOp := runCmd(fmt.Sprintf("curl %s", url)) + url := runCmdShouldPass("odo url list | grep `odo component get -q` | grep 8080 | awk '{print $2}' | tr -d '\n'") + curlOp := runCmdShouldPass(fmt.Sprintf("curl %s", url)) return strings.Contains(curlOp, "Hello odo") }, startSimulationCh, @@ -379,25 +379,25 @@ var _ = Describe("odoWatchE2e", func() { Expect(err).To(BeNil()) // Verify memory limits to be same as configured - getMemoryLimit := runCmd("oc get dc openjdk-watch-binary-" + + getMemoryLimit := runCmdShouldPass("oc get dc openjdk-watch-binary-" + appTestName + " -o go-template='{{range .spec.template.spec.containers}}{{.resources.limits.memory}}{{end}}'", ) Expect(getMemoryLimit).To(ContainSubstring("700Mi")) - getMemoryRequest := runCmd("oc get dc openjdk-watch-binary-" + + getMemoryRequest := runCmdShouldPass("oc get dc openjdk-watch-binary-" + appTestName + " -o go-template='{{range .spec.template.spec.containers}}{{.resources.requests.memory}}{{end}}'", ) Expect(getMemoryRequest).To(ContainSubstring("400Mi")) }) It("watch wildfly component created from binary", func() { - runCmd("git clone " + wildflyURI + " " + tmpDir + "/binary/katacoda-odo-backend") - runCmd("mvn package -f " + tmpDir + "/binary/katacoda-odo-backend") - runCmd("odo create wildfly wildfly-watch-binary --binary " + tmpDir + "/binary/katacoda-odo-backend/target/ROOT.war --min-memory 400Mi --max-memory 700Mi") - runCmd("odo push -v 4") + runCmdShouldPass("git clone " + wildflyURI + " " + tmpDir + "/binary/katacoda-odo-backend") + runCmdShouldPass("mvn package -f " + tmpDir + "/binary/katacoda-odo-backend") + runCmdShouldPass("odo create wildfly wildfly-watch-binary --binary " + tmpDir + "/binary/katacoda-odo-backend/target/ROOT.war --min-memory 400Mi --max-memory 700Mi") + runCmdShouldPass("odo push -v 4") // Test multiple push so as to avoid regressions like: https://github.com/redhat-developer/odo/issues/1054 - runCmd("odo push -v 4") - runCmd("odo url create --port 8080") + runCmdShouldPass("odo push -v 4") + runCmdShouldPass("odo url create --port 8080") startSimulationCh := make(chan bool) go func() { @@ -405,14 +405,14 @@ var _ = Describe("odoWatchE2e", func() { if startMsg { fmt.Println("Received signal, starting file modification simulation") - runCmd(fmt.Sprintf("mkdir -p %s/binary/katacoda-odo-backend/tests", tmpDir)) - runCmd(fmt.Sprintf("touch %s/binary/katacoda-odo-backend/tests/test_1.java", tmpDir)) - runCmd("mkdir -p " + tmpDir + "/binary/katacoda-odo-backend/src" + "/'.a b'") - runCmd("mkdir -p " + tmpDir + "/binary/katacoda-odo-backend/src" + "/'a b'") - runCmd("touch " + tmpDir + "/binary/katacoda-odo-backend/src" + "/'a b.txt'") + runCmdShouldPass(fmt.Sprintf("mkdir -p %s/binary/katacoda-odo-backend/tests", tmpDir)) + runCmdShouldPass(fmt.Sprintf("touch %s/binary/katacoda-odo-backend/tests/test_1.java", tmpDir)) + runCmdShouldPass("mkdir -p " + tmpDir + "/binary/katacoda-odo-backend/src" + "/'.a b'") + runCmdShouldPass("mkdir -p " + tmpDir + "/binary/katacoda-odo-backend/src" + "/'a b'") + runCmdShouldPass("touch " + tmpDir + "/binary/katacoda-odo-backend/src" + "/'a b.txt'") // Delete during watch - runCmd(fmt.Sprintf("rm -fr %s/binary/katacoda-odo-backend/tests", tmpDir)) - runCmd("rm -fr " + tmpDir + "/binary/katacoda-odo-backend/src/'a b.txt'") + runCmdShouldPass(fmt.Sprintf("rm -fr %s/binary/katacoda-odo-backend/tests", tmpDir)) + runCmdShouldPass("rm -fr " + tmpDir + "/binary/katacoda-odo-backend/src/'a b.txt'") fileModificationPath := filepath.Join( tmpDir, @@ -432,17 +432,17 @@ var _ = Describe("odoWatchE2e", func() { "sed -i 's/response.getWriter().println(counter.toString())/response.getWriter().println(\"Hello odo\" + counter.toString())/g' %s", fileModificationPath, ) - runCmd(fileModificationCmd) - runCmd("mvn package -f " + tmpDir + "/binary/katacoda-odo-backend") + runCmdShouldPass(fileModificationCmd) + runCmdShouldPass("mvn package -f " + tmpDir + "/binary/katacoda-odo-backend") } }() success, err := pollNonRetCmdStdOutForString( "odo watch wildfly-watch-binary -v 4", time.Duration(5)*time.Minute, func(output string) bool { - url := runCmd("odo url list | grep `odo component get -q` | grep 8080 | awk '{print $2}' | tr -d '\n'") + url := runCmdShouldPass("odo url list | grep `odo component get -q` | grep 8080 | awk '{print $2}' | tr -d '\n'") url = fmt.Sprintf("%s/counter", url) - curlOp := runCmd(fmt.Sprintf("curl %s", url)) + curlOp := runCmdShouldPass(fmt.Sprintf("curl %s", url)) return strings.Contains(curlOp, "Hello odo") }, startSimulationCh, @@ -453,12 +453,12 @@ var _ = Describe("odoWatchE2e", func() { Expect(err).To(BeNil()) // Verify memory limits to be same as configured - getMemoryLimit := runCmd("oc get dc wildfly-watch-binary-" + + getMemoryLimit := runCmdShouldPass("oc get dc wildfly-watch-binary-" + appTestName + " -o go-template='{{range .spec.template.spec.containers}}{{.resources.limits.memory}}{{end}}'", ) Expect(getMemoryLimit).To(ContainSubstring("700Mi")) - getMemoryRequest := runCmd("oc get dc wildfly-watch-binary-" + + getMemoryRequest := runCmdShouldPass("oc get dc wildfly-watch-binary-" + appTestName + " -o go-template='{{range .spec.template.spec.containers}}{{.resources.requests.memory}}{{end}}'", )