Skip to content

Commit

Permalink
[v0.9] Make drift tests more lightweight (#2701)
Browse files Browse the repository at this point in the history
* Speed up drift tests

This uses a `pause` image instead of nginx, which should reduce the risk
of flaky tests.

* Remove references to nginx

Drift correction end-to-end tests no longer rely on nginx.
  • Loading branch information
weyfonk authored Aug 6, 2024
1 parent 04408de commit 73182d3
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions e2e/drift/drift_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ var _ = Describe("Drift", Ordered, func() {
JustBeforeEach(func() {
kw := k.Namespace(namespace)
out, err := kw.Patch(
"service", "nginx-service",
"service", "drift-dummy-service",
"-o=json",
"--type=json",
"-p", `[{"op": "replace", "path": "/spec/externalName", "value": "modified"}]`,
)
Expand All @@ -63,7 +64,7 @@ var _ = Describe("Drift", Ordered, func() {
}).Should(BeTrue())
By("Changes haven't been rolled back")
kw := k.Namespace(namespace)
out, _ := kw.Get("services", "nginx-service", "-o=json")
out, _ := kw.Get("services", "drift-dummy-service", "-o=json")
var service corev1.Service
_ = json.Unmarshal([]byte(out), &service)
Expect(service.Spec.ExternalName).Should(Equal("modified"))
Expand All @@ -80,7 +81,8 @@ var _ = Describe("Drift", Ordered, func() {
JustBeforeEach(func() {
kw := k.Namespace(namespace)
out, err := kw.Patch(
"service", "nginx-service",
"service", "drift-dummy-service",
"-o=json",
"--type=json",
"-p", `[{"op": "replace", "path": "/spec/externalName", "value": "modified"}]`,
)
Expand All @@ -94,10 +96,10 @@ var _ = Describe("Drift", Ordered, func() {
}).Should(BeTrue())
Eventually(func() bool {
kw := k.Namespace(namespace)
out, _ := kw.Get("services", "nginx-service", "-o=json")
out, _ := kw.Get("services", "drift-dummy-service", "-o=json")
var service corev1.Service
_ = json.Unmarshal([]byte(out), &service)
return service.Spec.ExternalName == "nginx"
return service.Spec.ExternalName == "drift-dummy"
}).Should(BeTrue())
})
})
Expand All @@ -106,9 +108,10 @@ var _ = Describe("Drift", Ordered, func() {
JustBeforeEach(func() {
kw := k.Namespace(namespace)
out, err := kw.Patch(
"deployment", "nginx-deployment",
"deployment", "drift-dummy-deployment",
"-o=json",
"--type=json",
"-p", `[{"op": "replace", "path": "/spec/template/spec/containers/0/image", "value": "nginx:modified"}]`,
"-p", `[{"op": "replace", "path": "/spec/template/spec/containers/0/image", "value": "foo:modified"}]`,
)
Expect(err).ToNot(HaveOccurred(), out)
})
Expand All @@ -120,10 +123,10 @@ var _ = Describe("Drift", Ordered, func() {
}).Should(BeTrue())
Eventually(func() bool {
kw := k.Namespace(namespace)
out, _ := kw.Get("deployment", "nginx-deployment", "-o=json")
out, _ := kw.Get("deployment", "drift-dummy-deployment", "-o=json")
var deployment appsv1.Deployment
_ = json.Unmarshal([]byte(out), &deployment)
return deployment.Spec.Template.Spec.Containers[0].Image == "nginx:1.14.2"
return deployment.Spec.Template.Spec.Containers[0].Image == "k8s.gcr.io/pause"
}).Should(BeTrue())
})
})
Expand Down Expand Up @@ -168,7 +171,8 @@ var _ = Describe("Drift", Ordered, func() {
JustBeforeEach(func() {
kw := k.Namespace(namespace)
out, err := kw.Patch(
"service", "nginx-service",
"service", "drift-dummy-service",
"-o=json",
"--type=json",
"-p", `[{"op": "replace", "path": "/spec/ports/0/port", "value": 1234}]`,
)
Expand All @@ -179,7 +183,7 @@ var _ = Describe("Drift", Ordered, func() {
Eventually(func() string {
out, _ := k.Namespace(env.Namespace).Get("bundles", bundleName, "-o=jsonpath={.status.conditions[*].message}")
return out
}).Should(ContainSubstring(`service.v1 drift/nginx-service modified {"spec":{"ports":[` +
}).Should(ContainSubstring(`service.v1 drift/drift-dummy-service modified {"spec":{"ports":[` +
`{"name":"http","port":80,"protocol":"TCP","targetPort":"http-web-svc"},` +
`{"name":"http","port":1234,"protocol":"TCP","targetPort":"http-web-svc"}]}}`))
})
Expand Down Expand Up @@ -208,7 +212,8 @@ var _ = Describe("Drift", Ordered, func() {
JustBeforeEach(func() {
kw := k.Namespace(namespace)
out, err := kw.Patch(
"service", "nginx-service",
"service", "drift-dummy-service",
"-o=json",
"--type=json",
"-p", `[{"op": "replace", "path": "/spec/ports/0/port", "value": 1234}]`,
)
Expand All @@ -222,7 +227,7 @@ var _ = Describe("Drift", Ordered, func() {
}).Should(BeTrue())
Eventually(func() bool {
kw := k.Namespace(namespace)
out, _ := kw.Get("services", "nginx-service", "-o=json")
out, _ := kw.Get("services", "drift-dummy-service", "-o=json")
var service corev1.Service
_ = json.Unmarshal([]byte(out), &service)
return service.Spec.Ports[0].Port == 80
Expand Down

0 comments on commit 73182d3

Please sign in to comment.