Add Readiness and Liveness probes - code cleanup
This commit is contained in:
parent
3dde0b0f56
commit
70f35c47f0
|
|
@ -10,8 +10,8 @@ spec:
|
|||
path: /login
|
||||
port: 8080
|
||||
scheme: HTTP
|
||||
failureThreshold: 12
|
||||
initialDelaySeconds: 20
|
||||
failureThreshold: 10
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 10
|
||||
successThreshold: 1
|
||||
timeoutSeconds: 5
|
||||
|
|
@ -20,8 +20,8 @@ spec:
|
|||
path: /login
|
||||
port: 8080
|
||||
scheme: HTTP
|
||||
initialDelaySeconds: 20
|
||||
failureThreshold: 12
|
||||
initialDelaySeconds: 35
|
||||
failureThreshold: 10
|
||||
periodSeconds: 10
|
||||
successThreshold: 1
|
||||
timeoutSeconds: 5
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package jenkins
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
"reflect"
|
||||
|
||||
"github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkinsio/v1alpha1"
|
||||
|
|
@ -22,6 +21,7 @@ import (
|
|||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/controller"
|
||||
"sigs.k8s.io/controller-runtime/pkg/handler"
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ func TestConfiguration(t *testing.T) {
|
|||
// Deletes test namespace
|
||||
defer ctx.Cleanup()
|
||||
|
||||
t.Logf("BASE")
|
||||
jenkinsCRName := "e2e"
|
||||
numberOfExecutors := 6
|
||||
systemMessage := "Configuration as Code integration works!!!"
|
||||
|
|
@ -43,7 +42,6 @@ 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})
|
||||
|
|
@ -141,30 +139,32 @@ func verifyJenkinsMasterPodAttributes(t *testing.T, jenkins *v1alpha1.Jenkins) {
|
|||
}
|
||||
}
|
||||
|
||||
if jenkinsPod.Spec.Containers[0].Image != jenkins.Spec.Master.Image {
|
||||
t.Fatalf("Invalid jenkins pod image expected '%s', actual '%s'", jenkins.Spec.Master.Image, jenkinsPod.Spec.Containers[0].Image)
|
||||
jenkinsContainer := jenkinsPod.Spec.Containers[0]
|
||||
|
||||
if jenkinsContainer.Image != jenkins.Spec.Master.Image {
|
||||
t.Fatalf("Invalid jenkins pod image expected '%s', actual '%s'", jenkins.Spec.Master.Image, jenkinsContainer.Image)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(jenkinsPod.Spec.Containers[0].Resources, jenkins.Spec.Master.Resources) {
|
||||
t.Fatalf("Invalid jenkins pod continer resources expected '%+v', actual '%+v'", jenkins.Spec.Master.Resources, jenkinsPod.Spec.Containers[0].Resources)
|
||||
if !reflect.DeepEqual(jenkinsContainer.Resources, jenkins.Spec.Master.Resources) {
|
||||
t.Fatalf("Invalid jenkins pod continer resources expected '%+v', actual '%+v'", jenkins.Spec.Master.Resources, jenkinsContainer.Resources)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(jenkinsPod.Spec.NodeSelector, jenkins.Spec.Master.NodeSelector) {
|
||||
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(jenkinsContainer.ReadinessProbe, jenkins.Spec.Master.ReadinessProbe) {
|
||||
t.Fatalf("Invalid jenkins pod readinessProbe. Expected '%+v', actual '%+v'", jenkins.Spec.Master.ReadinessProbe, jenkinsContainer.ReadinessProbe)
|
||||
}
|
||||
|
||||
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)
|
||||
if !reflect.DeepEqual(jenkinsContainer.LivenessProbe, jenkins.Spec.Master.LivenessProbe) {
|
||||
t.Fatalf("Invalid jenkins pod livenessProbe. Expected '%+v', actual '%+v'", jenkins.Spec.Master.LivenessProbe, jenkinsContainer.LivenessProbe)
|
||||
}
|
||||
|
||||
requiredEnvs := resources.GetJenkinsMasterPodBaseEnvs()
|
||||
requiredEnvs = append(requiredEnvs, jenkins.Spec.Master.Env...)
|
||||
if !reflect.DeepEqual(jenkinsPod.Spec.Containers[0].Env, requiredEnvs) {
|
||||
t.Fatalf("Invalid jenkins pod continer resources expected '%+v', actual '%+v'", requiredEnvs, jenkinsPod.Spec.Containers[0].Env)
|
||||
if !reflect.DeepEqual(jenkinsContainer.Env, requiredEnvs) {
|
||||
t.Fatalf("Invalid jenkins pod continer resources expected '%+v', actual '%+v'", requiredEnvs, jenkinsContainer.Env)
|
||||
}
|
||||
|
||||
t.Log("Jenkins pod attributes are valid")
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package e2e
|
|||
|
||||
import (
|
||||
"context"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
"testing"
|
||||
|
||||
"github.com/jenkinsci/kubernetes-operator/pkg/apis/jenkinsio/v1alpha1"
|
||||
|
|
@ -15,6 +14,7 @@ import (
|
|||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
)
|
||||
|
||||
func getJenkins(t *testing.T, namespace, name string) *v1alpha1.Jenkins {
|
||||
|
|
@ -94,7 +94,9 @@ func createJenkinsCR(t *testing.T, name, namespace string, seedJob *[]v1alpha1.S
|
|||
Scheme: corev1.URISchemeHTTP,
|
||||
},
|
||||
},
|
||||
InitialDelaySeconds: int32(50),
|
||||
InitialDelaySeconds: int32(35),
|
||||
TimeoutSeconds: int32(4),
|
||||
FailureThreshold: int32(10),
|
||||
},
|
||||
LivenessProbe: &corev1.Probe{
|
||||
Handler: corev1.Handler{
|
||||
|
|
@ -105,8 +107,8 @@ func createJenkinsCR(t *testing.T, name, namespace string, seedJob *[]v1alpha1.S
|
|||
},
|
||||
},
|
||||
InitialDelaySeconds: int32(40),
|
||||
TimeoutSeconds: int32(8),
|
||||
FailureThreshold: int32(15),
|
||||
TimeoutSeconds: int32(4),
|
||||
FailureThreshold: int32(10),
|
||||
},
|
||||
},
|
||||
SeedJobs: seedJobs,
|
||||
|
|
|
|||
Loading…
Reference in New Issue