Commit 9388e99a authored by Martin Schurz's avatar Martin Schurz
Browse files

fix: add tests for probes in DeploymentTemplate

parent 6a3894db
Loading
Loading
Loading
Loading
+63 −0
Original line number Diff line number Diff line
@@ -628,6 +628,26 @@ func TestDeploymentTemplate(t *testing.T) {
			ExpectedReadinessProbe: defaultReadinessProbe(),
			ExpectedStartupProbe:   nil,
		},
		{
			CaseName: "exec liveness probe",
			Release:  "production",
			Values: map[string]string{
				"livenessProbe.command[0]": "echo",
				"livenessProbe.command[1]": "hello",
				"livenessProbe.probeType":  "exec",
			},
			ExpectedLivenessProbe: &coreV1.Probe{
				ProbeHandler: coreV1.ProbeHandler{
					Exec: &coreV1.ExecAction{
						Command: []string{"echo", "hello"},
					},
				},
				InitialDelaySeconds: 15,
				TimeoutSeconds:      15,
			},
			ExpectedReadinessProbe: defaultReadinessProbe(),
			ExpectedStartupProbe:   nil,
		},
		{
			CaseName: "custom readiness probe",
			Release:  "production",
@@ -656,6 +676,26 @@ func TestDeploymentTemplate(t *testing.T) {
			},
			ExpectedStartupProbe: nil,
		},
		{
			CaseName: "exec readiness probe",
			Release:  "production",
			Values: map[string]string{
				"readinessProbe.command[0]": "echo",
				"readinessProbe.command[1]": "hello",
				"readinessProbe.probeType":  "exec",
			},
			ExpectedLivenessProbe: defaultLivenessProbe(),
			ExpectedReadinessProbe: &coreV1.Probe{
				ProbeHandler: coreV1.ProbeHandler{
					Exec: &coreV1.ExecAction{
						Command: []string{"echo", "hello"},
					},
				},
				InitialDelaySeconds: 5,
				TimeoutSeconds:      3,
			},
			ExpectedStartupProbe: nil,
		},
		{
			CaseName: "custom startup probe",
			Release:  "production",
@@ -687,6 +727,29 @@ func TestDeploymentTemplate(t *testing.T) {
				PeriodSeconds:       10,
			},
		},
		{
			CaseName: "exec startup probe",
			Release:  "production",
			Values: map[string]string{
				"startupProbe.enabled":    "true",
				"startupProbe.command[0]": "echo",
				"startupProbe.command[1]": "hello",
				"startupProbe.probeType":  "exec",
			},
			ExpectedLivenessProbe:  defaultLivenessProbe(),
			ExpectedReadinessProbe: defaultReadinessProbe(),
			ExpectedStartupProbe: &coreV1.Probe{
				ProbeHandler: coreV1.ProbeHandler{
					Exec: &coreV1.ExecAction{
						Command: []string{"echo", "hello"},
					},
				},
				InitialDelaySeconds: 5,
				TimeoutSeconds:      3,
				FailureThreshold:    30,
				PeriodSeconds:       10,
			},
		},
	} {
		t.Run(tc.CaseName, func(t *testing.T) {
			namespaceName := "minimal-ruby-app-" + strings.ToLower(random.UniqueId())