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

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 \
......
......@@ -50,7 +50,7 @@ pipeline {
"Static Code Analysis",
"Code Formatting Checker",
"Build AMF-server",
"Build UMD-server",
"Build UDM-server",
"Build AMF-client"
])
......@@ -253,7 +253,7 @@ pipeline {
[$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.PrivateGitLabRepository_Credentials}", usernameVariable: 'git_username', passwordVariable: 'git_password']
]) {
if ("MERGE".equals(env.gitlabActionType)) {
myShCmd('docker build --target test-amf-server --tag test-amf-server:test-deploy --file ci-scripts/Dockerfile.private.amf-server.ubuntu18.04 --build-arg EURECOM_PROXY="http://proxy.eurecom.fr:8080" --build-arg GITLAB_USERNAME="' + git_username + '" --build-arg GITLAB_PASSWORD="' + git_password + '" --build-arg BUILD_FOR_CI="True" --build-arg CI_SRC_BRANCH="' + env.ghprbSourceBranch + '" --build-arg CI_SRC_COMMIT="' + env.ghprbActualCommit + '" --build-arg CI_DEST_BRANCH="develop" . > archives/amf_server_docker_image_build.log 2>&1', new_host_flag, new_host_user, new_host)
myShCmd('docker build --target test-amf-server --tag test-amf-server:test-deploy --file ci-scripts/Dockerfile.private.amf-server.ubuntu18.04 --build-arg EURECOM_PROXY="http://proxy.eurecom.fr:8080" --build-arg GITLAB_USERNAME="' + git_username + '" --build-arg GITLAB_PASSWORD="' + git_password + '" --build-arg BUILD_FOR_CI="True" --build-arg CI_SRC_BRANCH="' + env.gitlabSourceBranch + '" --build-arg CI_SRC_COMMIT="' + env.gitlabMergeRequestLastCommit + '" --build-arg CI_DEST_BRANCH="develop" . > archives/amf_server_docker_image_build.log 2>&1', new_host_flag, new_host_user, new_host)
} else {
myShCmd('docker build --target test-amf-server --tag test-amf-server:test-deploy --file ci-scripts/Dockerfile.private.amf-server.ubuntu18.04 --build-arg EURECOM_PROXY="http://proxy.eurecom.fr:8080" --build-arg GITLAB_USERNAME="' + git_username + '" --build-arg GITLAB_PASSWORD="' + git_password + '" --build-arg CI_SRC_BRANCH="develop" . > archives/amf_server_docker_image_build.log 2>&1', new_host_flag, new_host_user, new_host)
}
......@@ -276,15 +276,15 @@ pipeline {
}
}
}
stage('Build Test UMD-server') {
stage('Build Test UDM-server') {
steps {
script {
gitlabCommitStatus(name: "Build UMD-server") {
gitlabCommitStatus(name: "Build UDM-server") {
withCredentials([
[$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.PrivateGitLabRepository_Credentials}", usernameVariable: 'git_username', passwordVariable: 'git_password']
]) {
if ("MERGE".equals(env.gitlabActionType)) {
myShCmd('docker build --target test-udm-server --tag test-udm-server:test-deploy --file ci-scripts/Dockerfile.private.udm-server.ubuntu18.04 --build-arg EURECOM_PROXY="http://proxy.eurecom.fr:8080" --build-arg GITLAB_USERNAME="' + git_username + '" --build-arg GITLAB_PASSWORD="' + git_password + '" --build-arg BUILD_FOR_CI="True" --build-arg CI_SRC_BRANCH="' + env.ghprbSourceBranch + '" --build-arg CI_SRC_COMMIT="' + env.ghprbActualCommit + '" --build-arg CI_DEST_BRANCH="develop" . > archives/udm_server_docker_image_build.log 2>&1', new_host_flag, new_host_user, new_host)
myShCmd('docker build --target test-udm-server --tag test-udm-server:test-deploy --file ci-scripts/Dockerfile.private.udm-server.ubuntu18.04 --build-arg EURECOM_PROXY="http://proxy.eurecom.fr:8080" --build-arg GITLAB_USERNAME="' + git_username + '" --build-arg GITLAB_PASSWORD="' + git_password + '" --build-arg BUILD_FOR_CI="True" --build-arg CI_SRC_BRANCH="' + env.gitlabSourceBranch + '" --build-arg CI_SRC_COMMIT="' + env.gitlabMergeRequestLastCommit + '" --build-arg CI_DEST_BRANCH="develop" . > archives/udm_server_docker_image_build.log 2>&1', new_host_flag, new_host_user, new_host)
} else {
myShCmd('docker build --target test-udm-server --tag test-udm-server:test-deploy --file ci-scripts/Dockerfile.private.udm-server.ubuntu18.04 --build-arg EURECOM_PROXY="http://proxy.eurecom.fr:8080" --build-arg GITLAB_USERNAME="' + git_username + '" --build-arg GITLAB_PASSWORD="' + git_password + '" --build-arg CI_SRC_BRANCH="develop" . > archives/udm_server_docker_image_build.log 2>&1', new_host_flag, new_host_user, new_host)
}
......@@ -300,10 +300,10 @@ pipeline {
}
}
success {
sh "echo 'TEST-UMD-SERVER DOCKER IMAGE BUILD: OK' >> archives/udm_server_docker_image_build.log"
sh "echo 'TEST-UDM-SERVER DOCKER IMAGE BUILD: OK' >> archives/udm_server_docker_image_build.log"
}
unsuccessful {
sh "echo 'TEST-UMD-SERVER DOCKER IMAGE BUILD: KO' >> archives/udm_server_docker_image_build.log"
sh "echo 'TEST-UDM-SERVER DOCKER IMAGE BUILD: KO' >> archives/udm_server_docker_image_build.log"
}
}
}
......@@ -315,7 +315,7 @@ pipeline {
[$class: 'UsernamePasswordMultiBinding', credentialsId: "${params.PrivateGitLabRepository_Credentials}", usernameVariable: 'git_username', passwordVariable: 'git_password']
]) {
if ("MERGE".equals(env.gitlabActionType)) {
myShCmd('docker build --target test-amf-client --tag test-amf-client:test-deploy --file ci-scripts/Dockerfile.private.amf-client.ubuntu18.04 --build-arg EURECOM_PROXY="http://proxy.eurecom.fr:8080" --build-arg GITLAB_USERNAME="' + git_username + '" --build-arg GITLAB_PASSWORD="' + git_password + '" --build-arg BUILD_FOR_CI="True" --build-arg CI_SRC_BRANCH="' + env.ghprbSourceBranch + '" --build-arg CI_SRC_COMMIT="' + env.ghprbActualCommit + '" --build-arg CI_DEST_BRANCH="develop" . > archives/amf_client_docker_image_build.log 2>&1', new_host_flag, new_host_user, new_host)
myShCmd('docker build --target test-amf-client --tag test-amf-client:test-deploy --file ci-scripts/Dockerfile.private.amf-client.ubuntu18.04 --build-arg EURECOM_PROXY="http://proxy.eurecom.fr:8080" --build-arg GITLAB_USERNAME="' + git_username + '" --build-arg GITLAB_PASSWORD="' + git_password + '" --build-arg BUILD_FOR_CI="True" --build-arg CI_SRC_BRANCH="' + env.gitlabSourceBranch + '" --build-arg CI_SRC_COMMIT="' + env.gitlabMergeRequestLastCommit + '" --build-arg CI_DEST_BRANCH="develop" . > archives/amf_client_docker_image_build.log 2>&1', new_host_flag, new_host_user, new_host)
} else {
myShCmd('docker build --target test-amf-client --tag test-amf-client:test-deploy --file ci-scripts/Dockerfile.private.amf-client.ubuntu18.04 --build-arg EURECOM_PROXY="http://proxy.eurecom.fr:8080" --build-arg GITLAB_USERNAME="' + git_username + '" --build-arg GITLAB_PASSWORD="' + git_password + '" --build-arg CI_SRC_BRANCH="develop" . > archives/amf_client_docker_image_build.log 2>&1', new_host_flag, new_host_user, new_host)
}
......@@ -354,9 +354,9 @@ pipeline {
steps {
script {
if ("MERGE".equals(env.gitlabActionType)) {
myShCmd('docker run --name ci-oai-smf -d oai-smf:ci-temp /bin/bash -c "sleep infinity"', new_host_flag, new_host_user, new_host)
myShCmd('docker run --privileged --name ci-oai-smf -d oai-smf:ci-temp /bin/bash -c "sleep infinity"', new_host_flag, new_host_user, new_host)
} else {
myShCmd('docker run --name ci-oai-smf -d oai-smf:develop /bin/bash -c "sleep infinity"', new_host_flag, new_host_user, new_host)
myShCmd('docker run --privileged --name ci-oai-smf -d oai-smf:develop /bin/bash -c "sleep infinity"', new_host_flag, new_host_user, new_host)
}
// SBI --> eth1
myShCmd('docker network connect ci-sbi ci-oai-smf', new_host_flag, new_host_user, new_host)
......@@ -370,16 +370,69 @@ pipeline {
myShCmd('docker run --name ci-test-amf-client -d test-amf-client:test-deploy /bin/bash -c "sleep infinity"', new_host_flag, new_host_user, new_host)
myShCmd('docker network connect ci-sbi ci-test-amf-client', new_host_flag, new_host_user, new_host)
// SPGWU as UPF
myShCmd('docker run --name ci-oai-spgwu -d oai-spgwu-tiny:develop /bin/bash -c "sleep infinity"', new_host_flag, new_host_user, new_host)
myShCmd('docker run --privileged --name ci-oai-spgwu -d oai-spgwu-tiny:develop /bin/bash -c "sleep infinity"', new_host_flag, new_host_user, new_host)
// N4 --> eth1
myShCmd('docker network connect ci-n4 ci-oai-spgwu', new_host_flag, new_host_user, new_host)
// 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)
UPF_N4_IP_ADDRESS=myShRetCmd('docker exec -it ci-oai-spgwu /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)
sh "python3 ci-scripts/generateConfigFiles.py --kind=SMF --sbi=eth1 --n4=eth2 --amf_ip_addr=${AMF_IP_ADDRESS} --udm_ip_addr=${UDM_IP_ADDRESS} --upf_ip_addr=${UPF_N4_IP_ADDRESS} --from_docker_file"
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)
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)
}
}
}
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)
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"
}
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"
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)
}
}
}
......@@ -423,9 +476,9 @@ pipeline {
script {
// Deleting containers in case of errors
try {
myShCmd('docker rm -f ci-oai-smf ci-test-amf-server ci-test-udm-server ci-test-amf-client ci-oai-spgwu', new_host_flag, new_host_user, new_host)
} catch (Exception e) {
echo "We failed to remove any existing containers"
myShCmd('docker rm -f ci-oai-smf', new_host_flag, new_host_user, new_host)
}
// Deleting networks in case of errors
try {
......
#/*
# * 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':
self.file.write(' <td>N/A</td>\n')
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
logFileName = 'smf_docker_image_build.log'
self.file.write(' <td>Builder Image</td>\n')
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'
section_end_pattern = 'FROM ubuntu:bionic as oai-smf$'
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,29 +597,50 @@ 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':
self.file.write(' <td>N/A</td>\n')
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
logFileName = 'smf_docker_image_build.log'
self.file.write(' <td>Builder Image</td>\n')
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()
nb_errors = 0
nb_warnings = 0
if os.path.isfile(cwd + '/archives/' + logFileName):
section_start_pattern = 'build_smf --clean --Verbose --build-type Release --jobs'
section_end_pattern = 'FROM ubuntu:bionic as oai-smf$'
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':
self.file.write(' <td>N/A</td>\n')
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
logFileName = 'smf_docker_image_build.log'
self.file.write(' <td>Target Image</td>\n')
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):
section_start_pattern = 'Successfully tagged oai-smf'
section_end_pattern = 'OAI-SMF DOCKER IMAGE BUILD'
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 self.git_pull_request:
result = re.search('oai-smf *ci-temp', line)
else:
result = re.search('oai-smf *develop', line)
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):