From 4e7747e1c478c52f1f22ba2960a17b72723043c3 Mon Sep 17 00:00:00 2001 From: Roberto Santalla Date: Thu, 14 Sep 2023 17:37:29 +0200 Subject: [PATCH] fixtures: add fixtures for building pods without probes --- e2e/disruptors/pod_e2e_test.go | 4 ++-- e2e/disruptors/service_e2e_test.go | 2 +- pkg/testutils/e2e/fixtures/fixtures.go | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/e2e/disruptors/pod_e2e_test.go b/e2e/disruptors/pod_e2e_test.go index aa29c22a..b388e6b2 100644 --- a/e2e/disruptors/pod_e2e_test.go +++ b/e2e/disruptors/pod_e2e_test.go @@ -66,7 +66,7 @@ func Test_PodDisruptor(t *testing.T) { }{ { title: "Inject Http error 500", - pod: fixtures.BuildHttpbinPod(), + pod: fixtures.BuildHttpbinPodWithoutProbes(), service: fixtures.BuildHttpbinService(), port: 80, injector: func(d disruptors.PodDisruptor) error { @@ -223,7 +223,7 @@ func Test_PodDisruptor(t *testing.T) { err = deploy.ExposeApp( k8s, namespace, - fixtures.BuildHttpbinPod(), + fixtures.BuildHttpbinPodWithoutProbes(), // Probes generate requests, invalidating the test. service, intstr.FromInt(80), 30*time.Second, diff --git a/e2e/disruptors/service_e2e_test.go b/e2e/disruptors/service_e2e_test.go index 4a546bd5..d4ab71b9 100644 --- a/e2e/disruptors/service_e2e_test.go +++ b/e2e/disruptors/service_e2e_test.go @@ -60,7 +60,7 @@ func Test_ServiceDisruptor(t *testing.T) { }{ { title: "Inject Http error 500", - pod: fixtures.BuildHttpbinPod(), + pod: fixtures.BuildHttpbinPodWithoutProbes(), service: fixtures.BuildHttpbinService(), port: 80, injector: func(d disruptors.ServiceDisruptor) error { diff --git a/pkg/testutils/e2e/fixtures/fixtures.go b/pkg/testutils/e2e/fixtures/fixtures.go index 6d4dc07c..4686347e 100644 --- a/pkg/testutils/e2e/fixtures/fixtures.go +++ b/pkg/testutils/e2e/fixtures/fixtures.go @@ -23,6 +23,13 @@ func BuildHttpbinPod() corev1.Pod { Build() } +func BuildHttpbinPodWithoutProbes() corev1.Pod { + pod := BuildHttpbinPod() + pod.Spec.Containers[0].ReadinessProbe = nil + + return pod +} + // BuildGrpcpbinPod returns the definition for deploying grpcbin as a Pod func BuildGrpcpbinPod() corev1.Pod { c := builders.NewContainerBuilder("grpcbin"). @@ -97,6 +104,13 @@ func BuildNginxPod() corev1.Pod { Build() } +func BuildNginxPodWithoutPobes() corev1.Pod { + pod := BuildNginxPod() + pod.Spec.Containers[0].ReadinessProbe = nil + + return pod +} + // BuildNginxService returns the definition of a Service that exposes the nginx pod(s) func BuildNginxService() corev1.Service { return builders.NewServiceBuilder("nginx").