diff --git a/Makefile b/Makefile index 9800a96a027..59623f31bd9 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ COMMON_FLAGS := -X $(PROJECT)/pkg/odo/cli/version.GITCOMMIT=$(GITCOMMIT) BUILD_FLAGS := -ldflags="-w $(COMMON_FLAGS)" DEBUG_BUILD_FLAGS := -ldflags="$(COMMON_FLAGS)" FILES := odo dist -TIMEOUT ?= 1800s +TIMEOUT ?= 7200s # Env variable TEST_EXEC_NODES is used to pass spec execution type # (parallel or sequential) for ginkgo tests. To run the specs sequentially use @@ -113,89 +113,114 @@ test: # Run generic integration tests .PHONY: test-generic test-generic: - ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odo generic" slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT) + ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odo generic" \ + slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT) # Run json outout tests .PHONY: test-json-format-output test-json-format-output: - ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odojsonoutput" slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT) + ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odojsonoutput" \ + slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT) # Run component e2e tests .PHONY: test-cmp-e2e test-cmp-e2e: - ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoCmpE2e" slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT) + ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoCmpE2e" \ + slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT) # Run component subcommands e2e tests .PHONY: test-cmp-sub-e2e test-cmp-sub-e2e: - ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoCmpSubE2e" slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT) + ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoCmpSubE2e" \ + slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT) # Run java e2e tests .PHONY: test-java-e2e test-java-e2e: - ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoJavaE2e" slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT) + ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoJavaE2e" \ + slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT) # Run source e2e tests .PHONY: test-source-e2e test-source-e2e: - ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoSourceE2e" slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT) + ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoSourceE2e" \ + slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT) # Run service catalog e2e tests .PHONY: test-service-e2e test-service-e2e: - ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoServiceE2e" slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT) + ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoServiceE2e" \ + slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/servicecatalog/ -timeout $(TIMEOUT) # Run link e2e tests .PHONY: test-link-e2e test-link-e2e: - ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoLinkE2e" slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT) + ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoLinkE2e" \ + slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/servicecatalog/ -timeout $(TIMEOUT) # Run watch e2e tests .PHONY: test-watch-e2e test-watch-e2e: - ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoWatchE2e" slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT) + ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoWatchE2e" \ + slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT) # Run storage command integration tests .PHONY: test-cmd-storage test-cmd-storage: - ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odo storage command" slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT) + ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odo storage command" \ + slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT) # Run odo app cmd tests .PHONY: test-cmd-app test-cmd-app: - ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoCmdApp" slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT) + ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoCmdApp" \ + slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT) # Run login e2e tests # This test shouldn't run spec in paralel because it will break the test behaviour # due to race condition in parallel run. .PHONY: test-odo-login-e2e test-odo-login-e2e: - ginkgo -v -nodes=1 -focus="odoLoginE2e" slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT) + ginkgo -v -nodes=1 -focus="odoLoginE2e" \ + slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/loginlogout/ -timeout $(TIMEOUT) # Run config tests .PHONY: test-odo-config test-odo-config: - ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odo config test" slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT) + ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odo config test" \ + slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT) -# Run all integration tests +# Run command's integration tests irrespective of service catalog status in the cluster. +# Service, link and login/logout command tests are not the part of this test run .PHONY: test-integration test-integration: - go test -v github.com/openshift/odo/tests/integration -ginkgo.slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -ginkgo.v -timeout $(TIMEOUT) + ginkgo -v -nodes=$(TEST_EXEC_NODES) \ + slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT) + +# Run command's integration tests which are depend on service catalog enabled cluster. +# Only service and link command tests are the part of this test run +.PHONY: test-integration-service-catalog +test-integration-service-catalog: + ginkgo -v -nodes=$(TEST_EXEC_NODES) \ + slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/servicecatalog -timeout $(TIMEOUT) # Run url integreation tests .PHONY: test-odo-url-int test-odo-url-int: - ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoURLIntegration" slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT) + ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odoURLIntegration" \ + slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT) # Run push command e2e .PHONY: test-cmd-push test-cmd-push: - ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odo push command tests" slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT) + ginkgo -v -nodes=$(TEST_EXEC_NODES) -focus="odo push command tests" \ + slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/integration/ -timeout $(TIMEOUT) # Run e2e test scenarios .PHONY: test-e2e-scenarios test-e2e-scenarios: - ginkgo -v -nodes=$(TEST_EXEC_NODES) slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) -randomizeAllSpecs tests/e2escenarios/ -timeout $(TIMEOUT) + ginkgo -v -nodes=$(TEST_EXEC_NODES) -randomizeAllSpecs \ + slowSpecThreshold=$(SLOW_SPEC_THRESHOLD) tests/e2escenarios/ -timeout $(TIMEOUT) # this test shouldn't be in paralel - it will effect the results .PHONY: test-benchmark diff --git a/docs/development.adoc b/docs/development.adoc index 372a3baabec..66ee8115767 100644 --- a/docs/development.adoc +++ b/docs/development.adoc @@ -268,6 +268,10 @@ $ make test-source-e2e * To run the tests sequentially or on single ginkgo test node use enviornment variable `TEST_EXEC_NODES`: + + +NOTE: However the env variable `TEST_EXEC_NODES` can be used to increase or decrease any number of test node for parallel run depending on the resource allocated to the OpenShift cluster. Make sure that the `TEST_EXEC_NODES` value cannot be `0` or any `negative` value. ++ + Run component command integration tests + ---- @@ -354,14 +358,33 @@ $ make test-odo-login-e2e NOTE: `make test-odo-login-e2e` doesn't honour environment variable `TEST_EXEC_NODES`. So by default it runs login and logout command integration test suite on a single ginkgo test node sequentially to avoid race conditions in a parallel run. -* For the entire integration test suite: +Entire integration tests suite can be run in parallel and sequentially separately: + +* To run entire integration tests spec in parallel (default: 2 ginkgo test node), on a test cluster: + +---- +$ make test-integration-service-catalog +---- ++ + ---- $ make test-integration ---- + -NOTE: `make test-integration` doesn't honour enviornment variable `TEST_EXEC_NODES`. So by default it runs the entire integration test suite on a single ginkgo test node sequentially. +* To run entire integration tests spec sequentially or on single ginkgo test node use enviornment variable `TEST_EXEC_NODES`: ++ +---- +$ TEST_EXEC_NODES=1 make test-integration-service-catalog +---- ++ + +---- +$ TEST_EXEC_NODES=1 make test-integration +---- ++ + +NOTE: `make test-integration-service-catalog` includes only service and link tests and can be successfully validated only if the cluster has service catalog enabled. Whereas `make test-integration` includes tests except service, link, login tests and runs rest of the tests irrespective of service catalog status in the cluster. Similarly e2e (end to end) tests can be run in parallel and sequentially separately. diff --git a/pkg/preference/preference.go b/pkg/preference/preference.go index 33ffd05791a..3408ac32f5e 100644 --- a/pkg/preference/preference.go +++ b/pkg/preference/preference.go @@ -112,18 +112,18 @@ func NewPreference() Preference { // NewPreferenceInfo gets the PreferenceInfo from preference file and creates the preference file in case it's // not present func NewPreferenceInfo() (*PreferenceInfo, error) { - configFile, err := getPreferenceFile() - glog.V(4).Infof("The configFile is %+v", configFile) + preferenceFile, err := getPreferenceFile() + glog.V(4).Infof("The preference file is %+v", preferenceFile) if err != nil { - return nil, errors.Wrap(err, "unable to get odo config file") + return nil, errors.Wrap(err, "unable to get odo preference file") } c := PreferenceInfo{ Preference: NewPreference(), - Filename: configFile, + Filename: preferenceFile, } - // if the config file doesn't exist then we dont worry about it and return - if _, err = os.Stat(configFile); os.IsNotExist(err) { + // if the preference file doesn't exist then we dont worry about it and return + if _, err = os.Stat(preferenceFile); os.IsNotExist(err) { return &c, nil } diff --git a/tests/e2escenarios/core_beta_flow.go b/tests/e2escenarios/core_beta_flow.go index 862d52af1ff..a2ad02af234 100644 --- a/tests/e2escenarios/core_beta_flow.go +++ b/tests/e2escenarios/core_beta_flow.go @@ -33,9 +33,9 @@ var _ = Describe("Core beta flow", func() { oc = helper.NewOcRunner("oc") odo = "odo" - project = helper.CreateRandProject() context = helper.CreateNewContext() os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml")) + project = helper.CreateRandProject() }) AfterEach(func() { diff --git a/tests/integration/cmd_app_test.go b/tests/integration/cmd_app_test.go index 850247aa672..e5facd5eb22 100644 --- a/tests/integration/cmd_app_test.go +++ b/tests/integration/cmd_app_test.go @@ -23,9 +23,9 @@ var _ = Describe("odoCmdApp", func() { var _ = BeforeEach(func() { SetDefaultEventuallyTimeout(10 * time.Minute) SetDefaultConsistentlyDuration(30 * time.Second) - project = helper.CreateRandProject() context = helper.CreateNewContext() os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml")) + project = helper.CreateRandProject() originalDir = helper.Getwd() }) @@ -61,6 +61,11 @@ var _ = Describe("odoCmdApp", func() { }) Context("when running app command without app parameter in directory that contains .odo config directory", func() { + + JustAfterEach(func() { + helper.Chdir(originalDir) + }) + It("should successfuly execute list, describe and delete along with machine readable output", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context) helper.CmdShouldPass("odo", "component", "create", "nodejs", cmpName, "--app", appName, "--project", project, "--context", context) @@ -80,7 +85,6 @@ var _ = Describe("odoCmdApp", func() { Expect(desiredDesAppJSON).Should(MatchJSON(actualDesAppJSON)) helper.CmdShouldPass("odo", "app", "delete", "-f") - helper.Chdir(originalDir) }) }) diff --git a/tests/integration/cmd_pref_config_test.go b/tests/integration/cmd_pref_config_test.go index 8edd5eac732..c37dc13dd9f 100644 --- a/tests/integration/cmd_pref_config_test.go +++ b/tests/integration/cmd_pref_config_test.go @@ -80,9 +80,9 @@ var _ = Describe("odo config test", func() { Context("when creating odo local config in the same config dir", func() { JustBeforeEach(func() { - project = helper.CreateRandProject() context = helper.CreateNewContext() os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "preference.yaml")) + project = helper.CreateRandProject() originalDir = helper.Getwd() helper.Chdir(context) }) @@ -161,9 +161,9 @@ var _ = Describe("odo config test", func() { Context("when creating odo local config with context flag", func() { JustBeforeEach(func() { - project = helper.CreateRandProject() context = helper.CreateNewContext() os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "preference.yaml")) + project = helper.CreateRandProject() }) JustAfterEach(func() { helper.DeleteProject(project) @@ -239,9 +239,9 @@ var _ = Describe("odo config test", func() { Context("when creating odo local config with env variables", func() { JustBeforeEach(func() { - project = helper.CreateRandProject() context = helper.CreateNewContext() os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "preference.yaml")) + project = helper.CreateRandProject() }) JustAfterEach(func() { helper.DeleteProject(project) @@ -266,9 +266,9 @@ var _ = Describe("odo config test", func() { Context("when viewing local config without logging into the OpenShift cluster", func() { JustBeforeEach(func() { - project = helper.CreateRandProject() context = helper.CreateNewContext() os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "preference.yaml")) + project = helper.CreateRandProject() }) JustAfterEach(func() { helper.DeleteProject(project) diff --git a/tests/integration/cmd_storage_test.go b/tests/integration/cmd_storage_test.go index 491727853b5..01a5accd1ba 100644 --- a/tests/integration/cmd_storage_test.go +++ b/tests/integration/cmd_storage_test.go @@ -18,9 +18,9 @@ var _ = Describe("odo storage command", func() { var _ = BeforeEach(func() { SetDefaultEventuallyTimeout(10 * time.Minute) SetDefaultConsistentlyDuration(30 * time.Second) - project = helper.CreateRandProject() context = helper.CreateNewContext() os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml")) + project = helper.CreateRandProject() oc = helper.NewOcRunner("oc") }) diff --git a/tests/integration/cmd_watch_test.go b/tests/integration/cmd_watch_test.go index 178ab3f919e..05e1c9993f2 100644 --- a/tests/integration/cmd_watch_test.go +++ b/tests/integration/cmd_watch_test.go @@ -21,9 +21,9 @@ var _ = Describe("odoWatchE2e", func() { BeforeEach(func() { SetDefaultEventuallyTimeout(10 * time.Minute) SetDefaultConsistentlyDuration(30 * time.Second) - project = helper.CreateRandProject() context = helper.CreateNewContext() os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml")) + project = helper.CreateRandProject() }) // Clean up after the test diff --git a/tests/integration/component.go b/tests/integration/component.go index 0eaff18f39f..e88d41b24ea 100644 --- a/tests/integration/component.go +++ b/tests/integration/component.go @@ -25,9 +25,9 @@ func componentTests(args ...string) { BeforeEach(func() { SetDefaultEventuallyTimeout(10 * time.Minute) SetDefaultConsistentlyDuration(30 * time.Second) - oc = helper.NewOcRunner("oc") context = helper.CreateNewContext() os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml")) + oc = helper.NewOcRunner("oc") }) // Clean up after the test @@ -114,7 +114,6 @@ func componentTests(args ...string) { }) Context("Test odo push with --source and --config flags", func() { - var originalDir string JustBeforeEach(func() { project = helper.CreateRandProject() originalDir = helper.Getwd() @@ -249,12 +248,10 @@ func componentTests(args ...string) { Context("Creating Component even in new project", func() { var project string JustBeforeEach(func() { - context = helper.CreateNewContext() project = helper.RandString(10) }) JustAfterEach(func() { - os.RemoveAll(context) helper.DeleteProject(project) }) It("should create component", func() { @@ -267,16 +264,6 @@ func componentTests(args ...string) { }) Context("Test odo push with --now flag during creation", func() { - var originalDir string - BeforeEach(func() { - context = helper.CreateNewContext() - }) - - AfterEach(func() { - helper.DeleteProject(project) - helper.DeleteDir(context) - }) - JustBeforeEach(func() { project = helper.CreateRandProject() originalDir = helper.Getwd() @@ -286,12 +273,10 @@ func componentTests(args ...string) { JustAfterEach(func() { helper.Chdir(originalDir) }) - It("should successfully create config and push code in one create command with --now", func() { appName := "nodejs-create-now-test" cmpName := "nodejs-push-atonce" helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", append(args, "create", "nodejs", cmpName, "--app", appName, "--project", project, "--now")...) oc.VerifyCmpExists(cmpName, appName, project) @@ -317,7 +302,6 @@ func componentTests(args ...string) { componentName := "my-component" JustBeforeEach(func() { - context = helper.CreateNewContext() project = helper.CreateRandProject() originalDir = helper.Getwd() helper.Chdir(context) @@ -326,7 +310,6 @@ func componentTests(args ...string) { JustAfterEach(func() { helper.Chdir(originalDir) helper.DeleteProject(project) - os.RemoveAll(context) }) It("create local nodejs component twice and fail", func() { @@ -366,12 +349,10 @@ func componentTests(args ...string) { Context("odo component updating", func() { JustBeforeEach(func() { project = helper.CreateRandProject() - context = helper.CreateNewContext() }) JustAfterEach(func() { helper.DeleteProject(project) - os.RemoveAll(context) }) It("should be able to create a git component and update it from local to git", func() { @@ -444,14 +425,12 @@ func componentTests(args ...string) { JustBeforeEach(func() { project = helper.CreateRandProject() - context = helper.CreateNewContext() originalDir = helper.Getwd() }) JustAfterEach(func() { helper.DeleteProject(project) - helper.DeleteDir(context) - os.RemoveAll(context) + helper.Chdir(originalDir) }) It("should pass inside a odo directory without component name as parameter", func() { @@ -465,7 +444,6 @@ func componentTests(args ...string) { Expect(cmpListOutput).To(ContainSubstring(cmpName)) helper.CmdShouldPass("odo", "describe") helper.CmdShouldPass("odo", "delete", "-f") - helper.Chdir(originalDir) }) It("should fail outside a odo directory without component name as parameter", func() { @@ -495,14 +473,12 @@ func componentTests(args ...string) { Context("when running odo push multiple times, check for existence of environment variables", func() { JustBeforeEach(func() { project = helper.CreateRandProject() - context = helper.CreateNewContext() originalDir = helper.Getwd() }) JustAfterEach(func() { helper.DeleteProject(project) - helper.DeleteDir(context) - os.RemoveAll(context) + helper.Chdir(originalDir) }) It("should should retain the same environment variable on multiple push", func() { @@ -515,7 +491,6 @@ func componentTests(args ...string) { helper.Chdir(context) helper.CmdShouldPass("odo", "config", "set", "--env", "FOO=BAR") helper.CmdShouldPass("odo", "push") - helper.CmdShouldPass("oc", "project", project) dcName := oc.GetDcName(componentName, project) stdOut := helper.CmdShouldPass("oc", "get", "dc/"+dcName, "-n", project, "-o", "go-template={{ .spec.template.spec }}{{.env}}") @@ -524,30 +499,30 @@ func componentTests(args ...string) { helper.CmdShouldPass("odo", "push") stdOut = oc.DescribeDc(dcName, project) Expect(stdOut).To(ContainSubstring("FOO")) - - helper.Chdir(originalDir) }) }) Context("Creating component with numeric named context", func() { - var context string + var contextNumeric string JustBeforeEach(func() { var err error ts := time.Now().UnixNano() - context, err = ioutil.TempDir("", fmt.Sprint(ts)) + contextNumeric, err = ioutil.TempDir("", fmt.Sprint(ts)) Expect(err).ToNot(HaveOccurred()) os.Mkdir(context, 0750) project = helper.CreateRandProject() - helper.Chdir(context) + helper.Chdir(contextNumeric) }) JustAfterEach(func() { helper.DeleteProject(project) + helper.Chdir(originalDir) + helper.DeleteDir(contextNumeric) }) It("should create default named component in a directory with numeric name", func() { - helper.CopyExample(filepath.Join("source", "nodejs"), context) - helper.CmdShouldPass("odo", append(args, "create", "nodejs", "--project", project, "--context", context, "--app", "testing")...) - helper.CmdShouldPass("odo", "push", "--context", context, "-v4") + helper.CopyExample(filepath.Join("source", "nodejs"), contextNumeric) + helper.CmdShouldPass("odo", append(args, "create", "nodejs", "--project", project, "--context", contextNumeric, "--app", "testing")...) + helper.CmdShouldPass("odo", "push", "--context", contextNumeric, "-v4") }) }) diff --git a/tests/integration/generic_test.go b/tests/integration/generic_test.go index be6977d2102..764e2d679de 100644 --- a/tests/integration/generic_test.go +++ b/tests/integration/generic_test.go @@ -40,9 +40,9 @@ var _ = Describe("odo generic", func() { Context("creating component with an application and url", func() { JustBeforeEach(func() { - project = helper.CreateRandProject() context = helper.CreateNewContext() os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml")) + project = helper.CreateRandProject() originalDir = helper.Getwd() helper.Chdir(context) }) @@ -65,9 +65,9 @@ var _ = Describe("odo generic", func() { Context("should list applications in other project", func() { JustBeforeEach(func() { - project = helper.CreateRandProject() context = helper.CreateNewContext() os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml")) + project = helper.CreateRandProject() }) JustAfterEach(func() { @@ -89,9 +89,9 @@ var _ = Describe("odo generic", func() { Context("when running odo push with flag --show-log", func() { JustBeforeEach(func() { - project = helper.CreateRandProject() context = helper.CreateNewContext() os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml")) + project = helper.CreateRandProject() }) JustAfterEach(func() { @@ -111,9 +111,9 @@ var _ = Describe("odo generic", func() { Context("deploying a component with a specific image name", func() { JustBeforeEach(func() { - project = helper.CreateRandProject() context = helper.CreateNewContext() os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml")) + project = helper.CreateRandProject() }) JustAfterEach(func() { @@ -130,6 +130,14 @@ var _ = Describe("odo generic", func() { }) Context("When deleting two project one after the other", func() { + JustBeforeEach(func() { + context = helper.CreateNewContext() + os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml")) + }) + + JustAfterEach(func() { + os.Unsetenv("GLOBALODOCONFIG") + }) It("should be able to delete sequentially", func() { project1 := helper.CreateRandProject() project2 := helper.CreateRandProject() @@ -140,6 +148,14 @@ var _ = Describe("odo generic", func() { }) Context("When deleting three project one after the other in opposite order", func() { + JustBeforeEach(func() { + context = helper.CreateNewContext() + os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml")) + }) + + JustAfterEach(func() { + os.Unsetenv("GLOBALODOCONFIG") + }) It("should be able to delete", func() { project1 := helper.CreateRandProject() project2 := helper.CreateRandProject() @@ -171,8 +187,9 @@ var _ = Describe("odo generic", func() { var originalDir string JustBeforeEach(func() { - project = helper.CreateRandProject() context = helper.CreateNewContext() + os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml")) + project = helper.CreateRandProject() originalDir = helper.Getwd() helper.Chdir(context) }) @@ -181,6 +198,7 @@ var _ = Describe("odo generic", func() { helper.DeleteProject(project) helper.Chdir(originalDir) helper.DeleteDir(context) + os.Unsetenv("GLOBALODOCONFIG") }) It("should not allow creating a URL with long name", func() { helper.CmdShouldPass("odo", "create", "nodejs", "--project", project) diff --git a/tests/integration/java_test.go b/tests/integration/java_test.go index 21b608f6577..68c47dbe090 100644 --- a/tests/integration/java_test.go +++ b/tests/integration/java_test.go @@ -18,9 +18,9 @@ var _ = Describe("odoJavaE2e", func() { var _ = BeforeEach(func() { SetDefaultEventuallyTimeout(10 * time.Minute) oc = helper.NewOcRunner("oc") - project = helper.CreateRandProject() context = helper.CreateNewContext() os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml")) + project = helper.CreateRandProject() }) // Clean up after the test diff --git a/tests/integration/json_test.go b/tests/integration/json_test.go index 477c1b27130..6bfe62dd8c6 100644 --- a/tests/integration/json_test.go +++ b/tests/integration/json_test.go @@ -75,13 +75,9 @@ var _ = Describe("odojsonoutput", func() { Expect(desiredDesCompJSON).Should(MatchJSON(actualDesCompJSON)) // odo list -o json --path . - pwd := helper.Getwd() - - desired := fmt.Sprintf(`{"kind":"List","apiVersion":"odo.openshift.io/v1alpha1","metadata":{},"items":[{"kind":"Component","apiVersion":"odo.openshift.io/v1alpha1","metadata":{"name":"nodejs","creationTimestamp":null,"namespace":"%s"},"spec":{"type":"nodejs","app": "myapp","source":"https://github.com/openshift/nodejs-ex","ports": ["8080/TCP"]},"status":{"context":"%s","state":"Pushed"}}]}`, project, strings.TrimSpace(pwd)) - helper.Chdir(context) - actual := helper.CmdShouldPass("odo", "list", "-o", "json", "--path", pwd) - helper.Chdir(pwd) - Expect(desired).Should(MatchJSON(actual)) + desiredJSONPathFlag := fmt.Sprintf(`{"kind":"List","apiVersion":"odo.openshift.io/v1alpha1","metadata":{},"items":[{"kind":"Component","apiVersion":"odo.openshift.io/v1alpha1","metadata":{"name":"nodejs","creationTimestamp":null,"namespace":"%s"},"spec":{"type":"nodejs","app": "myapp","source":"https://github.com/openshift/nodejs-ex","ports": ["8080/TCP"]},"status":{"context":"%s","state":"Pushed"}}]}`, project, strings.TrimSpace(context)) + actualJSONPathFlag := helper.CmdShouldPass("odo", "list", "-o", "json", "--path", context) + Expect(desiredJSONPathFlag).Should(MatchJSON(actualJSONPathFlag)) }) }) diff --git a/tests/integration/cmd_login_logout_test.go b/tests/integration/loginlogout/cmd_login_logout_test.go similarity index 100% rename from tests/integration/cmd_login_logout_test.go rename to tests/integration/loginlogout/cmd_login_logout_test.go diff --git a/tests/integration/loginlogout/loginlogout_suite_test.go b/tests/integration/loginlogout/loginlogout_suite_test.go new file mode 100644 index 00000000000..4c65f07df17 --- /dev/null +++ b/tests/integration/loginlogout/loginlogout_suite_test.go @@ -0,0 +1,13 @@ +package integration + +import ( + "testing" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +func TestLoginlogout(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Loginlogout Suite") +} diff --git a/tests/integration/cmd_link_unlink_test.go b/tests/integration/servicecatalog/cmd_link_unlink_test.go similarity index 99% rename from tests/integration/cmd_link_unlink_test.go rename to tests/integration/servicecatalog/cmd_link_unlink_test.go index d41d7a55f9d..a1c9cd0da9f 100644 --- a/tests/integration/cmd_link_unlink_test.go +++ b/tests/integration/servicecatalog/cmd_link_unlink_test.go @@ -18,16 +18,17 @@ var _ = Describe("odoLinkE2e", func() { var project string var context, context1, context2 string var originalDir string + var oc helper.OcRunner // Setup up state for each test spec // create new project (not set as active) and new context directory for each test spec // This is before every spec (It) var _ = BeforeEach(func() { SetDefaultEventuallyTimeout(10 * time.Minute) - oc = helper.NewOcRunner("oc") - project = helper.CreateRandProject() context = helper.CreateNewContext() os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml")) + oc = helper.NewOcRunner("oc") + project = helper.CreateRandProject() }) // Clean up after the test diff --git a/tests/integration/service_test.go b/tests/integration/servicecatalog/service_test.go similarity index 98% rename from tests/integration/service_test.go rename to tests/integration/servicecatalog/service_test.go index 081674d49bd..e4a3c719770 100644 --- a/tests/integration/service_test.go +++ b/tests/integration/servicecatalog/service_test.go @@ -38,9 +38,9 @@ var _ = Describe("odoServiceE2e", func() { Context("When creating with a spring boot application", func() { JustBeforeEach(func() { - project = helper.CreateRandProject() context = helper.CreateNewContext() os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml")) + project = helper.CreateRandProject() originalDir = helper.Getwd() helper.Chdir(context) }) @@ -57,7 +57,7 @@ var _ = Describe("odoServiceE2e", func() { // Local config needs to be present in order to create service https://github.com/openshift/odo/issues/1602 helper.CmdShouldPass("odo", "create", "java", "sb-app", "--project", project) - helper.CmdShouldPass("odo", "service", "create", "dh-postgresql-apb", "--plan", "dev", + helper.CmdShouldPass("odo", "service", "create", "dh-postgresql-apb", "--project", project, "--plan", "dev", "-p", "postgresql_user=luke", "-p", "postgresql_password=secret", "-p", "postgresql_database=my_data", "-p", "postgresql_version=9.6") ocArgs := []string{"get", "serviceinstance", "-o", "name", "-n", project} @@ -82,7 +82,7 @@ var _ = Describe("odoServiceE2e", func() { routeURL := helper.DetermineRouteURL("") // Ping said URL - helper.HttpWaitFor(routeURL, "Spring Boot", 30, 1) + helper.HttpWaitFor(routeURL, "Spring Boot", 90, 1) // Delete the component helper.CmdShouldPass("odo", "delete", "sb-app", "-f") diff --git a/tests/integration/servicecatalog/servicecatalog_suite_test.go b/tests/integration/servicecatalog/servicecatalog_suite_test.go new file mode 100644 index 00000000000..3eab041c2d1 --- /dev/null +++ b/tests/integration/servicecatalog/servicecatalog_suite_test.go @@ -0,0 +1,13 @@ +package integration + +import ( + "testing" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +func TestServicecatalog(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Servicecatalog Suite") +} diff --git a/tests/integration/source_test.go b/tests/integration/source_test.go index 52095abdd1d..f2fa20aa419 100644 --- a/tests/integration/source_test.go +++ b/tests/integration/source_test.go @@ -18,9 +18,9 @@ var _ = Describe("odoSourceE2e", func() { BeforeEach(func() { SetDefaultEventuallyTimeout(10 * time.Minute) oc = helper.NewOcRunner("oc") - project = helper.CreateRandProject() context = helper.CreateNewContext() os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml")) + project = helper.CreateRandProject() }) AfterEach(func() {