diff --git a/ci-scripts/Jenkinsfile-GitLab-Helm b/ci-scripts/Jenkinsfile-GitLab-Helm index 9fd0342b93f726347c5666f501246876b3dab4c4..0fea03c57ee77015517c85327aa8b80f94d53723 100644 --- a/ci-scripts/Jenkinsfile-GitLab-Helm +++ b/ci-scripts/Jenkinsfile-GitLab-Helm @@ -189,13 +189,22 @@ pipeline { 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.yaml | tee ../DS-TEST-RESULTS/dsTester_Summary.txt" + 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" } } } + withCredentials([ + [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.OC_Credentials}", usernameVariable: 'OC_Username', passwordVariable: 'OC_Password'] + ]) { + try { + sh "python3 ci-scripts/helmDeploy.py --mode=GetLogs --OCUserName=${OC_Username} --OCPassword=${OC_Password} --OCProjectName=${OC_ProjectName} --imageTags=${imageTags}" + } catch (Exception e) { + echo "Unable to collect the logs, configs, pcaps" + } + } sh "python3 ./ci-scripts/toCheckDSTesterResult1.py" } } @@ -208,11 +217,6 @@ pipeline { withCredentials([ [$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.OC_Credentials}", usernameVariable: 'OC_Username', passwordVariable: 'OC_Password'] ]) { - try { - sh "python3 ci-scripts/helmDeploy.py --mode=GetLogs --OCUserName=${OC_Username} --OCPassword=${OC_Password} --OCProjectName=${OC_ProjectName} --imageTags=${imageTags}" - } catch (Exception e) { - echo "Unable to collect the logs, configs, pcaps" - } sh "python3 ci-scripts/helmDeploy.py --mode=UnDeploy --OCUserName=${OC_Username} --OCPassword=${OC_Password} --OCProjectName=${OC_ProjectName} --imageTags=${imageTags}" } } diff --git a/ci-scripts/dsTestGenerateHTMLReport1.py b/ci-scripts/dsTestGenerateHTMLReport1.py index 7ce24335a75b8ac143c6047eea77c41195cdaf4d..2f4261acc2ee6c46c8bef24b5ba9f914b68222fd 100644 --- a/ci-scripts/dsTestGenerateHTMLReport1.py +++ b/ci-scripts/dsTestGenerateHTMLReport1.py @@ -151,8 +151,8 @@ class HtmlReport(): sizeInt = int(sizeInt / 1000000) size = str(sizeInt) + ' MB' imageLog.close() - helmState = 'N/A' - podState = 'N/A' + helmState = 'UNKNOW' + podState = 'UNKNOW' cmd = f'egrep -c "{imageName}: HELM OK" archives/5gcn_helm_summary.txt || true' ret = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, encoding='utf-8') if ret.stdout is not None: @@ -183,23 +183,23 @@ class HtmlReport(): elif helmState == 'KO': self.file.write(' <td bgcolor = "Red"><b><font color="white">' + helmState + '</font></b></td>\n') else: - self.file.write(' <td><b><font color="white">' + helmState + '</font></b></td>\n') + self.file.write(' <td bgcolor = "DarkOrange"><b><font color="white">' + helmState + '</font></b></td>\n') if podState == 'OK': self.file.write(' <td bgcolor = "DarkGreen"><b><font color="white">' + podState + '</font></b></td>\n') elif podState == 'KO': self.file.write(' <td bgcolor = "Red"><b><font color="white">' + podState + '</font></b></td>\n') else: - self.file.write(' <td><b><font color="white">' + podState + '</font></b></td>\n') + self.file.write(' <td bgcolor = "DarkOrange"><b><font color="white">' + podState + '</font></b></td>\n') self.file.write(' </tr>\n') else: if imageName == 'mysql': self.file.write(' <tr>\n') self.file.write(' <td>mysql</td>\n') - self.file.write(' <td>mysql:5.7</td>\n') + self.file.write(' <td>mysql:5.7.30</td>\n') self.file.write(' <td>N/A</td>\n') self.file.write(' <td>449MB</td>\n') - helmState = 'N/A' - podState = 'N/A' + helmState = 'UNKNOW' + podState = 'UNKNOW' cmd = f'egrep -c "{imageName}: HELM OK" archives/5gcn_helm_summary.txt || true' ret = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, encoding='utf-8') if ret.stdout is not None: @@ -225,13 +225,13 @@ class HtmlReport(): elif helmState == 'KO': self.file.write(' <td bgcolor = "Red"><b><font color="white">' + helmState + '</font></b></td>\n') else: - self.file.write(' <td><b><font color="white">' + helmState + '</font></b></td>\n') + self.file.write(' <td bgcolor = "DarkOrange"><b><font color="white">' + helmState + '</font></b></td>\n') if podState == 'OK': self.file.write(' <td bgcolor = "DarkGreen"><b><font color="white">' + podState + '</font></b></td>\n') elif podState == 'KO': self.file.write(' <td bgcolor = "Red"><b><font color="white">' + podState + '</font></b></td>\n') else: - self.file.write(' <td><b><font color="white">' + podState + '</font></b></td>\n') + self.file.write(' <td bgcolor = "DarkOrange"><b><font color="white">' + podState + '</font></b></td>\n') self.file.write(' </tr>\n') else: self.file.write(' <tr>\n') @@ -294,10 +294,12 @@ class HtmlReport(): self.file.write(' <td bgcolor = "DarkGreen"><b><font color="white">OK</font></b></td>\n') else: self.file.write(' <td bgcolor = "DarkOrange"><b><font color="white">UNKNOW</font></b></td>\n') - #testDetails += '</pre>\n' - self.file.write(' <td>' + str(data['scenarios'][scenario]['conditions']) + '</td>\n') + testDetails = '' + for x,y in data['scenarios'][scenario]['conditions'].items(): + testDetails += str(x) + ': ' + str(y) + '\n' + #details += '\n' + self.file.write(' <td><pre>' + testDetails + '</pre></td>\n') self.file.write(' </tr>\n') - #testDetails = '<pre style="background-color:white">\n' else: print ('no details???') self.file.write(' </table>\n') diff --git a/ci-scripts/helmDeploy.py b/ci-scripts/helmDeploy.py index 90658cec015aea5c0b87dd6d98febb2814ab830e..d4b0270c230650a4a8776428305a05254961e7d6 100644 --- a/ci-scripts/helmDeploy.py +++ b/ci-scripts/helmDeploy.py @@ -72,9 +72,9 @@ class ClusterDeploy: if imageName == 'mysql': continue # Check if image is exist on the Red Hat server, before pushing it to OC cluster - subprocess.run(f'echo "IMAGENAME_TAG: {imageName}:{imageTag} > archives/{imageName}_image_info.log', shell=True) + subprocess.run(f'echo "IMAGENAME_TAG: {imageName}:{imageTag}" > archives/{imageName}_image_info.log', shell=True) res = subprocess.check_output("sudo podman image inspect --format='Size = {{.Size}} bytes' " + f'{imageName}:{imageTag} | tee -a archives/{imageName}_image_info.log', shell=True, universal_newlines=True) - subprocess.run(f"sudo podman image inspect --format='Date = {{.Created}}' " + f'{imageName}:{imageTag} | tee -a archives/{imageName}_image_info.log', shell=True) + subprocess.run("sudo podman image inspect --format='Date = {{.Created}}' " + f'{imageName}:{imageTag} >> archives/{imageName}_image_info.log', shell=True) res2 = re.search('no such image', str(res.strip())) if res2 is not None: logging.error(f'\u001B[1m No such image {imageName}]\u001B[0m') @@ -167,14 +167,14 @@ class ClusterDeploy: res = subprocess.check_output(f'helm install {imageName} ./charts/{imageName}/ | tee -a archives/5gcn_helm_summary.txt 2>&1', shell=True, universal_newlines=True) res2 = re.search('STATUS: deployed', str(res.strip())) if res2 is None: - subprocess.run(f'echo "{imageName}: HELM KO" > archives/5gcn_helm_summary.txt', shell=True) + subprocess.run(f'echo "{imageName}: HELM KO" >> archives/5gcn_helm_summary.txt 2>&1', shell=True) logging.error(f'\u001B[1m Deploying "{imageName}" Failed using helm chart on OC Cluster\u001B[0m') logging.error(f'\u001B[1m 5GCN Deployment: KO \u001B[0m') subprocess.run(f'echo "DEPLOYMENT: KO" > archives/deployment_status.log', shell=True) self.UnDeploy_5gcn() sys.exit(-1) else: - subprocess.run(f'echo "{imageName}: HELM OK" > archives/5gcn_helm_summary.txt', shell=True) + subprocess.run(f'echo "{imageName}: HELM OK" >> archives/5gcn_helm_summary.txt 2>&1', shell=True) logging.debug(f'\u001B[1m Deployed "{imageName}" Successfully using helm chart\u001B[0m') time.sleep(20) res = subprocess.check_output(f'oc get pods -o wide -l app.kubernetes.io/instance={imageName} | tee -a archives/5gcn_pods_summary.txt', shell=True, universal_newlines=True) @@ -192,11 +192,13 @@ class ClusterDeploy: res3 = re.search(f'mysqld is alive', str(res.strip())) if res2 is not None or res3 is not None: logging.debug(f'\u001B[1m POD "{imageName}" Service Running Sucessfully\u001B[0m') + subprocess.run(f'echo "{imageName}: POD OK" >> archives/5gcn_pods_summary.txt 2>&1', shell=True) isRunning = True passPods += 1 count +=1 if isRunning == False: logging.error(f'\u001B[1m POD "{imageName}" Service Running FAILED \u001B[0m') + subprocess.run(f'echo "{imageName}: POD KO" >> archives/5gcn_pods_summary.txt 2>&1', shell=True) #self.UnDeploy_5gcn() #sys.exit(-1) diff --git a/ci-scripts/toCheckDSTesterResult1.py b/ci-scripts/toCheckDSTesterResult1.py index cf8c09e253c7d64614d8b67e7fc17b45a2ca9fb0..42d52ab490b1bf8ebed7791cecef5a23de82def6 100644 --- a/ci-scripts/toCheckDSTesterResult1.py +++ b/ci-scripts/toCheckDSTesterResult1.py @@ -24,24 +24,25 @@ import re import sys import subprocess import yaml -import logging +import os locexist = False +cwd = os.getcwd() try: - with open('DS-TEST-RESULTS/dsTester_Summary.txt') as f: + with open(cwd + '/DS-TEST-RESULTS/dsTester_Summary.txt') as f: for line in f: if re.search('Result file is available here', str(line)): result = re.search('(?:\/.+?\/)(.+?)(?:\/.+)', str(line)) if result: result1 = re.search('^(.*/)([^/]*)$', str(result.group(0))) - subprocess.Popen(f'cp {result1.group(1)}* DS-TEST-RESULTS/',shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE) + subprocess.check_output(f'cp {result1.group(1)}* DS-TEST-RESULTS/', stderr=subprocess.STDOUT, shell=True, universal_newlines=True) locexist = True except IOError: sys.exit("File not accessible to check DSTester Summary: DS-TEST-RESULTS/dsTester_Summary.txt") if locexist: try: - with open('DS-TEST-RESULTS/5gcn.yaml') as f: + with open(cwd + '/DS-TEST-RESULTS/5gcn.yaml') as f: data = yaml.load(f) if data["final-result"] == 'fail': sys.exit('DsTester final result FAILED')