mirror of
https://github.com/jenkinsci/kubernetes-operator.git
synced 2026-10-04 15:11:10 +02:00
#190 Improve e2e tests for OpenShift
This commit is contained in:
@@ -216,7 +216,7 @@ func verifyJenkinsMasterPodAttributes(t *testing.T, jenkins *v1alpha2.Jenkins) {
|
||||
jenkinsPod := getJenkinsMasterPod(t, jenkins)
|
||||
jenkins = getJenkins(t, jenkins.Namespace, jenkins.Name)
|
||||
|
||||
assert.Equal(t, jenkins.Spec.Master.Annotations, jenkinsPod.ObjectMeta.Annotations)
|
||||
assertMapContainsElementsFromAnotherMap(t, jenkins.Spec.Master.Annotations, jenkinsPod.ObjectMeta.Annotations)
|
||||
assert.Equal(t, jenkins.Spec.Master.NodeSelector, jenkinsPod.Spec.NodeSelector)
|
||||
|
||||
assert.Equal(t, resources.JenkinsMasterContainerName, jenkinsPod.Spec.Containers[0].Name)
|
||||
@@ -225,8 +225,6 @@ func verifyJenkinsMasterPodAttributes(t *testing.T, jenkins *v1alpha2.Jenkins) {
|
||||
assert.Equal(t, jenkins.Spec.Master.SecurityContext, jenkinsPod.Spec.SecurityContext)
|
||||
assert.Equal(t, jenkins.Spec.Master.Containers[0].Command, jenkinsPod.Spec.Containers[0].Command)
|
||||
|
||||
assert.Equal(t, jenkins.Spec.Master.ImagePullSecrets, jenkinsPod.Spec.ImagePullSecrets)
|
||||
|
||||
assert.Equal(t, resources.GetJenkinsMasterPodLabels(*jenkins), jenkinsPod.Labels)
|
||||
|
||||
for _, actualContainer := range jenkinsPod.Spec.Containers {
|
||||
@@ -347,3 +345,14 @@ if (!"%s".equals(Jenkins.instance.systemMessage)) {
|
||||
logs, err = jenkinsClient.ExecuteScript(checkConfigurationAsCode)
|
||||
assert.NoError(t, err, logs)
|
||||
}
|
||||
|
||||
func assertMapContainsElementsFromAnotherMap(t *testing.T, expected map[string]string, actual map[string]string) {
|
||||
for key, expectedValue := range expected {
|
||||
actualValue, keyExists := actual[key]
|
||||
if !keyExists {
|
||||
assert.Failf(t, "key '%s' doesn't exist in map '%+v'", key, actual)
|
||||
continue
|
||||
}
|
||||
assert.Equal(t, expectedValue, actualValue, expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
+15
-1
@@ -127,6 +127,12 @@ func createJenkinsCR(t *testing.T, name, namespace string, seedJob *[]v1alpha2.S
|
||||
TimeoutSeconds: int32(4),
|
||||
FailureThreshold: int32(10),
|
||||
},
|
||||
VolumeMounts: []corev1.VolumeMount{
|
||||
{
|
||||
Name: "plugins-cache",
|
||||
MountPath: "/usr/share/jenkins/ref/plugins",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "envoyproxy",
|
||||
@@ -138,7 +144,15 @@ func createJenkinsCR(t *testing.T, name, namespace string, seedJob *[]v1alpha2.S
|
||||
{Name: "simple-theme-plugin", Version: "0.5.1"},
|
||||
{Name: "github", Version: "1.29.4"},
|
||||
},
|
||||
NodeSelector: map[string]string{"kubernetes.io/hostname": "minikube"},
|
||||
NodeSelector: map[string]string{"kubernetes.io/os": "linux"},
|
||||
Volumes: []corev1.Volume{
|
||||
{
|
||||
Name: "plugins-cache",
|
||||
VolumeSource: corev1.VolumeSource{
|
||||
EmptyDir: &corev1.EmptyDirVolumeSource{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
SeedJobs: seedJobs,
|
||||
Service: v1alpha2.Service{
|
||||
|
||||
@@ -140,6 +140,10 @@ func createJenkinsWithBackupAndRestoreConfigured(t *testing.T, name, namespace s
|
||||
Name: "jenkins-home",
|
||||
MountPath: "/jenkins-home",
|
||||
},
|
||||
{
|
||||
Name: "plugins-cache",
|
||||
MountPath: "/usr/share/jenkins/ref/plugins",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -152,6 +156,12 @@ func createJenkinsWithBackupAndRestoreConfigured(t *testing.T, name, namespace s
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "plugins-cache",
|
||||
VolumeSource: corev1.VolumeSource{
|
||||
EmptyDir: &corev1.EmptyDirVolumeSource{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
SeedJobs: []v1alpha2.SeedJob{
|
||||
|
||||
Reference in New Issue
Block a user