From cdf72066771f771b7de550be7eb0608c50942464 Mon Sep 17 00:00:00 2001
From: OZGCloud <ozgcloud@mgm-tp.com>
Date: Tue, 5 Apr 2022 16:40:08 +0200
Subject: [PATCH] fix e2e tests

---
 Jenkinsfile                                   | 35 +++++++++++--------
 .../deployment-values/goofy/ea-values.yaml    |  7 ++--
 .../deployment-values/goofy/values.yaml       |  5 ++-
 .../deployment-values/pluto/ea-values.yaml    |  5 ++-
 .../deployment-values/pluto/values.yaml       |  5 ++-
 5 files changed, 38 insertions(+), 19 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index aacd283660..4f3633e165 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -149,9 +149,10 @@ pipeline {
                     steps {
                         script {
                             def stageName = env.STAGE_NAME
-                            def namespace = generateNamespaceName(stageName)
+                            def bezeichner = generateBezeichner(stageName)
+                            def namespace = generateNamespaceName(bezeichner)
 
-                            startEnvironment(namespace, 'ea-values.yaml', 'ea-values.yaml', IMAGE_TAG)
+                            startEnvironment(namespace, 'ea-values.yaml', 'ea-values.yaml', IMAGE_TAG, bezeichner)
                     
                             def testResult = runTests(stageName, 'einheitlicher-ansprechpartner')
                             
@@ -175,9 +176,10 @@ pipeline {
                     steps {
                         script {
                             def stageName = env.STAGE_NAME
-                            def namespace = generateNamespaceName(stageName)
+                            def bezeichner = generateBezeichner(stageName)
+                            def namespace = generateNamespaceName(bezeichner)
 
-                            startEnvironment(namespace, 'values.yaml', 'values.yaml', IMAGE_TAG)
+                            startEnvironment(namespace, 'values.yaml', 'values.yaml', IMAGE_TAG, bezeichner)
 
                             def testResult = runTests(stageName, 'main-tests')
                             
@@ -304,15 +306,15 @@ pipeline {
     }
 }
 
-Void startEnvironment(String namespace, String goofyValues, String plutoValues, String imageTag){
+Void startEnvironment(String namespace, String goofyValues, String plutoValues, String imageTag, String bezeichner){
     checkIfNamespaceExists(namespace)
 
     parallel(
         startGoofy: {
-		    startGoofy(namespace, goofyValues, imageTag)
+		    startGoofy(namespace, goofyValues, imageTag, bezeichner)
         },
         startPluto: {
-		    startPluto(namespace, plutoValues)
+		    startPluto(namespace, plutoValues, bezeichner)
         }
     )
 }
@@ -340,11 +342,11 @@ Void checkIfNamespaceExists(String namespace) {
     }
 }
 
-Void startPluto(String namespace, String values) {
+Void startPluto(String namespace, String values, String bezeichner) {
     container("k8s") {
         dir('goofy-client/apps/goofy-e2e/deployment-values/pluto') {
         	withCredentials([usernamePassword(credentialsId: 'jenkins-nexus-login', usernameVariable: 'USER', passwordVariable: 'PASSWORD')]) {
-            	sh "helm upgrade --install --create-namespace pluto pluto -f ${values} --namespace ${namespace}" + ' --repo https://nexus.ozg-sh.de/repository/ozg-base-apps --username ${USER} --password ${PASSWORD} --wait --wait-for-jobs'
+            	sh "helm upgrade --install --create-namespace pluto pluto -f ${values} --set kop.bezeichner=${bezeichner} --namespace ${namespace}" + ' --repo https://nexus.ozg-sh.de/repository/ozg-base-apps --username ${USER} --password ${PASSWORD} --wait --wait-for-jobs'
             }
         }
 
@@ -352,11 +354,11 @@ Void startPluto(String namespace, String values) {
     }
 }
 
-Void startGoofy(String namespace, String values, String imageTag) {
+Void startGoofy(String namespace, String values, String imageTag, String bezeichner) {
     container("k8s") {
         dir('goofy-client/apps/goofy-e2e/deployment-values/goofy') {
         	withCredentials([usernamePassword(credentialsId: 'jenkins-nexus-login', usernameVariable: 'USER', passwordVariable: 'PASSWORD')]) {
-            	sh "helm upgrade --install --create-namespace goofy goofy -f ${values} --set image.tag=${imageTag} --namespace ${namespace}" + ' --repo https://nexus.ozg-sh.de/repository/ozg-base-apps --username ${USER} --password ${PASSWORD} --wait --wait-for-jobs'
+            	sh "helm upgrade --install --create-namespace goofy goofy -f ${values} --set image.tag=${imageTag} --set kop.bezeichner=${bezeichner} --namespace ${namespace}" + ' --repo https://nexus.ozg-sh.de/repository/ozg-base-apps --username ${USER} --password ${PASSWORD} --wait --wait-for-jobs'
             }
         }
 	    
@@ -397,11 +399,15 @@ String makeUrlConform(String input) {
     return input.replaceAll(/[^a-zA-Z0-9]+/, "").toLowerCase()
 }
 
-String generateNamespaceName(String stage) {
+String generateBezeichner(String stage) {
     def branchName = makeUrlConform(env.BRANCH_NAME)
     def stageName = makeUrlConform(stage)
     
-    return "e2e-${branchName}${stageName}-dev"
+    return "${branchName}${stageName}"
+}
+
+String generateNamespaceName(String bezeichner) {    
+    return "e2e-${bezeichner}-dev"
 }
 
 Void generateKeycloakUserYaml(String namespace) {
@@ -474,7 +480,8 @@ Void removeKeycloakUser(String namespace) {
 }
 
 String generateCypressConfig(String stage, String testFolder) {
-    def namespace = generateNamespaceName(stage)
+    def bezeichner = generateBezeichner(stage)
+    def namespace = generateNamespaceName(bezeichner)
     def configName = "cypress-ci-"+testFolder+".json"
 
     dir('goofy-client/apps/goofy-e2e/'){
diff --git a/goofy-client/apps/goofy-e2e/deployment-values/goofy/ea-values.yaml b/goofy-client/apps/goofy-e2e/deployment-values/goofy/ea-values.yaml
index 62327ac8b4..e55cc722c9 100644
--- a/goofy-client/apps/goofy-e2e/deployment-values/goofy/ea-values.yaml
+++ b/goofy-client/apps/goofy-e2e/deployment-values/goofy/ea-values.yaml
@@ -2,7 +2,10 @@ sso:
   serverUrl: 'https://sso.dev.ozg-sh.de/auth'
   role_einheitlicher_ansprechpartner: true
 env:
-  sprintProfiles: 'oc,dev,e2e'
+  overrideSpringProfiles: 'oc,dev,ea,e2e'
 plutoName: pluto
 replicaCount: '1'
-scrapeMetricsDisabled: true
\ No newline at end of file
+scrapeMetricsDisabled: true
+kop:
+  bundesland: e2e
+  environment: dev
\ No newline at end of file
diff --git a/goofy-client/apps/goofy-e2e/deployment-values/goofy/values.yaml b/goofy-client/apps/goofy-e2e/deployment-values/goofy/values.yaml
index ab3860f7dc..393960b351 100644
--- a/goofy-client/apps/goofy-e2e/deployment-values/goofy/values.yaml
+++ b/goofy-client/apps/goofy-e2e/deployment-values/goofy/values.yaml
@@ -1,7 +1,10 @@
 sso:
   serverUrl: 'https://sso.dev.ozg-sh.de/auth'
 env:
-  springProfiles: 'oc, dev, e2e'
+  overrideSpringProfiles: 'oc, dev, e2e'
 plutoName: pluto
 replicaCount: '1'
 scrapeMetricsDisabled: true
+kop:
+  bundesland: e2e
+  environment: dev
\ No newline at end of file
diff --git a/goofy-client/apps/goofy-e2e/deployment-values/pluto/ea-values.yaml b/goofy-client/apps/goofy-e2e/deployment-values/pluto/ea-values.yaml
index 48ef8aaab6..143e5a404e 100644
--- a/goofy-client/apps/goofy-e2e/deployment-values/pluto/ea-values.yaml
+++ b/goofy-client/apps/goofy-e2e/deployment-values/pluto/ea-values.yaml
@@ -5,7 +5,7 @@ env:
   aktenzeichen:
     enabled: true
     value: de.itvsh.ozg.pluto.vorgang.AktenzeichenProviderEA
-  springProfiles: "oc,ea,dev,e2e"
+  overrideSpringProfiles: "oc,ea,dev,e2e"
 image:
   tag: snapshot-latest
 kopProxyApi:
@@ -26,3 +26,6 @@ osipostfach:
     host: 10.61.16.6
     port: "3128"
 scrapeMetricsDisabled: true
+kop:
+  bundesland: e2e
+  environment: dev
\ No newline at end of file
diff --git a/goofy-client/apps/goofy-e2e/deployment-values/pluto/values.yaml b/goofy-client/apps/goofy-e2e/deployment-values/pluto/values.yaml
index d915bc5cb5..6b480dc4f3 100644
--- a/goofy-client/apps/goofy-e2e/deployment-values/pluto/values.yaml
+++ b/goofy-client/apps/goofy-e2e/deployment-values/pluto/values.yaml
@@ -5,7 +5,7 @@ env:
   aktenzeichen:
     enabled: false
     value: de.itvsh.ozg.pluto.vorgang.AktenzeichenProviderEA
-  springProfiles: "oc, dev, e2e"
+  overrideSpringProfiles: "oc, dev, e2e"
 image:
   tag: snapshot-latest
 kopProxyApi:
@@ -26,3 +26,6 @@ osipostfach:
     host: 10.61.16.6
     port: "3128"
 scrapeMetricsDisabled: true
+kop:
+  bundesland: e2e
+  environment: dev
\ No newline at end of file
-- 
GitLab