From ae85aee18c96afcacf910007eabb3138eae8b250 Mon Sep 17 00:00:00 2001 From: Tomas Kral Date: Wed, 9 Oct 2019 18:20:54 +0200 Subject: [PATCH 1/2] fix dev-scripts and test to verify linking --- pkg/occlient/occlient.go | 3 ++- pkg/occlient/templates.go | 2 ++ tests/helper/helper_oc.go | 13 +++++++++++++ .../servicecatalog/cmd_link_unlink_test.go | 12 +++++++++++- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/pkg/occlient/occlient.go b/pkg/occlient/occlient.go index ea509654b98..45a2f7983ac 100644 --- a/pkg/occlient/occlient.go +++ b/pkg/occlient/occlient.go @@ -96,7 +96,8 @@ const ( // Default Image that will be used containing the supervisord binary and assembly scripts // use getBoostrapperImage() function instead of this variable - defaultBootstrapperImage = "quay.io/openshiftdo/init:0.13.0" + //TODO(kadel): change to updated released init-image + defaultBootstrapperImage = "quay.io/tkral/odo-supervisord-image:fix-dev-scripts" // ENV variable to overwrite image used to bootstrap SupervisorD in S2I builder Image bootstrapperImageEnvName = "ODO_BOOTSTRAPPER_IMAGE" diff --git a/pkg/occlient/templates.go b/pkg/occlient/templates.go index df954266dbc..8ec9c10af5b 100644 --- a/pkg/occlient/templates.go +++ b/pkg/occlient/templates.go @@ -409,6 +409,8 @@ func addBootstrapSupervisordInitContainer(dc *appsv1.DeploymentConfig, dcName st corev1.Container{ Name: "copy-supervisord", Image: getBootstrapperImage(), + //TODO(kadel): remove PullAlways, just for testing + ImagePullPolicy: corev1.PullAlways, VolumeMounts: []corev1.VolumeMount{ { Name: supervisordVolumeName, diff --git a/tests/helper/helper_oc.go b/tests/helper/helper_oc.go index 2f8f6e9b337..6deb094bdd6 100644 --- a/tests/helper/helper_oc.go +++ b/tests/helper/helper_oc.go @@ -5,6 +5,7 @@ import ( "fmt" "regexp" "strings" + "time" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -393,3 +394,15 @@ func (oc *OcRunner) GetEnvs(componentName string, appName string, projectName st } return mapOutput } + +// WaitForDCRollout wait for DeploymentConfig to finish active rollout +// timeout is a maximum wait time in seconds +func (oc *OcRunner) WaitForDCRollout(dcName string, project string, timeout time.Duration) { + session := CmdRunner(oc.path, "rollout", "status", + "-w", + "-n", project, + "dc", dcName) + + Eventually(session).Should(gexec.Exit(0), runningCmd(session.Command)) + session.Wait(timeout) +} diff --git a/tests/integration/servicecatalog/cmd_link_unlink_test.go b/tests/integration/servicecatalog/cmd_link_unlink_test.go index 19ed13b1fc7..c84e38f7acc 100644 --- a/tests/integration/servicecatalog/cmd_link_unlink_test.go +++ b/tests/integration/servicecatalog/cmd_link_unlink_test.go @@ -74,7 +74,7 @@ var _ = Describe("odo link and unlink command tests", func() { }) }) - Context("When handiling link/unlink between components", func() { + Context("When handling link/unlink between components", func() { JustBeforeEach(func() { context1 = helper.CreateNewContext() context2 = helper.CreateNewContext() @@ -86,14 +86,24 @@ var _ = Describe("odo link and unlink command tests", func() { It("should link the frontend application to the backend and then unlink successfully", func() { helper.CopyExample(filepath.Join("source", "nodejs"), context1) helper.CmdShouldPass("odo", "create", "nodejs", "frontend", "--context", context1, "--project", project) + helper.CmdShouldPass("odo", "url", "create", "--port", "8080", "--context", context1) helper.CmdShouldPass("odo", "push", "--context", context1) + frontendUrl := helper.DetermineRouteURL(context1) helper.CopyExample(filepath.Join("source", "python"), context2) helper.CmdShouldPass("odo", "create", "python", "backend", "--context", context2, "--project", project) + helper.CmdShouldPass("odo", "url", "create", "--context", context2) helper.CmdShouldPass("odo", "push", "--context", context2) + helper.CmdShouldPass("odo", "link", "backend", "--component", "frontend", "--project", project, "--context", context2) // ensure that the proper envFrom entry was created envFromOutput := oc.GetEnvFromEntry("frontend", "app", project) Expect(envFromOutput).To(ContainSubstring("backend")) + + dcName := oc.GetDcName("frontend", project) + // wait for DeploymentConfig rollout to finish, so we can check if application is successfully running + oc.WaitForDCRollout(dcName, project, 20*time.Second) + helper.HttpWaitFor(frontendUrl, "Hello world from node.js!", 20, 1) + outputErr := helper.CmdShouldFail("odo", "link", "backend", "--component", "frontend", "--project", project, "--context", context2) Expect(outputErr).To(ContainSubstring("been linked")) helper.CmdShouldPass("odo", "unlink", "backend", "--component", "frontend", "--project", project, "--context", context2) From f8463c71b552010cc6ca7f4944e6bd584b31d155 Mon Sep 17 00:00:00 2001 From: Tomas Kral Date: Thu, 10 Oct 2019 17:56:53 +0200 Subject: [PATCH 2/2] user relased odo-init-image 0.13.1 --- pkg/occlient/occlient.go | 3 +-- pkg/occlient/templates.go | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/pkg/occlient/occlient.go b/pkg/occlient/occlient.go index 45a2f7983ac..4a4d51fed29 100644 --- a/pkg/occlient/occlient.go +++ b/pkg/occlient/occlient.go @@ -96,8 +96,7 @@ const ( // Default Image that will be used containing the supervisord binary and assembly scripts // use getBoostrapperImage() function instead of this variable - //TODO(kadel): change to updated released init-image - defaultBootstrapperImage = "quay.io/tkral/odo-supervisord-image:fix-dev-scripts" + defaultBootstrapperImage = "quay.io/openshiftdo/init:0.13.1" // ENV variable to overwrite image used to bootstrap SupervisorD in S2I builder Image bootstrapperImageEnvName = "ODO_BOOTSTRAPPER_IMAGE" diff --git a/pkg/occlient/templates.go b/pkg/occlient/templates.go index 8ec9c10af5b..df954266dbc 100644 --- a/pkg/occlient/templates.go +++ b/pkg/occlient/templates.go @@ -409,8 +409,6 @@ func addBootstrapSupervisordInitContainer(dc *appsv1.DeploymentConfig, dcName st corev1.Container{ Name: "copy-supervisord", Image: getBootstrapperImage(), - //TODO(kadel): remove PullAlways, just for testing - ImagePullPolicy: corev1.PullAlways, VolumeMounts: []corev1.VolumeMount{ { Name: supervisordVolumeName,