From a7b50f51ec171218f0e26a19ae29b3937f590363 Mon Sep 17 00:00:00 2001 From: John Collier Date: Wed, 20 May 2020 13:22:04 -0400 Subject: [PATCH 1/3] Run devfile docker url tests without kube config Signed-off-by: John Collier --- .travis.yml | 3 +- Makefile | 5 ++ .../cmd_docker_devfile_url_pushtarget_test.go | 82 +++++++++++++++++++ .../docker/cmd_docker_devfile_url_test.go | 38 --------- 4 files changed, 89 insertions(+), 39 deletions(-) create mode 100644 tests/integration/devfile/docker/cmd_docker_devfile_url_pushtarget_test.go diff --git a/.travis.yml b/.travis.yml index 68081c9cf09..1c7f0645847 100644 --- a/.travis.yml +++ b/.travis.yml @@ -135,7 +135,7 @@ jobs: - ./scripts/oc-cluster.sh - make bin - sudo cp odo /usr/bin - - travis_wait make test-cmd-docker-devfile-url + - travis_wait test-cmd-docker-devfile-url-pushtarget # These tests need cluster login as they will be interacting with a Kube environment - odo login -u developer - travis_wait make test-cmd-devfile-catalog @@ -169,6 +169,7 @@ jobs: - travis_wait make test-cmd-docker-devfile-push - travis_wait make test-cmd-docker-devfile-catalog - travis_wait make test-cmd-docker-devfile-delete + - travis_wait make test-cmd-docker-devfile-url # Run devfile integration test on Kubernetes cluster - <<: *base-test diff --git a/Makefile b/Makefile index 3914e3da1cf..35fd5f8dade 100644 --- a/Makefile +++ b/Makefile @@ -258,6 +258,11 @@ test-cmd-docker-devfile-delete: test-cmd-docker-devfile-catalog: ginkgo $(GINKGO_FLAGS) -focus="odo docker devfile catalog command tests" tests/integration/devfile/docker/ +# Run odo url docker devfile command tests +.PHONY: test-cmd-docker-devfile-url-pushtarget +test-cmd-docker-devfile-url: + ginkgo $(GINKGO_FLAGS) -focus="odo docker devfile url pushtarget command tests" tests/integration/devfile/docker/ + # Run odo watch command tests .PHONY: test-cmd-watch test-cmd-watch: diff --git a/tests/integration/devfile/docker/cmd_docker_devfile_url_pushtarget_test.go b/tests/integration/devfile/docker/cmd_docker_devfile_url_pushtarget_test.go new file mode 100644 index 00000000000..31242cdcb5f --- /dev/null +++ b/tests/integration/devfile/docker/cmd_docker_devfile_url_pushtarget_test.go @@ -0,0 +1,82 @@ +package docker + +import ( + "os" + "path/filepath" + "time" + + "github.com/openshift/odo/tests/helper" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("odo docker devfile url pushtarget command tests", func() { + var context, currentWorkingDirectory, cmpName string + dockerClient := helper.NewDockerRunner("docker") + + // This is run after every Spec (It) + var _ = BeforeEach(func() { + SetDefaultEventuallyTimeout(10 * time.Minute) + context = helper.CreateNewContext() + currentWorkingDirectory = helper.Getwd() + cmpName = helper.RandString(6) + helper.Chdir(context) + os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml")) + helper.CmdShouldPass("odo", "preference", "set", "Experimental", "true") + helper.CmdShouldPass("odo", "preference", "set", "pushtarget", "docker") + }) + + // Clean up after the test + // This is run after every Spec (It) + var _ = AfterEach(func() { + // Stop all containers labeled with the component name + label := "component=" + cmpName + dockerClient.StopContainers(label) + + helper.Chdir(currentWorkingDirectory) + helper.DeleteDir(context) + os.Unsetenv("GLOBALODOCONFIG") + }) + + // These tests require an active kube context *and* Docker daemon, so keeping them separate + // from the other Docker URL tests which only require Docker. + Context("Switching pushtarget", func() { + It("switch from docker to kube, odo push should display warning", func() { + var stdout string + + helper.CmdShouldPass("odo", "create", "nodejs", cmpName) + + helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), context) + helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile.yaml"), filepath.Join(context, "devfile.yaml")) + + helper.CmdShouldPass("odo", "url", "create") + + helper.CmdShouldPass("odo", "preference", "set", "pushtarget", "kube", "-f") + session := helper.CmdRunner("odo", "push", "--devfile", "devfile.yaml") + stdout = string(session.Wait().Out.Contents()) + stderr := string(session.Wait().Err.Contents()) + Expect(stderr).To(ContainSubstring("Found a URL defined for Docker, but no valid URLs for Kubernetes.")) + Expect(stdout).To(ContainSubstring("Changes successfully pushed to component")) + }) + + It("switch from kube to docker, odo push should display warning", func() { + var stdout string + helper.CmdShouldPass("odo", "preference", "set", "pushtarget", "kube", "-f") + helper.CmdShouldPass("odo", "create", "nodejs", cmpName) + + helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), context) + helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile.yaml"), filepath.Join(context, "devfile.yaml")) + + helper.CmdShouldPass("odo", "url", "create", "--host", "1.2.3.4.com", "--ingress") + + helper.CmdShouldPass("odo", "preference", "set", "pushtarget", "docker", "-f") + session := helper.CmdRunner("odo", "push", "--devfile", "devfile.yaml") + stdout = string(session.Wait().Out.Contents()) + stderr := string(session.Wait().Err.Contents()) + Expect(stderr).To(ContainSubstring("Found a URL defined for Kubernetes, but no valid URLs for Docker.")) + Expect(stdout).To(ContainSubstring("Changes successfully pushed to component")) + }) + }) + +}) diff --git a/tests/integration/devfile/docker/cmd_docker_devfile_url_test.go b/tests/integration/devfile/docker/cmd_docker_devfile_url_test.go index e3e7ec63255..8b4de1a6cbe 100644 --- a/tests/integration/devfile/docker/cmd_docker_devfile_url_test.go +++ b/tests/integration/devfile/docker/cmd_docker_devfile_url_test.go @@ -103,44 +103,6 @@ var _ = Describe("odo docker devfile url command tests", func() { }) }) - Context("Switching pushtarget", func() { - It("switch from docker to kube, odo push should display warning", func() { - var stdout string - - helper.CmdShouldPass("odo", "create", "nodejs", cmpName) - - helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), context) - helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile.yaml"), filepath.Join(context, "devfile.yaml")) - - helper.CmdShouldPass("odo", "url", "create") - - helper.CmdShouldPass("odo", "preference", "set", "pushtarget", "kube", "-f") - session := helper.CmdRunner("odo", "push", "--devfile", "devfile.yaml") - stdout = string(session.Wait().Out.Contents()) - stderr := string(session.Wait().Err.Contents()) - Expect(stderr).To(ContainSubstring("Found a URL defined for Docker, but no valid URLs for Kubernetes.")) - Expect(stdout).To(ContainSubstring("Changes successfully pushed to component")) - }) - - It("switch from kube to docker, odo push should display warning", func() { - var stdout string - helper.CmdShouldPass("odo", "preference", "set", "pushtarget", "kube", "-f") - helper.CmdShouldPass("odo", "create", "nodejs", cmpName) - - helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), context) - helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile.yaml"), filepath.Join(context, "devfile.yaml")) - - helper.CmdShouldPass("odo", "url", "create", "--host", "1.2.3.4.com", "--ingress") - - helper.CmdShouldPass("odo", "preference", "set", "pushtarget", "docker", "-f") - session := helper.CmdRunner("odo", "push", "--devfile", "devfile.yaml") - stdout = string(session.Wait().Out.Contents()) - stderr := string(session.Wait().Err.Contents()) - Expect(stderr).To(ContainSubstring("Found a URL defined for Kubernetes, but no valid URLs for Docker.")) - Expect(stdout).To(ContainSubstring("Changes successfully pushed to component")) - }) - }) - Context("Listing urls", func() { It("should list url with appropriate state", func() { var stdout string From c58d66210cdc5f617c27a220a900775e55cf6ca3 Mon Sep 17 00:00:00 2001 From: John Collier Date: Wed, 20 May 2020 13:31:34 -0400 Subject: [PATCH 2/3] Update target Signed-off-by: John Collier --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 35fd5f8dade..393fa6df2d6 100644 --- a/Makefile +++ b/Makefile @@ -260,7 +260,7 @@ test-cmd-docker-devfile-catalog: # Run odo url docker devfile command tests .PHONY: test-cmd-docker-devfile-url-pushtarget -test-cmd-docker-devfile-url: +test-cmd-docker-devfile-url-pushtarget: ginkgo $(GINKGO_FLAGS) -focus="odo docker devfile url pushtarget command tests" tests/integration/devfile/docker/ # Run odo watch command tests From c4c48de3ddbefd29606a85a8761f2801ead7cd94 Mon Sep 17 00:00:00 2001 From: John Collier Date: Wed, 20 May 2020 13:33:36 -0400 Subject: [PATCH 3/3] Fix typo Signed-off-by: John Collier --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1c7f0645847..4e8ac5a030a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -135,7 +135,7 @@ jobs: - ./scripts/oc-cluster.sh - make bin - sudo cp odo /usr/bin - - travis_wait test-cmd-docker-devfile-url-pushtarget + - travis_wait make test-cmd-docker-devfile-url-pushtarget # These tests need cluster login as they will be interacting with a Kube environment - odo login -u developer - travis_wait make test-cmd-devfile-catalog