Commit 3e7b44e1 authored by ismail's avatar ismail
Browse files

CI: correction in the HTML reporting


Signed-off-by: default avatarismail <mohammed.ismail@openairinterface.org>
parent 7bec2dbc
......@@ -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}"
}
}
......
......@@ -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')
......
......@@ -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)
......
......@@ -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')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment