Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Run devfile docker url tests without kube config #3223

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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-pushtarget:
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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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"))
})
})

})
38 changes: 0 additions & 38 deletions tests/integration/devfile/docker/cmd_docker_devfile_url_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down