Skip to content

Commit

Permalink
fix: e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
aslakknutsen committed Nov 19, 2020
1 parent 174dfd0 commit 7f10210
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
34 changes: 17 additions & 17 deletions e2e/smoke_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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)
})

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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")
Expand All @@ -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")))
Expand Down Expand Up @@ -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",
Expand All @@ -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"))

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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() {
Expand All @@ -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
Expand All @@ -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"
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7f10210

Please sign in to comment.