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
nadiamoe authored and pablochacin committed Nov 13, 2024
1 parent fca5781 commit 544fa20
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
19 changes: 10 additions & 9 deletions e2e/disruptors/pod_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ func Test_PodDisruptor(t *testing.T) {
check checks.Check
}{
{
title: "Inject Http error 500",
pod: fixtures.BuildHttpbinPod(),

title: "Inject Http error 500",
pod: fixtures.BuildHttpbinPodWithoutProbes(),
replicas: 1,
service: fixtures.BuildHttpbinService(),
port: 80,
service: fixtures.BuildHttpbinService(),
port: 80,
injector: func(d disruptors.PodDisruptor) error {
fault := disruptors.HTTPFault{
Port: intstr.FromInt32(80),
Expand All @@ -97,11 +98,11 @@ func Test_PodDisruptor(t *testing.T) {
},
},
{
title: "Inject Grpc error",
pod: fixtures.BuildGrpcpbinPod(),
title: "Inject Grpc error",
pod: fixtures.BuildGrpcpbinPod(),
replicas: 1,
service: fixtures.BuildGrpcbinService(),
port: 9000,
service: fixtures.BuildGrpcbinService(),
port: 9000,
injector: func(d disruptors.PodDisruptor) error {
fault := disruptors.GrpcFault{
Port: intstr.FromInt32(9000),
Expand Down Expand Up @@ -231,7 +232,7 @@ func Test_PodDisruptor(t *testing.T) {
err = deploy.ExposeApp(
k8s,
namespace,
fixtures.BuildHttpbinPod(),
fixtures.BuildHttpbinPodWithoutProbes(), // Probes generate requests, invalidating the test.
1,
service,
k8sintstr.FromInt(80),
Expand Down
10 changes: 5 additions & 5 deletions e2e/disruptors/service_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ func Test_ServiceDisruptor(t *testing.T) {
check checks.Check
}{
{
title: "Inject Http error 500",
pod: fixtures.BuildHttpbinPod(),
replicas: 1,
service: fixtures.BuildHttpbinService(),
port: 80,

title: "Inject Http error 500",
pod: fixtures.BuildHttpbinPodWithoutProbes(),
service: fixtures.BuildHttpbinService(),
port: 80,
injector: func(d disruptors.ServiceDisruptor) error {
fault := disruptors.HTTPFault{
Port: intstr.FromInt32(80),
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 544fa20

Please sign in to comment.