diff --git a/.travis.yml b/.travis.yml index 53d9a1edaaf..70ad61cdc74 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,11 @@ env: global: - secure: "SSGPlBUXMb2F3ycFEvRKHoftYy0UkIprwgtfOKXU/Uc359Qct+IrF/b8GuTd64tedXtnQE4z4fxqT8wdYRdNwUysmOvRyzlNTRhs1gocx5iL5El8+7F4we7wElh6ckt2Z5AVI5g0JOwYeQNURFhgDumN14K8XsOu7a2LzRBVFRn55z79xgTL+JnTI89JIWjz1QCr8Z054CMaK0MHJRLkgPnbnx1Skra3Wt16g29wRZLqLWoU8lyrLy9Ao/yHw/AJMCNie8ah7nNiOEdgPTcr/onZ/v+eVyaTvzE9UrmdeqpUpASypAAUnmZ9Q6QsU31dVxwbfPB0r8TzrqinCOYMnHbU/3fIz49Q+yv7RyifYsTlnx7+J79LmCvs7X+iKkmOprWdBRwUUxzDhwgIGnmBlYf0nKj9H2U3XFCYDnbRSI9ZugGBprs3t09w15gwq/wLM6DhY87zNhM4Vfb34ZXVBCEhtUXKUVbVthiPOWlHtbs0YympG/QCV+27tVIszgek8FFt6/fJeEh/APNadK9fuU01ozB01aXj0xMl3PlvoWWeQXDnyttHEWRaiVpbPKGoV5a7LPCVpWk5EOX8YNgHEUnjKwfzVBUriXAd+8zp0sx6TRdt1ts7x04NP1yFF1SCXXBpz/geOsfa2bBQyJx6y7CODcmW7fbcJLxmwdGlm6E=" - secure: "Tr9KxWvfQS6BSF1qUqz1Q41le5k/c+L37Aq8wTPQcmXVu8nLv5T1QMarx64KfZ2qaQBRV+M6DwnJQM7HU/cWX9AKpdoAO2INqANfoFLh8XTR5ncHjaNTzi9aS7owxa+9t0yfKowq7s4dp96nqmwchYFtUxpzKo0TMOcQ1l1AGEu5liniXb9VOKgG8UAZsLgD6b2a80nn6NP1JehGGxcWsow0EzxalnJ8Cv78YTLmqGNowYh5UmkhjkxqE4TskQafRd2qtYMPvxnC2CFd8G3qMlbBzCxM02lGKwbr/Vi41hcSyD3uuyaKVHr/g5qLcp/HNyrUGTREL1UvWkWjlL6ovuh6uHYlnpVwQkX5fzUH7z2hlr9HjQ3Tu6Sbh1CX5QBR5PUkvoOfdx0BHTmTTw2xkvUDHarqZT1OkMuUplCY/VMnJaqa5ko126r8CyKYqRoT4HQuqa6szVawGiB211VCQXJRVyLYtKUGO6mmnMUoi5H676/sv6c9py8bieMoyEyrI87lS0AhQ6QLnTjNbEO5xt6vFi7rEgcctD5nuEBwb/X2bmM2OdZFYXrIbXaZfq7fRKyzCQthfceCmySExOGI9ndCE/mS68X6NNFBVsVwb7zt0zSY6oGlf0/N2CR5sf8gwKYG1scr5Jyqmuifvqv433zepA0Sxj6WqC3ixlssNd8=" + - MINIKUBE_WANTUPDATENOTIFICATION=false + - MINIKUBE_WANTREPORTERRORPROMPT=false + - MINIKUBE_HOME=$HOME + - CHANGE_MINIKUBE_NONE_USER=true + - KUBECONFIG=$HOME/.kube/config jobs: include: # YAML alias, for settings shared across the tests @@ -140,4 +145,26 @@ jobs: - travis_wait make test-e2e-images - odo logout + # Run devfile integration test on Kubernetes cluster + - <<: *base-test + stage: test + name: "devfile catalog, create command integration tests" + before_script: + # Download kubectl, a cli tool for accessing Kubernetes cluster + - curl -sLo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.7.0/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/ + # Download minikube and set up Kubernetes single node cluster + - curl -sLo minikube https://storage.googleapis.com/minikube/releases/v0.25.2/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/ + - mkdir -p $HOME/.kube $HOME/.minikube + - touch $KUBECONFIG + - sudo minikube start --vm-driver=none --kubernetes-version=v1.7.0 + - minikube update-context + - "sudo chown -R travis: /home/travis/.minikube/" + script: + - kubectl cluster-info + - make bin + - sudo cp odo /usr/bin + - export KUBERNETES=true + - travis_wait make test-cmd-devfile-catalog + - travis_wait make test-cmd-devfile-create + diff --git a/tests/helper/kubernetes_utils.go b/tests/helper/kubernetes_utils.go new file mode 100644 index 00000000000..2253d321dfb --- /dev/null +++ b/tests/helper/kubernetes_utils.go @@ -0,0 +1,25 @@ +package helper + +import ( + "fmt" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +// CreateRandNamespace create new project with random name in kubernetes cluster (10 letters) +func CreateRandNamespace(context string) string { + projectName := RandString(10) + fmt.Fprintf(GinkgoWriter, "Creating a new project: %s\n", projectName) + CmdShouldPass("kubectl", "create", "namespace", projectName) + CmdShouldPass("kubectl", "config", "set-context", context, "--namespace", projectName) + session := CmdShouldPass("kubectl", "get", "namespaces") + Expect(session).To(ContainSubstring(projectName)) + return projectName +} + +// DeleteNamespace deletes a specified project in kubernetes cluster +func DeleteNamespace(projectName string) { + fmt.Fprintf(GinkgoWriter, "Deleting project: %s\n", projectName) + CmdShouldPass("kubectl", "delete", "namespaces", projectName) +} diff --git a/tests/integration/devfile/cmd_devfile_create_test.go b/tests/integration/devfile/cmd_devfile_create_test.go index 19c85f79d00..816236d7989 100644 --- a/tests/integration/devfile/cmd_devfile_create_test.go +++ b/tests/integration/devfile/cmd_devfile_create_test.go @@ -18,16 +18,25 @@ var _ = Describe("odo devfile create command tests", func() { // This is run after every Spec (It) var _ = BeforeEach(func() { SetDefaultEventuallyTimeout(10 * time.Minute) - project = helper.CreateRandProject() context = helper.CreateNewContext() + os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml")) + helper.CmdShouldPass("odo", "preference", "set", "Experimental", "true") + if os.Getenv("KUBERNETES") == "true" { + project = helper.CreateRandNamespace(context) + } else { + project = helper.CreateRandProject() + } currentWorkingDirectory = helper.Getwd() helper.Chdir(context) - os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "config.yaml")) }) // This is run after every Spec (It) var _ = AfterEach(func() { - helper.DeleteProject(project) + if os.Getenv("KUBERNETES") == "true" { + helper.DeleteNamespace(project) + } else { + helper.DeleteProject(project) + } helper.Chdir(currentWorkingDirectory) helper.DeleteDir(context) os.Unsetenv("GLOBALODOCONFIG") @@ -35,14 +44,12 @@ var _ = Describe("odo devfile create command tests", func() { Context("When executing odo create with devfile component type argument", func() { It("should successfully create the devfile component", func() { - helper.CmdShouldPass("odo", "preference", "set", "Experimental", "true") helper.CmdShouldPass("odo", "create", "openLiberty") }) }) Context("When executing odo create with devfile component type and component name arguments", func() { It("should successfully create the devfile component", func() { - helper.CmdShouldPass("odo", "preference", "set", "Experimental", "true") componentName := helper.RandString(6) helper.CmdShouldPass("odo", "create", "openLiberty", componentName) }) @@ -50,7 +57,6 @@ var _ = Describe("odo devfile create command tests", func() { Context("When executing odo create with devfile component type argument and --project flag", func() { It("should successfully create the devfile component", func() { - helper.CmdShouldPass("odo", "preference", "set", "Experimental", "true") componentNamespace := helper.RandString(6) helper.CmdShouldPass("odo", "create", "openLiberty", "--project", componentNamespace) }) @@ -58,7 +64,6 @@ var _ = Describe("odo devfile create command tests", func() { Context("When executing odo create with devfile component type argument and --namespace flag", func() { It("should successfully create the devfile component", func() { - helper.CmdShouldPass("odo", "preference", "set", "Experimental", "true") componentNamespace := helper.RandString(6) helper.CmdShouldPass("odo", "create", "openLiberty", "--namespace", componentNamespace) }) @@ -66,7 +71,6 @@ var _ = Describe("odo devfile create command tests", func() { Context("When executing odo create with devfile component name that contains unsupported character", func() { It("should failed with component name is not valid and prompt supported character", func() { - helper.CmdShouldPass("odo", "preference", "set", "Experimental", "true") componentName := "BAD@123" output := helper.CmdShouldFail("odo", "create", "openLiberty", componentName) helper.MatchAllInOutput(output, []string{"Contain only lowercase alphanumeric characters or ‘-’"}) @@ -75,7 +79,6 @@ var _ = Describe("odo devfile create command tests", func() { Context("When executing odo create with devfile component name that contains all numeric values", func() { It("should failed with component name is not valid and prompt container name must not contain all numeric values", func() { - helper.CmdShouldPass("odo", "preference", "set", "Experimental", "true") componentName := "123456" output := helper.CmdShouldFail("odo", "create", "openLiberty", componentName) helper.MatchAllInOutput(output, []string{"Must not contain all numeric values"}) @@ -84,7 +87,6 @@ var _ = Describe("odo devfile create command tests", func() { Context("When executing odo create with devfile component name that contains more than 63 characters ", func() { It("should failed with component name is not valid and prompt container name contains at most 63 characters", func() { - helper.CmdShouldPass("odo", "preference", "set", "Experimental", "true") componentName := helper.RandString(64) output := helper.CmdShouldFail("odo", "create", "openLiberty", componentName) helper.MatchAllInOutput(output, []string{"Contain at most 63 characters"}) @@ -93,7 +95,6 @@ var _ = Describe("odo devfile create command tests", func() { Context("When executing odo create with an invalid devfile component", func() { It("should fail with please run 'odo catalog list components'", func() { - helper.CmdShouldPass("odo", "preference", "set", "Experimental", "true") fakeComponentName := "fake-component" output := helper.CmdShouldFail("odo", "create", fakeComponentName) expectedString := "\"" + fakeComponentName + "\" not found"