Fixed e2e tests

This commit is contained in:
Jakub Al-Khalili 2019-07-08 15:11:12 +02:00
parent 05a446e4a2
commit 5e22cdfdce
4 changed files with 20 additions and 20 deletions

View File

@ -40,31 +40,29 @@ func TestConfiguration(t *testing.T) {
RepositoryURL: "https://github.com/jenkinsci/kubernetes-operator.git", RepositoryURL: "https://github.com/jenkinsci/kubernetes-operator.git",
}, },
} }
volumes := []corev1.Volume{ groovyScripts := v1alpha2.GroovyScripts{
{ Customization: v1alpha2.Customization{
Name: "test-configmap", Configurations: []v1alpha2.ConfigMapRef{
VolumeSource: corev1.VolumeSource{ {userConfigurationConfigMapName},
ConfigMap: &corev1.ConfigMapVolumeSource{
LocalObjectReference: corev1.LocalObjectReference{
Name: userConfigurationConfigMapName,
},
},
}, },
Secret:v1alpha2.SecretRef{userConfigurationSecretName },
}, },
{ }
Name: "test-secret",
VolumeSource: corev1.VolumeSource{
Secret: &corev1.SecretVolumeSource{ casc := v1alpha2.ConfigurationAsCode{
SecretName: userConfigurationSecretName, Customization: v1alpha2.Customization{
}, Configurations: []v1alpha2.ConfigMapRef{
{userConfigurationConfigMapName},
}, },
Secret:v1alpha2.SecretRef{userConfigurationSecretName },
}, },
} }
// base // base
createUserConfigurationSecret(t, namespace, systemMessageEnvName, systemMessage) createUserConfigurationSecret(t, namespace, systemMessageEnvName, systemMessage)
createUserConfigurationConfigMap(t, namespace, numberOfExecutors, fmt.Sprintf("${%s}", systemMessageEnvName)) createUserConfigurationConfigMap(t, namespace, numberOfExecutors, fmt.Sprintf("${%s}", systemMessageEnvName))
jenkins := createJenkinsCR(t, jenkinsCRName, namespace, &[]v1alpha2.SeedJob{mySeedJob.SeedJob}, volumes) jenkins := createJenkinsCR(t, jenkinsCRName, namespace, &[]v1alpha2.SeedJob{mySeedJob.SeedJob}, groovyScripts, casc)
createDefaultLimitsForContainersInNamespace(t, namespace) createDefaultLimitsForContainersInNamespace(t, namespace)
createKubernetesCredentialsProviderSecret(t, namespace, mySeedJob) createKubernetesCredentialsProviderSecret(t, namespace, mySeedJob)
waitForJenkinsBaseConfigurationToComplete(t, jenkins) waitForJenkinsBaseConfigurationToComplete(t, jenkins)

View File

@ -65,7 +65,7 @@ func createJenkinsAPIClient(jenkins *v1alpha2.Jenkins) (jenkinsclient.Jenkins, e
) )
} }
func createJenkinsCR(t *testing.T, name, namespace string, seedJob *[]v1alpha2.SeedJob, volumes []corev1.Volume) *v1alpha2.Jenkins { func createJenkinsCR(t *testing.T, name, namespace string, seedJob *[]v1alpha2.SeedJob, groovyScripts v1alpha2.GroovyScripts, casc v1alpha2.ConfigurationAsCode) *v1alpha2.Jenkins {
var seedJobs []v1alpha2.SeedJob var seedJobs []v1alpha2.SeedJob
if seedJob != nil { if seedJob != nil {
seedJobs = append(seedJobs, *seedJob...) seedJobs = append(seedJobs, *seedJob...)
@ -78,6 +78,8 @@ func createJenkinsCR(t *testing.T, name, namespace string, seedJob *[]v1alpha2.S
Namespace: namespace, Namespace: namespace,
}, },
Spec: v1alpha2.JenkinsSpec{ Spec: v1alpha2.JenkinsSpec{
GroovyScripts:groovyScripts,
ConfigurationAsCode:casc,
Master: v1alpha2.JenkinsMaster{ Master: v1alpha2.JenkinsMaster{
Annotations: map[string]string{"test": "label"}, Annotations: map[string]string{"test": "label"},
Containers: []v1alpha2.Container{ Containers: []v1alpha2.Container{

View File

@ -20,7 +20,7 @@ func TestJenkinsMasterPodRestart(t *testing.T) {
// Deletes test namespace // Deletes test namespace
defer ctx.Cleanup() defer ctx.Cleanup()
jenkins := createJenkinsCR(t, "e2e", namespace, nil, []corev1.Volume{}) jenkins := createJenkinsCR(t, "e2e", namespace, nil, v1alpha2.GroovyScripts{}, v1alpha2.ConfigurationAsCode{})
waitForJenkinsBaseConfigurationToComplete(t, jenkins) waitForJenkinsBaseConfigurationToComplete(t, jenkins)
restartJenkinsMasterPod(t, jenkins) restartJenkinsMasterPod(t, jenkins)
waitForRecreateJenkinsMasterPod(t, jenkins) waitForRecreateJenkinsMasterPod(t, jenkins)
@ -36,7 +36,7 @@ func TestSafeRestart(t *testing.T) {
jenkinsCRName := "e2e" jenkinsCRName := "e2e"
configureAuthorizationToUnSecure(t, namespace) configureAuthorizationToUnSecure(t, namespace)
jenkins := createJenkinsCR(t, jenkinsCRName, namespace, nil, []corev1.Volume{}) jenkins := createJenkinsCR(t, jenkinsCRName, namespace, nil, v1alpha2.GroovyScripts{}, v1alpha2.ConfigurationAsCode{})
waitForJenkinsBaseConfigurationToComplete(t, jenkins) waitForJenkinsBaseConfigurationToComplete(t, jenkins)
waitForJenkinsUserConfigurationToComplete(t, jenkins) waitForJenkinsUserConfigurationToComplete(t, jenkins)
jenkinsClient := verifyJenkinsAPIConnection(t, jenkins) jenkinsClient := verifyJenkinsAPIConnection(t, jenkins)

View File

@ -51,7 +51,7 @@ func TestSeedJobs(t *testing.T) {
createKubernetesCredentialsProviderSecret(t, namespace, seedJobConfig) createKubernetesCredentialsProviderSecret(t, namespace, seedJobConfig)
seedJobs = append(seedJobs, seedJobConfig.SeedJob) seedJobs = append(seedJobs, seedJobConfig.SeedJob)
} }
jenkins := createJenkinsCR(t, jenkinsCRName, namespace, &seedJobs, []corev1.Volume{}) jenkins := createJenkinsCR(t, jenkinsCRName, namespace, &seedJobs, v1alpha2.GroovyScripts{}, v1alpha2.ConfigurationAsCode{})
waitForJenkinsBaseConfigurationToComplete(t, jenkins) waitForJenkinsBaseConfigurationToComplete(t, jenkins)
verifyJenkinsMasterPodAttributes(t, jenkins) verifyJenkinsMasterPodAttributes(t, jenkins)