Commit 049e877d authored by Raphael Defosseux's avatar Raphael Defosseux

CI: adding deployment of local test env; no check yet

Signed-off-by: default avatarRaphael Defosseux <raphael.defosseux@openairinterface.org>
parent 01cfcdfd
......@@ -77,6 +77,7 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && DE
net-tools \
bc \
tshark \
libasan4 \
libgoogle-glog0v5 \
libdouble-conversion1 \
libconfig++9v5 \
......
This diff is collapsed.
#/*
# * 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
class smfConfigGen():
def __init__(self):
self.kind = ''
self.sbi_name = ''
self.sbi_port = '80'
self.n4_name = ''
self.amf_ip_addr = ''
self.amf_port = '80'
self.udm_ip_addr = ''
self.udm_port = '80'
self.upf_ip_addr = ''
self.apn = 'carrier.com'
self.dns1_ip = '192.168.18.129'
self.dns2_ip = '8.8.4.4'
self.fromDockerFile = False
def GenerateSmfConfigurer(self):
smfFile = open('./smf-cfg.sh', 'w')
smfFile.write('#!/bin/bash\n')
smfFile.write('\n')
if self.fromDockerFile:
smfFile.write('cd /openair-smf\n')
else:
smfFile.write('cd /home\n')
smfFile.write('\n')
smfFile.write('INSTANCE=1\n')
if self.fromDockerFile:
smfFile.write('PREFIX=\'/openair-smf/etc\'\n')
else:
smfFile.write('PREFIX=\'/usr/local/etc/oai\'\n')
smfFile.write('\n')
smfFile.write('MY_APN=\'' + self.apn + '\'\n')
smfFile.write('MY_PRIMARY_DNS=\'' + self.dns1_ip + '\'\n')
smfFile.write('MY_SECONDARY_DNS=\'' + self.dns2_ip + '\'\n')
smfFile.write('\n')
if not self.fromDockerFile:
smfFile.write('mkdir -p $PREFIX\n')
smfFile.write('cp etc/spgw_c.conf $PREFIX\n')
smfFile.write('\n')
smfFile.write('declare -A SMF_CONF\n')
smfFile.write('\n')
smfFile.write('SMF_CONF[@INSTANCE@]=$INSTANCE\n')
smfFile.write('SMF_CONF[@PID_DIRECTORY@]=\'/var/run\'\n')
smfFile.write('SMF_CONF[@SMF_INTERFACE_NAME_FOR_SBI@]=\'' + self.sbi_name + '\'\n')
smfFile.write('SMF_CONF[@SMF_INTERFACE_PORT_FOR_SBI@]=' + self.sbi_port + '\n')
smfFile.write('SMF_CONF[@SMF_INTERFACE_NAME_FOR_N4@]=\'' + self.n4_name + '\'\n')
smfFile.write('SMF_CONF[@DEFAULT_DNS_IPV4_ADDRESS@]=$MY_PRIMARY_DNS\n')
smfFile.write('SMF_CONF[@DEFAULT_DNS_SEC_IPV4_ADDRESS@]=$MY_SECONDARY_DNS\n')
#smfFile.write('SMF_CONF[@DEFAULT_APN@]=$MY_APN\n')
smfFile.write('SMF_CONF[@AMF_IPV4_ADDRESS@]=\'' + self.amf_ip_addr + '\'\n')
smfFile.write('SMF_CONF[@AMF_PORT@]=' + self.amf_port + '\n')
smfFile.write('SMF_CONF[@UDM_IPV4_ADDRESS@]=\'' + self.udm_ip_addr + '\'\n')
smfFile.write('SMF_CONF[@UDM_PORT@]=' + self.udm_port + '\n')
smfFile.write('SMF_CONF[@UPF_IPV4_ADDRESS@]=\'' + self.upf_ip_addr + '\'\n')
smfFile.write('\n')
smfFile.write('for K in "${!SMF_CONF[@]}"; do \n')
smfFile.write(' egrep -lRZ "$K" $PREFIX | xargs -0 -l sed -i -e "s|$K|${SMF_CONF[$K]}|g"\n')
smfFile.write('done\n')
smfFile.write('\n')
smfFile.write('exit 0\n')
smfFile.close()
#-----------------------------------------------------------
# Usage()
#-----------------------------------------------------------
def Usage():
print('----------------------------------------------------------------------------------------------------------------------')
print('generateConfigFiles.py')
print(' Prepare a bash script to be run in the workspace where SMF is being built.')
print(' That bash script will copy configuration template files and adapt to your configuration.')
print('----------------------------------------------------------------------------------------------------------------------')
print('Usage: python3 generateConfigFiles.py [options]')
print(' --help Show this help.')
print('---------------------------------------------------------------------------------------------------- SMF Options -----')
print(' --kind=SMF')
print(' --sbi=[SMF SBI Interface Name]')
print(' --n4=[SMF N4 Interface Name]')
print(' --amf_ip_addr=[AMF IP Address]')
print(' --udm_ip_addr=[UDM IP Address]')
print(' --upf_ip_addr=[UPF IP Address]')
print(' --from_docker_file')
print('---------------------------------------------------------------------------------------------- SMF Not Mandatory -----')
print(' --apn=[Access Point Name]')
print(' --dns1_ip=[First DNS IP address]')
print(' --dns2_ip=[Second DNS IP address]')
argvs = sys.argv
argc = len(argvs)
cwd = os.getcwd()
mySmfCfg = smfConfigGen()
while len(argvs) > 1:
myArgv = argvs.pop(1)
if re.match('^\-\-help$', myArgv, re.IGNORECASE):
Usage()
sys.exit(0)
elif re.match('^\-\-kind=(.+)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-kind=(.+)$', myArgv, re.IGNORECASE)
mySmfCfg.kind = matchReg.group(1)
elif re.match('^\-\-sbi=(.+)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-sbi=(.+)$', myArgv, re.IGNORECASE)
mySmfCfg.sbi_name = matchReg.group(1)
elif re.match('^\-\-n4=(.+)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-n4=(.+)$', myArgv, re.IGNORECASE)
mySmfCfg.n4_name = matchReg.group(1)
elif re.match('^\-\-amf_ip_addr=(.+)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-amf_ip_addr=(.+)$', myArgv, re.IGNORECASE)
mySmfCfg.amf_ip_addr = matchReg.group(1)
elif re.match('^\-\-udm_ip_addr=(.+)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-udm_ip_addr=(.+)$', myArgv, re.IGNORECASE)
mySmfCfg.udm_ip_addr = matchReg.group(1)
elif re.match('^\-\-upf_ip_addr=(.+)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-upf_ip_addr=(.+)$', myArgv, re.IGNORECASE)
mySmfCfg.upf_ip_addr = matchReg.group(1)
elif re.match('^\-\-apn=(.+)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-apn=(.+)$', myArgv, re.IGNORECASE)
mySmfCfg.apn = matchReg.group(1)
elif re.match('^\-\-dns1_ip=(.+)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-dns1_ip=(.+)$', myArgv, re.IGNORECASE)
mySmfCfg.dns1_ip = matchReg.group(1)
elif re.match('^\-\-dns2_ip=(.+)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-dns2_ip=(.+)$', myArgv, re.IGNORECASE)
mySmfCfg.dns2_ip = matchReg.group(1)
elif re.match('^\-\-from_docker_file', myArgv, re.IGNORECASE):
mySmfCfg.fromDockerFile = True
else:
Usage()
sys.exit('Invalid Parameter: ' + myArgv)
if mySmfCfg.kind == '':
Usage()
sys.exit('missing kind parameter')
if mySmfCfg.kind == 'SMF':
if mySmfCfg.sbi_name == '':
Usage()
sys.exit('missing S11 Interface Name on SMF container')
elif mySmfCfg.n4_name == '':
Usage()
sys.exit('missing N4 Interface Name on SMF container')
elif mySmfCfg.amf_ip_addr == '':
Usage()
sys.exit('missing AMF IP address')
elif mySmfCfg.udm_ip_addr == '':
Usage()
sys.exit('missing UDM IP address')
elif mySmfCfg.upf_ip_addr == '':
Usage()
sys.exit('missing UPF IP address')
else:
mySmfCfg.GenerateSmfConfigurer()
sys.exit(0)
else:
Usage()
sys.exit('invalid kind parameter')
......@@ -57,6 +57,11 @@ class HtmlReport():
self.imageSizeRow()
self.buildSummaryFooter()
self.testBuildSummaryHeader()
self.testBuildCompileRows()
self.testImageSizeRow()
self.testBuildSummaryFooter()
self.sanityCheckSummaryHeader()
self.testSummaryHeader()
......@@ -351,6 +356,20 @@ class HtmlReport():
self.file.write(' </table>\n')
self.file.write(' <br>\n')
def testBuildSummaryHeader(self):
self.file.write(' <h2>Test Images Build Summary</h2>\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>Test AMF Server</th>\n')
self.file.write(' <th>Test AMF Client</th>\n')
self.file.write(' <th>Test UDM Server</th>\n')
self.file.write(' </tr>\n')
def testBuildSummaryFooter(self):
self.file.write(' </table>\n')
self.file.write(' <br>\n')
def initialGitSetup(self):
self.file.write(' <tr>\n')
self.file.write(' <td bgcolor="lightcyan" >Initial Git Setup</td>\n')
......@@ -512,26 +531,52 @@ class HtmlReport():
def buildCompileRows(self):
self.file.write(' <tr>\n')
self.file.write(' <td rowspan=2 bgcolor="lightcyan" >cNF Compile / Build</td>\n')
self.analyze_build_log('SMF')
self.analyze_build_log('SMF', True)
self.file.write(' </tr>\n')
self.file.write(' <tr>\n')
self.analyze_compile_log('SMF')
self.analyze_compile_log('SMF', True)
self.file.write(' </tr>\n')
def analyze_build_log(self, nfType):
if nfType != 'SMF':
def analyze_build_log(self, nfType, imageKind):
if nfType != 'SMF' and nfType != 'AMF-Server' and nfType != 'AMF-Client' and nfType != 'UDM-Server':
if imageKind:
self.file.write(' <td>N/A</td>\n')
self.file.write(' <td>Wrong NF Type for this Report</td>\n')
return
if nfType == 'SMF':
logFileName = 'smf_docker_image_build.log'
if nfType == 'AMF-Server':
logFileName = 'amf_server_docker_image_build.log'
if nfType == 'AMF-Client':
logFileName = 'amf_client_docker_image_build.log'
if nfType == 'UDM-Server':
logFileName = 'udm_server_docker_image_build.log'
if imageKind:
self.file.write(' <td>Builder Image</td>\n')
cwd = os.getcwd()
if os.path.isfile(cwd + '/archives/' + logFileName):
status = False
section_start_pattern = 'build_smf --clean --Verbose --build-type Release --jobs'
if nfType == 'SMF':
section_start_pattern = 'build_smf --clean --Verbose --build-type Debug --jobs'
section_end_pattern = 'FROM ubuntu:bionic as oai-smf$'
pass_pattern = 'smf installed'
if nfType == 'AMF-Server':
section_start_pattern = 'mkdir build && cd build && cmake .. && make'
section_end_pattern = 'FROM ubuntu:bionic as test-amf-server$'
pass_pattern = 'Built target amf-server'
path_pattern = 'src/test/amf'
if nfType == 'AMF-Client':
section_start_pattern = 'mkdir build && cd build && cmake .. && make'
section_end_pattern = 'FROM ubuntu:bionic as test-amf-client$'
pass_pattern = 'Built target amf-client'
path_pattern = 'src/test/amf_client'
if nfType == 'UDM-Server':
section_start_pattern = 'mkdir build && cd build && cmake .. && make'
section_end_pattern = 'FROM ubuntu:bionic as test-udm-server$'
pass_pattern = 'Built target udm-server'
path_pattern = 'src/test/udm'
section_status = False
with open(cwd + '/archives/' + logFileName, 'r') as logfile:
for line in logfile:
......@@ -542,7 +587,7 @@ class HtmlReport():
if result is not None:
section_status = False
if section_status:
result = re.search('smf installed', line)
result = re.search(pass_pattern, line)
if result is not None:
status = True
logfile.close()
......@@ -552,20 +597,31 @@ class HtmlReport():
else:
cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>'
cell_msg += 'KO:\n'
cell_msg += ' -- build_smf --clean --Verbose --build-type Release --jobs</b></pre></td>\n'
if nfType != 'SMF':
cell_msg += ' -- cd ' + path_pattern + '\n'
cell_msg += ' -- ' + section_start_pattern + '</b></pre></td>\n'
else:
cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>'
cell_msg += 'KO: logfile (' + logFileName + ') not found</b></pre></td>\n'
self.file.write(cell_msg)
def analyze_compile_log(self, nfType):
if nfType != 'SMF':
def analyze_compile_log(self, nfType, imageKind):
if nfType != 'SMF' and nfType != 'AMF-Server' and nfType != 'AMF-Client' and nfType != 'UDM-Server':
if imageKind:
self.file.write(' <td>N/A</td>\n')
self.file.write(' <td>Wrong NF Type for this Report</td>\n')
return
if nfType == 'SMF':
logFileName = 'smf_docker_image_build.log'
if nfType == 'AMF-Server':
logFileName = 'amf_server_docker_image_build.log'
if nfType == 'AMF-Client':
logFileName = 'amf_client_docker_image_build.log'
if nfType == 'UDM-Server':
logFileName = 'udm_server_docker_image_build.log'
if imageKind:
self.file.write(' <td>Builder Image</td>\n')
cwd = os.getcwd()
......@@ -573,8 +629,18 @@ class HtmlReport():
nb_warnings = 0
if os.path.isfile(cwd + '/archives/' + logFileName):
section_start_pattern = 'build_smf --clean --Verbose --build-type Release --jobs'
if nfType == 'SMF':
section_start_pattern = 'build_smf --clean --Verbose --build-type Debug --jobs'
section_end_pattern = 'FROM ubuntu:bionic as oai-smf$'
if nfType == 'AMF-Server':
section_start_pattern = 'mkdir build && cd build && cmake .. && make'
section_end_pattern = 'FROM ubuntu:bionic as test-amf-server$'
if nfType == 'AMF-Client':
section_start_pattern = 'mkdir build && cd build && cmake .. && make'
section_end_pattern = 'FROM ubuntu:bionic as test-amf-client$'
if nfType == 'UDM-Server':
section_start_pattern = 'mkdir build && cd build && cmake .. && make'
section_end_pattern = 'FROM ubuntu:bionic as test-udm-server$'
section_status = False
with open(cwd + '/archives/' + logFileName, 'r') as logfile:
for line in logfile:
......@@ -698,22 +764,41 @@ class HtmlReport():
def imageSizeRow(self):
self.file.write(' <tr>\n')
self.file.write(' <td bgcolor="lightcyan" >Image Size</td>\n')
self.analyze_image_size_log('SMF')
self.analyze_image_size_log('SMF', True)
self.file.write(' </tr>\n')
def analyze_image_size_log(self, nfType):
if nfType != 'SMF':
def analyze_image_size_log(self, nfType, imageKind):
if nfType != 'SMF' and nfType != 'AMF-Server' and nfType != 'AMF-Client' and nfType != 'UDM-Server':
if imageKind:
self.file.write(' <td>N/A</td>\n')
self.file.write(' <td>Wrong NF Type for this Report</td>\n')
return
if nfType == 'SMF':
logFileName = 'smf_docker_image_build.log'
if nfType == 'AMF-Server':
logFileName = 'amf_server_docker_image_build.log'
if nfType == 'AMF-Client':
logFileName = 'amf_client_docker_image_build.log'
if nfType == 'UDM-Server':
logFileName = 'udm_server_docker_image_build.log'
if imageKind:
self.file.write(' <td>Target Image</td>\n')
cwd = os.getcwd()
if os.path.isfile(cwd + '/archives/' + logFileName):
if nfType == 'SMF':
section_start_pattern = 'Successfully tagged oai-smf'
section_end_pattern = 'OAI-SMF DOCKER IMAGE BUILD'
if nfType == 'AMF-Server':
section_start_pattern = 'Successfully tagged test-amf-server'
section_end_pattern = 'TEST-AMF-SERVER DOCKER IMAGE BUILD'
if nfType == 'AMF-Client':
section_start_pattern = 'Successfully tagged test-amf-client'
section_end_pattern = 'TEST-AMF-CLIENT DOCKER IMAGE BUILD'
if nfType == 'UDM-Server':
section_start_pattern = 'Successfully tagged test-udm-server'
section_end_pattern = 'TEST-UDM-SERVER DOCKER IMAGE BUILD'
section_status = False
status = False
with open(cwd + '/archives/' + logFileName, 'r') as logfile:
......@@ -725,10 +810,17 @@ class HtmlReport():
if result is not None:
section_status = False
if section_status:
if nfType == 'SMF':
if self.git_pull_request:
result = re.search('oai-smf *ci-temp', line)
else:
result = re.search('oai-smf *develop', line)
if nfType == 'AMF-Server':
result = re.search('test-amf-server *test-deploy', line)
if nfType == 'AMF-Client':
result = re.search('test-amf-client *test-deploy', line)
if nfType == 'UDM-Server':
result = re.search('test-udm-server *test-deploy', line)
if result is not None:
result = re.search('ago *([0-9A-Z]+)', line)
if result is not None:
......@@ -748,6 +840,27 @@ class HtmlReport():
self.file.write(cell_msg)
def testBuildCompileRows(self):
self.file.write(' <tr>\n')
self.file.write(' <td rowspan=2 bgcolor="lightcyan" >cNF Compile / Build</td>\n')
self.analyze_build_log('AMF-Server', False)
self.analyze_build_log('AMF-Client', False)
self.analyze_build_log('UDM-Server', False)
self.file.write(' </tr>\n')
self.file.write(' <tr>\n')
self.analyze_compile_log('AMF-Server', False)
self.analyze_compile_log('AMF-Client', False)
self.analyze_compile_log('UDM-Server', False)
self.file.write(' </tr>\n')
def testImageSizeRow(self):
self.file.write(' <tr>\n')
self.file.write(' <td bgcolor="lightcyan" >Image Size</td>\n')
self.analyze_image_size_log('AMF-Server', False)
self.analyze_image_size_log('AMF-Client', False)
self.analyze_image_size_log('UDM-Server', False)
self.file.write(' </tr>\n')
def sanityCheckSummaryHeader(self):
self.file.write(' <h2>Sanity Check Deployment Summary</h2>\n')
self.file.write(' <div class="alert alert-warning">\n')
......
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