Skip to content

Commit

Permalink
fixtures: add fixtures for building pods without probes
Browse files Browse the repository at this point in the history
  • Loading branch information
roobre committed Sep 14, 2023
1 parent 28fc3e6 commit 4f19c30
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions e2e/disruptors/pod_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion e2e/disruptors/service_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
16 changes: 16 additions & 0 deletions pkg/testutils/e2e/fixtures/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ func BuildHttpbinPod() corev1.Pod {
Build()
}

// BuildHttpbinPodWithoutProbes returns the same pod as BuildHttpbinPod would, but without any probes.
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").
Expand Down Expand Up @@ -97,6 +105,14 @@ func BuildNginxPod() corev1.Pod {
Build()
}

// BuildNginxPodWithoutProbes returns the same pod as BuildNginxPod would, but without any probes.
func BuildNginxPodWithoutProbes() 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").
Expand Down

0 comments on commit 4f19c30

Please sign in to comment.