Skip to content

Commit

Permalink
add test to check livenessProbe
Browse files Browse the repository at this point in the history
  • Loading branch information
swang392 committed Sep 13, 2024
1 parent 4947924 commit 5d3df23
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion test/datadog-operator/operator_deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ func Test_operator_chart(t *testing.T) {
assertions: verifyAll,
skipTest: SkipTest,
},
{
name: "livenessProbe is correctly configured",
command: common.HelmCommand{
ReleaseName: "datadog-operator",
ChartPath: "../../charts/datadog-operator",
ShowOnly: []string{"templates/deployment.yaml"},
Values: []string{"../../charts/datadog-operator/values.yaml"},
Overrides: map[string]string{},
},
assertions: verifyLivenessProbe,
skipTest: SkipTest,
},
}

for _, tt := range tests {
Expand All @@ -73,7 +85,6 @@ func Test_operator_chart(t *testing.T) {
func verifyDeployment(t *testing.T, manifest string) {
var deployment appsv1.Deployment
common.Unmarshal(t, manifest, &deployment)

assert.Equal(t, 1, len(deployment.Spec.Template.Spec.Containers))
operatorContainer := deployment.Spec.Template.Spec.Containers[0]
assert.Equal(t, v1.PullPolicy("IfNotPresent"), operatorContainer.ImagePullPolicy)
Expand All @@ -85,3 +96,11 @@ func verifyDeployment(t *testing.T, manifest string) {
func verifyAll(t *testing.T, manifest string) {
assert.True(t, manifest != "")
}

func verifyLivenessProbe(t *testing.T, manifest string) {
var deployment appsv1.Deployment
common.Unmarshal(t, manifest, &deployment)
assert.Equal(t, 1, len(deployment.Spec.Template.Spec.Containers))
operatorContainer := deployment.Spec.Template.Spec.Containers[0]
assert.Equal(t, "/healthz/", operatorContainer.LivenessProbe.HTTPGet.Path)
}

0 comments on commit 5d3df23

Please sign in to comment.