#190 Improve e2e tests for OpenShift

This commit is contained in:
Tomasz Sęk
2020-03-22 12:24:05 +01:00
parent 2cecbba8b2
commit 7356a5ec49
6 changed files with 45 additions and 90 deletions
+12 -3
View File
@@ -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
View File
@@ -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{
+10
View File
@@ -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{