Skip to content
Snippets Groups Projects
Commit 71ead698 authored by Mohammed Ismail's avatar Mohammed Ismail
Browse files

CI: updated on the routecheck and fix on the Jenkinsfile

parent 7324992f
No related branches found
No related tags found
1 merge request!28CI: integration of new dsTester Framework with Minimal and Basic functionality
......@@ -262,9 +262,6 @@ pipeline {
steps {
lock (ds_tester_ci_resource) {
script {
// Check the route b/w the container and DSTester n/w and add
sh 'python3 ./ci-scripts/routeCheck.py --mode=Add --userName=' + dsT_host_user + ' --hostName=' + dsT_host
echo '\u2705 \u001B[32mDeploy CN5G using Docker-Compose and Testing with DS Tester\u001B[0m'
if (fileExists("dstester")) {
sh "rm -Rf dstester > /dev/null 2>&1"
......@@ -277,7 +274,9 @@ pipeline {
sh "git clone https://${git_username}:${git_token}@github.com/OPENAIRINTERFACE/chasseur.git . > ../git_clone.log 2>&1"
sh "git checkout -f " + dsTesterTag + " >> ../git_clone.log 2>&1"
// First put all correct tags to test
sh 'sed -i -e "s#NRF_TAG#' + nrfTag + '#" -i -e "s#AMF_TAG#' + amfTag + '#" -i -e "s#SMF_TAG#' + smfTag + '#" -i -e "s#SPGWU_TAG#' + spgwuTag + '#" -i -e "s#AUSF_TAG#' + ausfTag + '#" -i -e "s#UDM_TAG#' + udmTag + '#" -i -e "s#UDR_TAG#' + udrTag + '#" ./jenkins/suits/dc/integration/integration-basic.yaml'
sh 'sed -i -e "s#NRF_TAG#' + nrfTag + '#" -i -e "s#AMF_TAG#' + amfTag + '#" -i -e "s#SMF_TAG#' + smfTag + '#" -i -e "s#UPF_TAG#' + spgwuTag + '#" -i -e "s#AUSF_TAG#' + ausfTag + '#" -i -e "s#UDM_TAG#' + udmTag + '#" -i -e "s#UDR_TAG#' + udrTag + '#" ./jenkins/suits/dc/integration/integration-basic.yaml'
// Check the route b/w the container and DSTester n/w and add
sh 'python3 ../ci-scripts/routeCheck.py --mode Add --userName ' + dsT_host_user + ' --hostName ' + dsT_host + ' --docker_compose docker-compose/integration/integration-basic/integration.tplt'
dir ('jenkins') {
try {
sh "python3 ./chasseurdocker.py -f ./suits/dc/integration/integration-basic.yaml | tee ../../DS-TEST-RESULTS/dsTester_Summary.txt"
......@@ -285,7 +284,8 @@ pipeline {
currentBuild.result = 'FAILURE'
echo "dsTester FrameWork FAILED"
}
}
}
sh 'python3 ../ci-scripts/routeCheck.py --mode Delete --userName ' + dsT_host_user + ' --hostName ' + dsT_host + ' --docker_compose docker-compose/integration/integration-basic/integration.tplt'
}
}
sh "python3 ./ci-scripts/toCheckDSTesterResult.py"
......@@ -297,9 +297,8 @@ pipeline {
post {
always {
script {
sh 'python3 ./ci-scripts/routeCheck.py --mode=Delete --userName=' + dsT_host_user + ' --hostName=' + dsT_host
// Generating the HTML report
sh 'python3 ./ci-scripts/dsTestGenerateHTMLReport.py --job_name=' + JOB_NAME + ' --job_id=' + BUILD_ID + ' --job_url=' + BUILD_URL
sh 'python3 ./ci-scripts/dsTestGenerateHTMLReport.py --job_name ' + JOB_NAME + ' --job_id ' + BUILD_ID + ' --job_url ' + BUILD_URL
// Zipping all archived log files
sh "zip -r -qq cn5g_fed_docker_logs.zip archives DS-TEST-RESULTS"
......
......@@ -228,35 +228,7 @@ class HtmlReport():
size = str(sizeInt) + ' MB'
imageLog.close()
configState = 'KO'
with open(cwd + '/DS-TEST-RESULTS/bvc.yaml') as f:
data = yaml.full_load(f)
try:
if statusPrefix in data['nf-deployment']['pass']:
configState = 'OK'
elif statusPrefix in data['nf-deployment']['recovered']:
configState = 'RS'
except Exception as e:
pass
self.file.write(' <tr>\n')
self.file.write(' <td>' + containerName + '</td>\n')
self.file.write(' <td>' + usedTag + '</td>\n')
self.file.write(' <td>' + createDate + '</td>\n')
self.file.write(' <td>' + size + '</td>\n')
if configState == 'OK':
self.file.write(' <td bgcolor = "DarkGreen"><b><font color="white">' + configState + '</font></b></td>\n')
elif configState == 'RS':
self.file.write(' <td bgcolor = "Orange"><b><font color="white">' + configState + '</font></b></td>\n')
else:
self.file.write(' <td bgcolor = "Red"><b><font color="white">' + configState + '</font></b></td>\n')
self.file.write(' </tr>\n')
else:
if imageInfoPrefix == 'mysql':
self.file.write(' <tr>\n')
self.file.write(' <td>' + containerName + '</td>\n')
self.file.write(' <td>mysql:5.7</td>\n')
self.file.write(' <td>N/A</td>\n')
self.file.write(' <td>449MB</td>\n')
configState = 'KO'
if os.path.isfile(cwd + '/DS-TEST-RESULTS/bvc.yaml'):
with open(cwd + '/DS-TEST-RESULTS/bvc.yaml') as f:
data = yaml.full_load(f)
try:
......@@ -266,13 +238,43 @@ class HtmlReport():
configState = 'RS'
except Exception as e:
pass
self.file.write(' <tr>\n')
self.file.write(' <td>' + containerName + '</td>\n')
self.file.write(' <td>' + usedTag + '</td>\n')
self.file.write(' <td>' + createDate + '</td>\n')
self.file.write(' <td>' + size + '</td>\n')
if configState == 'OK':
self.file.write(' <td bgcolor = "DarkGreen"><b><font color="white">OK</font></b></td>\n')
self.file.write(' <td bgcolor = "DarkGreen"><b><font color="white">' + configState + '</font></b></td>\n')
elif configState == 'RS':
self.file.write(' <td bgcolor = "Orange"><b><font color="white">' + configState + '</font></b></td>\n')
else:
self.file.write(' <td bgcolor = "Red"><b><font color="white">KO</font></b></td>\n')
self.file.write(' <td bgcolor = "Red"><b><font color="white">' + configState + '</font></b></td>\n')
self.file.write(' </tr>\n')
else:
if imageInfoPrefix == 'mysql':
if os.path.isfile(cwd + '/DS-TEST-RESULTS/bvc.yaml'):
self.file.write(' <tr>\n')
self.file.write(' <td>' + containerName + '</td>\n')
self.file.write(' <td>mysql:5.7</td>\n')
self.file.write(' <td>N/A</td>\n')
self.file.write(' <td>449MB</td>\n')
configState = 'KO'
with open(cwd + '/DS-TEST-RESULTS/bvc.yaml') as f:
data = yaml.full_load(f)
try:
if statusPrefix in data['nf-deployment']['pass']:
configState = 'OK'
elif statusPrefix in data['nf-deployment']['recovered']:
configState = 'RS'
except Exception as e:
pass
if configState == 'OK':
self.file.write(' <td bgcolor = "DarkGreen"><b><font color="white">OK</font></b></td>\n')
elif configState == 'RS':
self.file.write(' <td bgcolor = "Orange"><b><font color="white">' + configState + '</font></b></td>\n')
else:
self.file.write(' <td bgcolor = "Red"><b><font color="white">KO</font></b></td>\n')
self.file.write(' </tr>\n')
else:
self.file.write(' <tr>\n')
self.file.write(' <td>' + containerName + '</td>\n')
......
......@@ -25,18 +25,59 @@ import re
import sys
import subprocess
import yaml
import argparse
class IpRouteCheck():
def __init__(self):
self.mode = ''
self.userName = ''
self.hostName = ''
self.file = ''
self.subnet = ''
self.gatwayIp = ''
self.interfaceName = ''
def _parse_args(self) -> argparse.Namespace:
"""Parse the command line args
Returns:
argparse.Namespace: the created parser
"""
parser = argparse.ArgumentParser(description='Route Add/Delete on the required Server for CI Deployment')
# Mode
parser.add_argument(
'--mode',
action='store',
required=True,
choices=['Add', 'Delete'],
help='route Add/Delete',
)
# Server username
parser.add_argument(
'--userName',
action='store',
required=True,
help='server username',
)
# Server hostname
parser.add_argument(
'--hostName',
action='store',
required=True,
help='server hostname',
)
# Docker-compose file to use
parser.add_argument(
'--docker_compose',
action='store',
required=True,
help='Docker-compose file to use',
)
return parser.parse_args()
def getSubnet(self):
cmd = "egrep 'subnet' ci-scripts/dsTesterDockerCompose/docker-compose.yml"
cmd = f"egrep 'subnet' {self.file}"
ret = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, encoding='utf-8')
if ret.returncode == 0:
if ret.stdout is not None:
......@@ -96,52 +137,20 @@ class IpRouteCheck():
cmd = f"sudo ip route del {self.subnet} via {self.gatwayIp} dev {self.interfaceName}"
ret = subprocess.run(f'ssh {self.userName}@{self.hostName} {cmd} || true', shell=True, stdout=subprocess.PIPE, encoding='utf-8')
print("Deleted ip route")
def Usage():
print('----------------------------------------------------------------------------------------------------------------------')
print('routecheck.py')
print(' Add and Delete the ip route on the Server.')
print('----------------------------------------------------------------------------------------------------------------------')
print('Usage: python3 routecheck.py [options]')
print(' --help Show this help.')
print('---------------------------------------------------------------------------------------------- Mandatory Options -----')
print(' --mode=[Add/Delete]')
print(' --userName=[server userName where to add/delete]')
print(' --hostName=[server hostName where to add/delete]')
print('------------------------------------------------------------------------------------------------- Actions Syntax -----')
print('python3 helmDeploy.py --mode=Add [Mandatory Options]')
print('python3 helmDeploy.py --mode=Delete [Mandatory Options]')
#--------------------------------------------------------------------------------------------------------
#
# Start of main
#
#--------------------------------------------------------------------------------------------------------
argvs = sys.argv
IPRC = IpRouteCheck()
args = IPRC._parse_args()
while len(argvs) > 1:
myArgv = argvs.pop(1)
if re.match('^\-\-help$', myArgv, re.IGNORECASE):
Usage()
sys.exit(0)
elif re.match('^\-\-mode=(.+)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-mode=(.+)$', myArgv, re.IGNORECASE)
IPRC.mode = matchReg.group(1)
elif re.match('^\-\-userName=(.+)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-userName=(.+)$', myArgv, re.IGNORECASE)
IPRC.userName = matchReg.group(1)
elif re.match('^\-\-hostName=(.+)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-hostName=(.+)$', myArgv, re.IGNORECASE)
IPRC.hostName = matchReg.group(1)
else:
sys.exit('Invalid Parameter: ' + myArgv)
if IPRC.mode == '' or IPRC.userName == '' or IPRC.hostName == '':
sys.exit('Missing Parameter in job description')
IPRC.mode = args.mode
IPRC.userName = args.userName
IPRC.hostName = args.hostName
IPRC.file = args.docker_compose
IPRC.getSubnet()
IPRC.getGatwayIp()
......
......@@ -49,3 +49,5 @@ if locexist:
sys.exit('DS Tester FrameWork final result FAILED')
except IOError:
sys.exit(f'File not accessible to check DSTester result: DS-TEST-RESULTS/{filename.group(0)}')
else:
sys.exit('Result path is not Available on Console, Something wrong with DSTester')
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment