Commit 9895c775 authored by Raphael Defosseux's avatar Raphael Defosseux
Browse files

CI: local test deployment is now tested and reported


Signed-off-by: default avatarRaphael Defosseux <raphael.defosseux@openairinterface.org>
parent 41880108
......@@ -51,7 +51,8 @@ pipeline {
"Code Formatting Checker",
"Build AMF-server",
"Build UDM-server",
"Build AMF-client"
"Build AMF-client",
"Local SMF test"
])
}
......@@ -374,6 +375,10 @@ pipeline {
// N4 --> eth1
myShCmd('docker network connect ci-n4 ci-oai-spgwu', new_host_flag, new_host_user, new_host)
sh "echo 'OAI-AMF-SERVER CONFIG: OK' >> archives/amf_server_config.log"
sh "echo 'OAI-UDM-SERVER CONFIG: OK' >> archives/umd_server_config.log"
sh "echo 'OAI-AMF-CLIENT CONFIG: OK' >> archives/amf_client_config.log"
// Configure containers
SMF_SBI_IP_ADDRESS=myShRetCmd('docker exec -it ci-oai-smf /bin/bash -c "ifconfig eth1 | egrep inet" | sed -e "s@^.*inet @@" -e "s@ netmask.*@@"', new_host_flag, new_host_user, new_host)
SMF_N4_IP_ADDRESS=myShRetCmd('docker exec -it ci-oai-smf /bin/bash -c "ifconfig eth2 | egrep inet" | sed -e "s@^.*inet @@" -e "s@ netmask.*@@"', new_host_flag, new_host_user, new_host)
......@@ -385,54 +390,113 @@ pipeline {
copyTo2ndServer('smf-cfg.sh', new_host_flag, new_host_user, new_host)
myShCmd('docker cp ./smf-cfg.sh ci-oai-smf:/openair-smf', new_host_flag, new_host_user, new_host)
myShCmd('docker exec -it ci-oai-smf /bin/bash -c "cd /openair-smf && chmod 777 smf-cfg.sh && ./smf-cfg.sh" >> archives/smf_config.log', new_host_flag, new_host_user, new_host)
myShCmd('docker cp ci-oai-smf:/openair-smf/etc/. archives/oai-smf-cfg', new_host_flag, new_host_user, new_host)
copyFrom2ndServer('archives/oai-smf-cfg/*.*', 'archives/oai-smf-cfg', new_host_flag, new_host_user, new_host)
copyFrom2ndServer('archives/smf_config.log', 'archives', new_host_flag, new_host_user, new_host)
sh "wget --quiet https://raw.githubusercontent.com/OPENAIRINTERFACE/openair-spgwu-tiny/develop/ci-scripts/generateConfigFiles.py -O ci-scripts/generateSpgwuConfigFiles.py"
sh "python3 ci-scripts/generateSpgwuConfigFiles.py --kind=SPGW-U --sxc_ip_addr=${SMF_N4_IP_ADDRESS} --sxu=eth1 --s1u=eth0 --from_docker_file"
copyTo2ndServer('spgwu-cfg.sh', new_host_flag, new_host_user, new_host)
myShCmd('docker cp ./spgwu-cfg.sh ci-oai-spgwu:/openair-spgwu-tiny', new_host_flag, new_host_user, new_host)
myShCmd('docker exec -it ci-oai-spgwu /bin/bash -c "cd /openair-spgwu-tiny && chmod 777 spgwu-cfg.sh && ./spgwu-cfg.sh" >> archives/spgwu_config.log', new_host_flag, new_host_user, new_host)
copyFrom2ndServer('archives/spgwu_config.log', 'archives', new_host_flag, new_host_user, new_host)
}
}
post {
success {
sh "echo 'OAI-SMF CONFIG: OK' >> archives/smf_config.log"
sh "echo 'OAI-SPGW-U CONFIG: OK' >> archives/spgwu_config.log"
}
unsuccessful {
sh "echo 'OAI-SMF CONFIG: KO' >> archives/smf_config.log"
sh "echo 'OAI-SPGW-U CONFIG: KO' >> archives/spgwu_config.log"
}
}
}
stage ('Test') {
steps {
script {
SMF_SBI_IP_ADDRESS=myShRetCmd('docker exec -it ci-oai-smf /bin/bash -c "ifconfig eth1 | egrep inet" | sed -e "s@^.*inet @@" -e "s@ netmask.*@@"', new_host_flag, new_host_user, new_host)
AMF_IP_ADDRESS=myShRetCmd('docker exec -it ci-test-amf-server /bin/bash -c "ifconfig eth1 | egrep inet" | sed -e "s@^.*inet @@" -e "s@ netmask.*@@"', new_host_flag, new_host_user, new_host)
UDM_IP_ADDRESS=myShRetCmd('docker exec -it ci-test-udm-server /bin/bash -c "ifconfig eth1 | egrep inet" | sed -e "s@^.*inet @@" -e "s@ netmask.*@@"', new_host_flag, new_host_user, new_host)
gitlabCommitStatus(name: "Local SMF test") {
SMF_SBI_IP_ADDRESS=myShRetCmd('docker exec -it ci-oai-smf /bin/bash -c "ifconfig eth1 | egrep inet" | sed -e "s@^.*inet @@" -e "s@ netmask.*@@"', new_host_flag, new_host_user, new_host)
AMF_IP_ADDRESS=myShRetCmd('docker exec -it ci-test-amf-server /bin/bash -c "ifconfig eth1 | egrep inet" | sed -e "s@^.*inet @@" -e "s@ netmask.*@@"', new_host_flag, new_host_user, new_host)
UDM_IP_ADDRESS=myShRetCmd('docker exec -it ci-test-udm-server /bin/bash -c "ifconfig eth1 | egrep inet" | sed -e "s@^.*inet @@" -e "s@ netmask.*@@"', new_host_flag, new_host_user, new_host)
myShCmd('docker exec -d ci-oai-smf /bin/bash -c "nohup ./bin/oai_smf -c ./etc/smf.conf -o > smf_check_run.log 2>&1"', new_host_flag, new_host_user, new_host)
sh "sleep 2"
myShCmd('docker exec -d ci-oai-spgwu /bin/bash -c "nohup ./bin/oai_spgwu -c ./etc/spgw_u.conf -o > spgwu_check_run.log 2>&1"', new_host_flag, new_host_user, new_host)
sh "sleep 2"
myShCmd('docker exec -d ci-test-udm-server /bin/bash -c "nohup ./bin/udm-server -i ' + UDM_IP_ADDRESS + ' > udm_server_check_run.log 2>&1"', new_host_flag, new_host_user, new_host)
sh "sleep 2"
myShCmd('docker exec -d ci-test-amf-server /bin/bash -c "nohup ./bin/amf-server -i ' + AMF_IP_ADDRESS + ' > amf_server_check_run.log 2>&1"', new_host_flag, new_host_user, new_host)
sh "sleep 2"
myShCmd('docker exec -it ci-test-amf-client /bin/bash -c "./bin/amf-client -i ' + SMF_SBI_IP_ADDRESS + ' > amf_client_check_run.log"', new_host_flag, new_host_user, new_host)
sh "sleep 30"
myShCmd('docker exec -it ci-oai-smf /bin/bash -c "killall --signal SIGINT oai_smf"', new_host_flag, new_host_user, new_host)
myShCmd('docker exec -it ci-oai-spgwu /bin/bash -c "killall --signal SIGINT oai_spgwu"', new_host_flag, new_host_user, new_host)
myShCmd('docker exec -it ci-test-amf-server /bin/bash -c "killall amf-server"', new_host_flag, new_host_user, new_host)
myShCmd('docker exec -it ci-test-udm-server /bin/bash -c "killall udm-server"', new_host_flag, new_host_user, new_host)
sh "sleep 5"
try {
myShCmd('docker exec -it ci-oai-smf /bin/bash -c "killall --signal SIGKILL oai_smf"', new_host_flag, new_host_user, new_host)
} catch (Exception e) {
echo "No residual oai_smf processes"
myShCmd('docker exec -d ci-oai-smf /bin/bash -c "nohup ./bin/oai_smf -c ./etc/smf.conf -o > smf_check_run.log 2>&1"', new_host_flag, new_host_user, new_host)
sh "sleep 2"
myShCmd('docker exec -d ci-oai-spgwu /bin/bash -c "nohup ./bin/oai_spgwu -c ./etc/spgw_u.conf -o > spgwu_check_run.log 2>&1"', new_host_flag, new_host_user, new_host)
sh "sleep 2"
myShCmd('docker exec -d ci-test-udm-server /bin/bash -c "nohup ./bin/udm-server -i ' + UDM_IP_ADDRESS + ' > udm_server_check_run.log 2>&1"', new_host_flag, new_host_user, new_host)
sh "sleep 2"
myShCmd('docker exec -d ci-test-amf-server /bin/bash -c "nohup ./bin/amf-server -i ' + AMF_IP_ADDRESS + ' > amf_server_check_run.log 2>&1"', new_host_flag, new_host_user, new_host)
sh "sleep 30"
myShCmd('docker exec -it ci-test-amf-client /bin/bash -c "./bin/amf-client -i ' + SMF_SBI_IP_ADDRESS + ' > amf_client_check_run.log"', new_host_flag, new_host_user, new_host)
sh "sleep 30"
myShCmd('docker exec -it ci-oai-smf /bin/bash -c "killall --signal SIGINT oai_smf"', new_host_flag, new_host_user, new_host)
myShCmd('docker exec -it ci-oai-spgwu /bin/bash -c "killall --signal SIGINT oai_spgwu"', new_host_flag, new_host_user, new_host)
myShCmd('docker exec -it ci-test-amf-server /bin/bash -c "killall amf-server"', new_host_flag, new_host_user, new_host)
myShCmd('docker exec -it ci-test-udm-server /bin/bash -c "killall udm-server"', new_host_flag, new_host_user, new_host)
sh "sleep 5"
try {
myShCmd('docker exec -it ci-oai-smf /bin/bash -c "killall --signal SIGKILL oai_smf"', new_host_flag, new_host_user, new_host)
} catch (Exception e) {
echo "No residual oai_smf processes"
}
try {
myShCmd('docker exec -it ci-oai-spgwu /bin/bash -c "killall --signal SIGKILL oai_spgwu"', new_host_flag, new_host_user, new_host)
} catch (Exception e) {
echo "No residual oai_spgwu processes"
}
sh "sleep 5"
// Retrieve all log files
myShCmd('docker cp ci-oai-smf:/openair-smf/smf_check_run.log archives', new_host_flag, new_host_user, new_host)
myShCmd('docker cp ci-oai-spgwu:/openair-spgwu-tiny/spgwu_check_run.log archives', new_host_flag, new_host_user, new_host)
myShCmd('docker cp ci-test-amf-server:/test-amf-server/amf_server_check_run.log archives', new_host_flag, new_host_user, new_host)
myShCmd('docker cp ci-test-udm-server:/test-udm-server/udm_server_check_run.log archives', new_host_flag, new_host_user, new_host)
myShCmd('docker cp ci-test-amf-client:/test-amf-client/amf_client_check_run.log archives', new_host_flag, new_host_user, new_host)
copyFrom2ndServer('archives/*_check_run.log', 'archives', new_host_flag, new_host_user, new_host)
sh "python3 ./ci-scripts/verifySanityCheckDeployment.py --job_name=${JOB_NAME} --job_id=${BUILD_ID}"
sh "python3 ./ci-scripts/verifySanityCheckDeployment.py --job_name=${JOB_NAME} --job_id=${BUILD_ID} --smf_pdu_check"
}
try {
myShCmd('docker exec -it ci-oai-spgwu /bin/bash -c "killall --signal SIGKILL oai_spgwu"', new_host_flag, new_host_user, new_host)
} catch (Exception e) {
echo "No residual oai_spgwu processes"
}
}
post {
unsuccessful {
script {
// Retrieve all log files in case of failure
try {
myShCmd('docker cp ci-oai-smf:/openair-smf/smf_check_run.log archives', new_host_flag, new_host_user, new_host)
} catch (Exception e) {
echo "No smf run logs"
}
try {
myShCmd('docker cp ci-oai-spgwu:/openair-spgwu-tiny/spgwu_check_run.log archives', new_host_flag, new_host_user, new_host)
} catch (Exception e) {
echo "No spgwu run logs"
}
try {
myShCmd('docker cp ci-test-amf-server:/test-amf-server/amf_server_check_run.log archives', new_host_flag, new_host_user, new_host)
} catch (Exception e) {
echo "No amf run logs"
}
try {
myShCmd('docker cp ci-test-udm-server:/test-udm-server/udm_server_check_run.log archives', new_host_flag, new_host_user, new_host)
} catch (Exception e) {
echo "No udm run logs"
}
try {
myShCmd('docker cp ci-test-amf-client:/test-amf-client/amf_client_check_run.log archives', new_host_flag, new_host_user, new_host)
} catch (Exception e) {
echo "No amf-client run logs"
}
try {
copyFrom2ndServer('archives/*_check_run.log', 'archives', new_host_flag, new_host_user, new_host)
} catch (Exception e) {
echo "No run logs at all?"
}
}
sh "sleep 5"
myShCmd('docker cp ci-oai-smf:/openair-smf/smf_check_run.log archives', new_host_flag, new_host_user, new_host)
myShCmd('docker cp ci-oai-spgwu:/openair-spgwu-tiny/spgwu_check_run.log archives', new_host_flag, new_host_user, new_host)
myShCmd('docker cp ci-test-amf-server:/test-amf-server/amf_server_check_run.log archives', new_host_flag, new_host_user, new_host)
myShCmd('docker cp ci-test-udm-server:/test-udm-server/udm_server_check_run.log archives', new_host_flag, new_host_user, new_host)
myShCmd('docker cp ci-test-amf-client:/test-amf-client/amf_client_check_run.log archives', new_host_flag, new_host_user, new_host)
copyFrom2ndServer('archives/*_check_run.log', 'archives', new_host_flag, new_host_user, new_host)
}
}
}
......
......@@ -63,6 +63,10 @@ class HtmlReport():
self.testBuildSummaryFooter()
self.sanityCheckSummaryHeader()
self.sanityCheckDeployRow()
self.sanityCheckConfigRow()
self.sanityCheckTestRow()
self.sanityCheckSummaryFooter()
self.testSummaryHeader()
self.testSummaryFooter()
......@@ -863,9 +867,139 @@ class HtmlReport():
def sanityCheckSummaryHeader(self):
self.file.write(' <h2>Sanity Check Deployment Summary</h2>\n')
self.file.write(' <div class="alert alert-warning">\n')
self.file.write(' <strong>Not performed yet. <span class="glyphicon glyphicon-warning-sign"></span></strong>\n')
self.file.write(' </div>\n')
self.file.write(' <table class="table-bordered" width = "100%" align = "center" border = "1">\n')
self.file.write(' <tr bgcolor="#33CCFF" >\n')
self.file.write(' <th>Stage Name</th>\n')
self.file.write(' <th>OAI SMF cNF</th>\n')
self.file.write(' <th>OAI SPGWU (as UPF) cNF</th>\n')
self.file.write(' <th>Test AMF-Server</th>\n')
self.file.write(' <th>Test UDM-Server</th>\n')
self.file.write(' <th>Test AMF-Client</th>\n')
self.file.write(' </tr>\n')
def sanityCheckSummaryFooter(self):
self.file.write(' </table>\n')
self.file.write(' <br>\n')
def sanityCheckDeployRow(self):
self.file.write(' <tr>\n')
self.file.write(' <td bgcolor="lightcyan" >Container Start</td>\n')
cwd = os.getcwd()
if os.path.isfile(cwd + '/archives/amf_server_config.log') and os.path.isfile(cwd + '/archives/umd_server_config.log') and os.path.isfile(cwd + '/archives/amf_client_config.log'):
cell_msg = ' <td bgcolor="LimeGreen"><pre style="border:none; background-color:LimeGreen"><b>OK</b></pre></td>\n'
for x in range(0, 5):
self.file.write(cell_msg)
else:
cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>KO?</b></pre></td>\n'
for x in range(0, 5):
self.file.write(cell_msg)
self.file.write(' </tr>\n')
def sanityCheckTestRow(self):
self.file.write(' <tr>\n')
self.file.write(' <td bgcolor="lightcyan" >Local Test</td>\n')
cwd = os.getcwd()
if os.path.isfile(cwd + '/archives/smf_check_run.log'):
nb_sm_req_from_amf = 0
nb_pdu_create_smf_req = 0
nb_encode_pdu_establish_accept = 0
nb_pdu_session_pending = 0
nb_pdu_session_ue_establish_req = 0
nb_pdu_status_active = 0
with open(cwd + '/archives/smf_check_run.log', 'r') as logfile:
for line in logfile:
result = re.search('Received a SM context create request from AMF', line)
if result is not None:
nb_sm_req_from_amf += 1
result = re.search('PDU Session Create SM Context Request', line)
if result is not None:
nb_pdu_create_smf_req += 1
result = re.search('Encode PDU Session Establishment Accept', line)
if result is not None:
nb_encode_pdu_establish_accept += 1
result = re.search('Set PDU Session Status to PDU_SESSION_ESTABLISHMENT_PENDING', line)
if result is not None:
nb_pdu_session_pending += 1
result = re.search('PDU_SESSION_ESTABLISHMENT_UE_REQUESTED', line)
if result is not None:
nb_pdu_session_ue_establish_req += 1
result = re.search('Set PDU Session Status to PDU_SESSION_ACTIVE', line)
if result is not None:
nb_pdu_status_active += 1
logfile.close()
if nb_sm_req_from_amf > 0 and nb_pdu_create_smf_req > 0 and nb_encode_pdu_establish_accept > 0 and nb_pdu_session_pending > 0 and nb_pdu_session_ue_establish_req > 0 and nb_pdu_status_active > 0:
cell_msg = ' <td colspan = "5" bgcolor="LimeGreen"><pre style="border:none; background-color:LimeGreen"><b>OK:\n'
else:
cell_msg = ' <td colspan = "5" bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>KO:\n'
if nb_sm_req_from_amf > 0:
cell_msg += ' -- Received a SM context create request from AMF : OK\n'
else:
cell_msg += ' -- Received a SM context create request from AMF : KO\n'
if nb_pdu_create_smf_req > 0:
cell_msg += ' -- PDU Session Create SM Context Request : OK\n'
else:
cell_msg += ' -- PDU Session Create SM Context Request : KO\n'
if nb_encode_pdu_establish_accept > 0:
cell_msg += ' -- Encode PDU Session Establishment Accept : OK\n'
else:
cell_msg += ' -- Encode PDU Session Establishment Accept : KO\n'
if nb_pdu_session_pending > 0:
cell_msg += ' -- PDU Session Status to PDU_SESSION_ESTABLISHMENT_PENDING : OK\n'
else:
cell_msg += ' -- PDU Session Status to PDU_SESSION_ESTABLISHMENT_PENDING : KO\n'
if nb_pdu_session_ue_establish_req > 0:
cell_msg += ' -- PDU_SESSION_ESTABLISHMENT_UE_REQUESTED : OK\n'
else:
cell_msg += ' -- PDU_SESSION_ESTABLISHMENT_UE_REQUESTED : KO\n'
if nb_pdu_status_active > 0:
cell_msg += ' -- Set PDU Session Status to PDU_SESSION_ACTIVE : OK\n'
else:
cell_msg += ' -- Set PDU Session Status to PDU_SESSION_ACTIVE : KO\n'
cell_msg += '</b></pre></td>\n'
else:
cell_msg = ' <td colspan = "5" bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>KO?</b></pre></td>\n'
self.file.write(cell_msg)
self.file.write(' </tr>\n')
def sanityCheckConfigRow(self):
self.file.write(' <tr>\n')
self.file.write(' <td bgcolor="lightcyan" >Container Config</td>\n')
cwd = os.getcwd()
if os.path.isfile(cwd + '/archives/smf_config.log'):
cmd = 'grep -c OK ' + cwd + '/archives/smf_config.log'
try:
is_ok = subprocess.check_output(cmd, shell=True, universal_newlines=True)
except:
is_ok = '0'
if int(is_ok.strip()) == 0:
cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>KO?</b></pre></td>\n'
else:
cell_msg = ' <td bgcolor="LimeGreen"><pre style="border:none; background-color:LimeGreen"><b>OK</b></pre></td>\n'
else:
cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>KO?</b></pre></td>\n'
self.file.write(cell_msg)
if os.path.isfile(cwd + '/archives/spgwu_config.log'):
cmd = 'grep -c OK ' + cwd + '/archives/spgwu_config.log'
try:
is_ok = subprocess.check_output(cmd, shell=True, universal_newlines=True)
except:
is_ok = '0'
if int(is_ok.strip()) == 0:
cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>KO?</b></pre></td>\n'
else:
cell_msg = ' <td bgcolor="LimeGreen"><pre style="border:none; background-color:LimeGreen"><b>OK</b></pre></td>\n'
else:
cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>KO?</b></pre></td>\n'
self.file.write(cell_msg)
cell_msg = ' <td bgcolor="LightGray"><pre style="border:none; background-color:LightGray">N/A</pre></td>\n'
for x in range(0, 3):
self.file.write(cell_msg)
self.file.write(' </tr>\n')
def testSummaryHeader(self):
self.file.write(' <h2>Test Summary</h2>\n')
......
#/*
# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
# * contributor license agreements. See the NOTICE file distributed with
# * this work for additional information regarding copyright ownership.
# * The OpenAirInterface Software Alliance licenses this file to You under
# * the OAI Public License, Version 1.1 (the "License"); you may not use this file
# * except in compliance with the License.
# * You may obtain a copy of the License at
# *
# * http://www.openairinterface.org/?page_id=698
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# *-------------------------------------------------------------------------------
# * For more information about the OpenAirInterface (OAI) Software Alliance:
# * contact@openairinterface.org
# */
#---------------------------------------------------------------------
import os
import re
import sys
import subprocess
class verifySanityCheckDeployment():
def __init__(self):
self.job_name = ''
self.smf_pdu_check = False
def checkLogs(self):
if self.smf_pdu_check:
smf_status = self.analyze_pdu_scenario_log('SMF')
if not smf_status:
sys.exit('Local Test went wrong')
else:
print ('Local Test is OK')
return
smf_status = self.analyze_check_run_log('SMF')
spgwu_status = self.analyze_check_run_log('SPGW-U')
if not smf_status:
print ('SMF did not deploy properly')
if not spgwu_status:
print ('SPGW-U did not deploy properly')
if not smf_status or not spgwu_status:
sys.exit('Sanity Check Deployment went wrong')
else:
print ('Sanity Check Deployment is OK')
def analyze_pdu_scenario_log(self, nfType):
if nfType != 'SMF':
return False
logFileName = nfType.lower().replace('-','') + '_check_run.log'
cwd = os.getcwd()
status = False
if os.path.isfile(cwd + '/archives/' + logFileName):
myCmd = 'iconv -f ISO-8859-1 -t UTF-8//TRANSLIT ' + cwd + '/archives/' + logFileName + ' -o ' + cwd + '/archives/' + logFileName + '.conv'
subprocess.run(myCmd, shell=True)
myCmd = 'mv ' + cwd + '/archives/' + logFileName + '.conv ' + cwd + '/archives/' + logFileName
subprocess.run(myCmd, shell=True)
nb_sm_req_from_amf = 0
nb_pdu_create_smf_req = 0
nb_encode_pdu_establish_accept = 0
nb_pdu_session_pending = 0
nb_pdu_session_ue_establish_req = 0
nb_pdu_status_active = 0
with open(cwd + '/archives/' + logFileName, 'r') as logfile:
for line in logfile:
result = re.search('Received a SM context create request from AMF', line)
if result is not None:
nb_sm_req_from_amf += 1
result = re.search('PDU Session Create SM Context Request', line)
if result is not None:
nb_pdu_create_smf_req += 1
result = re.search('Encode PDU Session Establishment Accept', line)
if result is not None:
nb_encode_pdu_establish_accept += 1
result = re.search('Set PDU Session Status to PDU_SESSION_ESTABLISHMENT_PENDING', line)
if result is not None:
nb_pdu_session_pending += 1
result = re.search('PDU_SESSION_ESTABLISHMENT_UE_REQUESTED', line)
if result is not None:
nb_pdu_session_ue_establish_req += 1
result = re.search('Set PDU Session Status to PDU_SESSION_ACTIVE', line)
if result is not None:
nb_pdu_status_active += 1
logfile.close()
if nb_sm_req_from_amf > 0 and nb_pdu_create_smf_req > 0 and nb_encode_pdu_establish_accept > 0 and nb_pdu_session_pending > 0 and nb_pdu_session_ue_establish_req > 0 and nb_pdu_status_active > 0:
status = True
return status
def analyze_check_run_log(self, nfType):
logFileName = nfType.lower().replace('-','') + '_check_run.log'
cwd = os.getcwd()
status = False
if os.path.isfile(cwd + '/archives/' + logFileName):
myCmd = 'iconv -f ISO-8859-1 -t UTF-8//TRANSLIT ' + cwd + '/archives/' + logFileName + ' -o ' + cwd + '/archives/' + logFileName + '.conv'
subprocess.run(myCmd, shell=True)
myCmd = 'mv ' + cwd + '/archives/' + logFileName + '.conv ' + cwd + '/archives/' + logFileName
subprocess.run(myCmd, shell=True)
nb_pfcp_hb_proc = 0
nb_sx_hb_resp = 0
nb_sx_hb_req = 0
with open(cwd + '/archives/' + logFileName, 'r') as logfile:
for line in logfile:
if nfType == 'SPGW-U':
result = re.search('PFCP HEARTBEAT PROCEDURE', line)
if result is not None:
nb_pfcp_hb_proc += 1
result = re.search('SX HEARTBEAT RESPONSE', line)
if result is not None:
nb_sx_hb_resp += 1
result = re.search('SX HEARTBEAT REQUEST', line)
if result is not None:
nb_sx_hb_req += 1
if nfType == 'SMF':
result = re.search('PFCP HEARTBEAT PROCEDURE', line)
if result is not None:
nb_pfcp_hb_proc += 1
result = re.search('Sending HEARTBEAT_REQUEST', line)
if result is not None:
nb_sx_hb_resp += 1
result = re.search('Sending HEARTBEAT_RESPONSE', line)
if result is not None:
nb_sx_hb_req += 1
logfile.close()
if nfType == 'SMF':
if nb_pfcp_hb_proc > 0:
status = True
if nfType == 'SPGW-U':
if nb_pfcp_hb_proc > 0 and nb_sx_hb_resp > 0 and nb_sx_hb_req > 0:
status = True
return status
def Usage():
print('----------------------------------------------------------------------------------------------------------------------')
print('verifySanityCheckDeployment.py')
print(' Verify the Sanity Check Deployment in the pipeline.')
print('----------------------------------------------------------------------------------------------------------------------')
print('Usage: python3 verifySanityCheckDeployment.py [options]')
print(' --help Show this help.')
print('---------------------------------------------------------------------------------------------- Mandatory Options -----')
print(' --job_name=[Jenkins Job name]')
print(' --job_id=[Jenkins Job Build ID]')
print(' --smf_pdu_check')
#--------------------------------------------------------------------------------------------------------
#
# Start of main
#
#--------------------------------------------------------------------------------------------------------
argvs = sys.argv
argc = len(argvs)
vscd = verifySanityCheckDeployment()
while len(argvs) > 1:
myArgv = argvs.pop(1)
if re.match('^\-\-help$', myArgv, re.IGNORECASE):
Usage()
sys.exit(0)
elif re.match('^\-\-job_name=(.+)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-job_name=(.+)$', myArgv, re.IGNORECASE)
vscd.job_name = matchReg.group(1)
elif re.match('^\-\-job_id=(.+)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-job_id=(.+)$', myArgv, re.IGNORECASE)
vscd.job_id = matchReg.group(1)
elif re.match('^\-\-smf_pdu_check', myArgv, re.IGNORECASE):
vscd.smf_pdu_check = True
else:
sys.exit('Invalid Parameter: ' + myArgv)
if vscd.job_name == '' or vscd.job_id == '':
sys.exit('Missing Parameter in job description')
vscd.checkLogs()
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