mirror of
https://github.com/jenkinsci/kubernetes-operator.git
synced 2026-10-19 09:10:58 +02:00
Add Readiness and Liveness probes
This commit is contained in:
@@ -25,6 +25,7 @@ func TestConfiguration(t *testing.T) {
|
||||
// Deletes test namespace
|
||||
defer ctx.Cleanup()
|
||||
|
||||
t.Logf("BASE")
|
||||
jenkinsCRName := "e2e"
|
||||
numberOfExecutors := 6
|
||||
systemMessage := "Configuration as Code integration works!!!"
|
||||
@@ -42,6 +43,7 @@ func TestConfiguration(t *testing.T) {
|
||||
}
|
||||
|
||||
// base
|
||||
|
||||
createUserConfigurationSecret(t, jenkinsCRName, namespace, systemMessageEnvName, systemMessage)
|
||||
createUserConfigurationConfigMap(t, jenkinsCRName, namespace, numberOfExecutors, fmt.Sprintf("${%s}", systemMessageEnvName))
|
||||
jenkins := createJenkinsCR(t, jenkinsCRName, namespace, &[]v1alpha1.SeedJob{mySeedJob.SeedJob})
|
||||
@@ -151,6 +153,14 @@ func verifyJenkinsMasterPodAttributes(t *testing.T, jenkins *v1alpha1.Jenkins) {
|
||||
t.Fatalf("Invalid jenkins pod node selector expected '%+v', actual '%+v'", jenkins.Spec.Master.NodeSelector, jenkinsPod.Spec.NodeSelector)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(jenkinsPod.Spec.Containers[0].ReadinessProbe, jenkins.Spec.Master.ReadinessProbe) {
|
||||
t.Fatalf("Invalid jenkins pod readinessProbe. Expected '%+v', actual '%+v'", jenkins.Spec.Master.NodeSelector, jenkinsPod.Spec.NodeSelector)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(jenkinsPod.Spec.Containers[0].LivenessProbe, jenkins.Spec.Master.LivenessProbe) {
|
||||
t.Fatalf("Invalid jenkins pod livenessProbe. Expected '%+v', actual '%+v'", jenkins.Spec.Master.NodeSelector, jenkinsPod.Spec.NodeSelector)
|
||||
}
|
||||
|
||||
requiredEnvs := resources.GetJenkinsMasterPodBaseEnvs()
|
||||
requiredEnvs = append(requiredEnvs, jenkins.Spec.Master.Env...)
|
||||
if !reflect.DeepEqual(jenkinsPod.Spec.Containers[0].Env, requiredEnvs) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package e2e
|
||||
|
||||
import (
|
||||
"context"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
"testing"
|
||||
|
||||
"github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkinsio/v1alpha1"
|
||||
@@ -10,6 +11,7 @@ import (
|
||||
|
||||
framework "github.com/operator-framework/operator-sdk/pkg/test"
|
||||
"k8s.io/api/core/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
@@ -84,6 +86,28 @@ func createJenkinsCR(t *testing.T, name, namespace string, seedJob *[]v1alpha1.S
|
||||
Value: "test_env_value",
|
||||
},
|
||||
},
|
||||
ReadinessProbe: &corev1.Probe{
|
||||
Handler: corev1.Handler{
|
||||
HTTPGet: &corev1.HTTPGetAction{
|
||||
Path: "/login",
|
||||
Port: intstr.FromString("http"),
|
||||
Scheme: corev1.URISchemeHTTP,
|
||||
},
|
||||
},
|
||||
InitialDelaySeconds: int32(50),
|
||||
},
|
||||
LivenessProbe: &corev1.Probe{
|
||||
Handler: corev1.Handler{
|
||||
HTTPGet: &corev1.HTTPGetAction{
|
||||
Path: "/login",
|
||||
Port: intstr.FromString("http"),
|
||||
Scheme: corev1.URISchemeHTTP,
|
||||
},
|
||||
},
|
||||
InitialDelaySeconds: int32(40),
|
||||
TimeoutSeconds: int32(8),
|
||||
FailureThreshold: int32(15),
|
||||
},
|
||||
},
|
||||
SeedJobs: seedJobs,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user