diff --git a/e2e/smoke_test.go b/e2e/smoke_test.go index 16e6b36bf..078a82583 100644 --- a/e2e/smoke_test.go +++ b/e2e/smoke_test.go @@ -30,7 +30,6 @@ var _ = Describe("Smoke End To End Tests - against OpenShift Cluster with Istio scenario, sessionName, tmpDir string - readyStatusFunc func(ns string) func() bool ) JustBeforeEach(func() { @@ -45,7 +44,7 @@ var _ = Describe("Smoke End To End Tests - against OpenShift Cluster with Istio } InstallLocalOperator(namespace) - Eventually(readyStatusFunc(namespace), 2*time.Minute, 5*time.Second).Should(BeTrue()) + Eventually(AllDeploymentsAndPodsReady(namespace), 2*time.Minute, 5*time.Second).Should(BeTrue()) DeployTestScenario(scenario, namespace) }) @@ -67,13 +66,12 @@ var _ = Describe("Smoke End To End Tests - against OpenShift Cluster with Istio BeforeEach(func() { scenario = "scenario-1" registry = GetDockerRegistryInternal() - readyStatusFunc = AllDeploymentsAndPodsReady }) Context("basic deployment modifications", func() { It("should watch for changes in ratings service and serve it", func() { - EnsureAllPodsAreReady(namespace) + EnsureAllDeploymentPodsAreReady(namespace) EnsureProdRouteIsReachable(namespace, ContainSubstring("ratings-v1")) // given we have details code locally @@ -89,7 +87,7 @@ var _ = Describe("Smoke End To End Tests - against OpenShift Cluster with Istio "--session", sessionName, "--namespace", namespace, ) - EnsureAllPodsAreReady(namespace) + EnsureAllDeploymentPodsAreReady(namespace) EnsureSessionRouteIsReachable(namespace, sessionName, ContainSubstring("PublisherA")) // then modify the service @@ -106,7 +104,7 @@ var _ = Describe("Smoke End To End Tests - against OpenShift Cluster with Istio Context("deployment create/delete operations", func() { It("should watch for changes in ratings service and serve it", func() { - EnsureAllPodsAreReady(namespace) + EnsureAllDeploymentPodsAreReady(namespace) EnsureProdRouteIsReachable(namespace, ContainSubstring("ratings-v1"), Not(ContainSubstring(PreparedImageV1))) ChangeNamespace("default") @@ -122,7 +120,7 @@ var _ = Describe("Smoke End To End Tests - against OpenShift Cluster with Istio Eventually(ike1.Done(), 1*time.Minute).Should(BeClosed()) // ensure the new service is running - EnsureAllPodsAreReady(namespace) + EnsureAllDeploymentPodsAreReady(namespace) // check original response EnsureSessionRouteIsReachable(namespace, sessionName, ContainSubstring(PreparedImageV1), Not(ContainSubstring("ratings-v1"))) @@ -168,12 +166,11 @@ var _ = Describe("Smoke End To End Tests - against OpenShift Cluster with Istio Context("grpc protocol", func() { BeforeEach(func() { scenario = "scenario-1.1" - readyStatusFunc = AllDeploymentsAndPodsReady }) Context("basic deployment modifications", func() { It("should take over ratings service and serve it", func() { - EnsureAllPodsAreReady(namespace) + EnsureAllDeploymentPodsAreReady(namespace) EnsureProdRouteIsReachable(namespace, ContainSubstring("ratings-v1")) ike := RunIke(testshell.GetProjectDir(), "develop", @@ -185,7 +182,7 @@ var _ = Describe("Smoke End To End Tests - against OpenShift Cluster with Istio "--session", sessionName, "--namespace", namespace, ) - EnsureAllPodsAreReady(namespace) + EnsureAllDeploymentPodsAreReady(namespace) EnsureSessionRouteIsReachable(namespace, sessionName, ContainSubstring("PublisherA"), ContainSubstring("grpc")) @@ -204,12 +201,11 @@ var _ = Describe("Smoke End To End Tests - against OpenShift Cluster with Istio "Tests for regular k8s deployment can be found in the same test suite.") } scenario = "scenario-2" - readyStatusFunc = AllDeploymentConfigsAndPodsReady }) It("should watch for changes in ratings service in specified namespace and serve it", func() { ChangeNamespace(namespace) - EnsureAllPodsAreReady(namespace) + EnsureAllDeploymentConfigPodsAreReady(namespace) EnsureProdRouteIsReachable(namespace, ContainSubstring("ratings-v1")) // given we have details code locally @@ -224,7 +220,7 @@ var _ = Describe("Smoke End To End Tests - against OpenShift Cluster with Istio "--route", "header:x-test-suite=smoke", "--session", sessionName, ) - EnsureAllPodsAreReady(namespace) + EnsureAllDeploymentPodsAreReady(namespace) EnsureSessionRouteIsReachable(namespace, sessionName, ContainSubstring("PublisherA")) // then modify the service @@ -246,7 +242,6 @@ var _ = Describe("Smoke End To End Tests - against OpenShift Cluster with Istio tmpRemove = test.TemporaryEnvVars( "IKE_SESSION", sessionName, "IKE_ROUTE", "header:x-test-suite=smoke") - readyStatusFunc = AllDeploymentsAndPodsReady }) AfterEach(func() { @@ -255,7 +250,7 @@ var _ = Describe("Smoke End To End Tests - against OpenShift Cluster with Istio It("should create session on deployment creation and remove on delete", func() { ChangeNamespace(namespace) - EnsureAllPodsAreReady(namespace) + EnsureAllDeploymentPodsAreReady(namespace) EnsureProdRouteIsReachable(namespace, ContainSubstring("ratings-v1")) // given the mutation hook has kicked in @@ -272,11 +267,16 @@ var _ = Describe("Smoke End To End Tests - against OpenShift Cluster with Istio }) }) -// EnsureAllPodsAreReady make sure all Pods are in Ready state in given namespace. -func EnsureAllPodsAreReady(namespace string) { +// EnsureAllDeploymentPodsAreReady make sure all Pods are in Ready state in given namespace. +func EnsureAllDeploymentPodsAreReady(namespace string) { Eventually(AllDeploymentsAndPodsReady(namespace), 5*time.Minute, 5*time.Second).Should(BeTrue()) } +// EnsureAllDeploymentConfigPodsAreReady make sure all Pods are in Ready state in given namespace. +func EnsureAllDeploymentConfigPodsAreReady(namespace string) { + Eventually(AllDeploymentConfigsAndPodsReady(namespace), 5*time.Minute, 5*time.Second).Should(BeTrue()) +} + // EnsureProdRouteIsReachable can be reached with no special arguments. func EnsureProdRouteIsReachable(namespace string, matchers ...types.GomegaMatcher) { productPageURL := GetIstioIngressHostname() + "/test-service/productpage" diff --git a/go.mod b/go.mod index 1f9fd089e..47435ebaa 100644 --- a/go.mod +++ b/go.mod @@ -41,6 +41,7 @@ require ( golang.org/x/sys v0.0.0-20201116194326-cc9327a14d48 // indirect golang.org/x/text v0.3.4 // indirect golang.org/x/tools v0.0.0-20201117152513-9036a0f9af11 + gomodules.xyz/jsonpatch/v2 v2.0.1 google.golang.org/grpc v1.27.0 google.golang.org/protobuf v1.23.0 gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect