From ecf85ec6be40ce53b6434c1bdf1bbdd07616a2bc Mon Sep 17 00:00:00 2001
From: Mohammed Ismail <mohammed.ismail@openairinterface.org>
Date: Fri, 6 Aug 2021 16:45:26 +0200
Subject: [PATCH] CI: added env for dstester version checkout and updated
 accordingly

Signed-off-by: Mohammed Ismail <mohammed.ismail@openairinterface.org>
---
 ci-scripts/Jenkinsfile-GitLab-Docker    | 17 +++++++++++------
 ci-scripts/Jenkinsfile-GitLab-Helm      | 17 +++++++++++------
 ci-scripts/dsTestGenerateHTMLReport1.py |  8 ++++----
 ci-scripts/dsTestGenerateHTMLReport2.py |  8 ++++----
 ci-scripts/toCheckDSTesterResult1.py    |  5 +++--
 5 files changed, 33 insertions(+), 22 deletions(-)

diff --git a/ci-scripts/Jenkinsfile-GitLab-Docker b/ci-scripts/Jenkinsfile-GitLab-Docker
index 7e100fe2..ef04b739 100644
--- a/ci-scripts/Jenkinsfile-GitLab-Docker
+++ b/ci-scripts/Jenkinsfile-GitLab-Docker
@@ -52,6 +52,9 @@ def dsT_host = ""
 def dsT_host_user = ""
 def dsT_host_ip_addr = ""
 
+// dsTester tag to use
+def dsTesterTag = params.DSTESTER_TAG
+
 // Flags
 def scmEvent = false
 def upstreamEvent = false
@@ -327,12 +330,14 @@ pipeline {
                 [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.dsTesterGitLabRepository_Credentials}", usernameVariable: 'git_username', passwordVariable: 'git_token']
               ]) {
                 sh "git clone https://${git_username}:${git_token}@github.com/OPENAIRINTERFACE/chasseur.git . > ../git_clone.log 2>&1"
-                sh "git checkout develop >> ../git_clone.log 2>&1"
-                try {
-                  sh "python3 jenkins/dogmatix-agent.py -f jenkins/suit-docker-compose.yaml | tee ../DS-TEST-RESULTS/dsTester_Summary.txt"
-                } catch (Exception e) {
-                  currentBuild.result = 'FAILURE'
-                  echo "dsTester Running FAILED"
+                sh "git checkout -f " + dsTesterTag + " >> ../git_clone.log 2>&1"
+                dir ('jenkins') {
+                  try {
+                    sh "python3 ./dogmatix-agent.py -f ./suits/dc/integration.yaml -d true | tee ../DS-TEST-RESULTS/dsTester_Summary.txt"
+                  } catch (Exception e) {
+                    currentBuild.result = 'FAILURE'
+                    echo "dsTester Running FAILED"
+                  }
                 } 
               }
             }
diff --git a/ci-scripts/Jenkinsfile-GitLab-Helm b/ci-scripts/Jenkinsfile-GitLab-Helm
index 2714b2ed..c6c0b4eb 100644
--- a/ci-scripts/Jenkinsfile-GitLab-Helm
+++ b/ci-scripts/Jenkinsfile-GitLab-Helm
@@ -47,6 +47,9 @@ def dsT_host = ""
 def dsT_host_user = ""
 def dsT_host_ip_addr = ""
 
+// dsTester tag to use
+def dsTesterTag = params.DSTESTER_TAG
+
 // Flags
 def scmEvent = false
 def upstreamEvent = false
@@ -189,12 +192,14 @@ pipeline {
                 [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.dsTesterGitLabRepository_Credentials}", usernameVariable: 'git_username', passwordVariable: 'git_token']
               ]) {
                 sh "git clone https://${git_username}:${git_token}@github.com/OPENAIRINTERFACE/chasseur.git . > ../git_clone.log 2>&1"
-                sh "git checkout develop >> ../git_clone.log 2>&1"
-                try {
-                  sh "python3 jenkins/dogmatix-agent.py -f jenkins/suit-helm-charts.yaml | tee ../DS-TEST-RESULTS/dsTester_Summary.txt"
-                } catch (Exception e) {
-                  currentBuild.result = 'FAILURE'
-                  echo "dsTester Running FAILED"
+                sh "git checkout -f " + dsTesterTag + " >> ../git_clone.log 2>&1"
+                dir ('jenkins') {
+                  try {
+                    sh "python3 ./dogmatix-agent.py -f ./suits/hc/integration.yaml -d true | tee ../DS-TEST-RESULTS/dsTester_Summary.txt"
+                  } catch (Exception e) {
+                    currentBuild.result = 'FAILURE'
+                    echo "dsTester Running FAILED"
+                  }
                 } 
               }
             }
diff --git a/ci-scripts/dsTestGenerateHTMLReport1.py b/ci-scripts/dsTestGenerateHTMLReport1.py
index 5ffb22b9..9d342a20 100644
--- a/ci-scripts/dsTestGenerateHTMLReport1.py
+++ b/ci-scripts/dsTestGenerateHTMLReport1.py
@@ -247,8 +247,8 @@ class HtmlReport():
 		self.file.write('  <h2>DS Tester Summary</h2>\n')
 		cwd = os.getcwd()
 		finalStatusOK = False
-		if os.path.isfile(cwd + '/DS-TEST-RESULTS/5gcn.yaml'):
-			cmd = f'egrep -c "final-result: pass" DS-TEST-RESULTS/5gcn.yaml || true'
+		if os.path.isfile(cwd + '/DS-TEST-RESULTS/hcintegration.yaml'):
+			cmd = f'egrep -c "final-result: pass" DS-TEST-RESULTS/hcintegration.yaml || true'
 			ret = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, encoding='utf-8')
 			if ret.stdout is not None:
 				if ret.stdout.strip() == '1':
@@ -281,8 +281,8 @@ class HtmlReport():
 		self.file.write('      <th>Test Details</th>\n')
 		self.file.write('    </tr>\n')
 		cwd = os.getcwd()
-		if os.path.isfile(cwd + '/DS-TEST-RESULTS/5gcn.yaml'):
-			with open(cwd + '/DS-TEST-RESULTS/5gcn.yaml') as f:
+		if os.path.isfile(cwd + '/DS-TEST-RESULTS/hcintegration.yaml'):
+			with open(cwd + '/DS-TEST-RESULTS/hcintegration.yaml') as f:
 				data = yaml.load(f)
 				nScenarios = len(data['scenarios'])
 				for scenario in range(nScenarios):
diff --git a/ci-scripts/dsTestGenerateHTMLReport2.py b/ci-scripts/dsTestGenerateHTMLReport2.py
index eb18279b..0e474774 100644
--- a/ci-scripts/dsTestGenerateHTMLReport2.py
+++ b/ci-scripts/dsTestGenerateHTMLReport2.py
@@ -216,8 +216,8 @@ class HtmlReport():
 		self.file.write('  <h2>DS Tester Summary</h2>\n')
 		cwd = os.getcwd()
 		finalStatusOK = False
-		if os.path.isfile(cwd + '/DS-TEST-RESULTS/5gcn.yaml'):
-			cmd = f'egrep -c "final-result: pass" DS-TEST-RESULTS/5gcn.yaml || true'
+		if os.path.isfile(cwd + '/DS-TEST-RESULTS/mvc.yaml'):
+			cmd = f'egrep -c "final-result: pass" DS-TEST-RESULTS/mvc.yaml || true'
 			ret = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, encoding='utf-8')
 			if ret.stdout is not None:
 				if ret.stdout.strip() == '1':
@@ -250,8 +250,8 @@ class HtmlReport():
 		self.file.write('      <th>Test Details</th>\n')
 		self.file.write('    </tr>\n')
 		cwd = os.getcwd()
-		if os.path.isfile(cwd + '/DS-TEST-RESULTS/5gcn.yaml'):
-			with open(cwd + '/DS-TEST-RESULTS/5gcn.yaml') as f:
+		if os.path.isfile(cwd + '/DS-TEST-RESULTS/mvc.yaml'):
+			with open(cwd + '/DS-TEST-RESULTS/mvc.yaml') as f:
 				data = yaml.load(f)
 				nScenarios = len(data['scenarios'])
 				for scenario in range(nScenarios):
diff --git a/ci-scripts/toCheckDSTesterResult1.py b/ci-scripts/toCheckDSTesterResult1.py
index 42d52ab4..8b936654 100644
--- a/ci-scripts/toCheckDSTesterResult1.py
+++ b/ci-scripts/toCheckDSTesterResult1.py
@@ -35,6 +35,7 @@ try:
                 result = re.search('(?:\/.+?\/)(.+?)(?:\/.+)', str(line))
                 if result:
                     result1 = re.search('^(.*/)([^/]*)$', str(result.group(0)))
+                    filename = re.search('[^/]*$', str(result1.group(0))) 
                     subprocess.check_output(f'cp {result1.group(1)}* DS-TEST-RESULTS/', stderr=subprocess.STDOUT, shell=True, universal_newlines=True)
                 locexist = True
 except IOError:
@@ -42,9 +43,9 @@ except IOError:
 
 if locexist:
     try:
-        with open(cwd + '/DS-TEST-RESULTS/5gcn.yaml') as f:
+        with open(cwd + f'/DS-TEST-RESULTS/{filename.group(0)}') as f:
             data = yaml.load(f)
             if data["final-result"] == 'fail':
                 sys.exit('DsTester final result FAILED')
     except IOError:
-        sys.exit("File not accessible to check DSTester result: DS-TEST-RESULTS/5gcn.yaml")
\ No newline at end of file
+        sys.exit(f'File not accessible to check DSTester result: DS-TEST-RESULTS/{filename.group(0)}')
-- 
GitLab