diff --git a/.gitignore b/.gitignore index acfc63c2e5cc5c9a9cff84933830b1fdce462eb8..a2fca4cf8d00da516ad32563e638a5f70b5c6aa4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ +archives/ +DS-TEST-RESULTS/ ci-scripts/mysql-complete.cmd +ci-scripts/temp/ci-generate_amf_conf.sh diff --git a/ci-scripts/Jenkinsfile-GitLab-Docker b/ci-scripts/Jenkinsfile-GitLab-Docker index d1212d7306befeba08e3d8727e6c6d5fae972cdb..39253ab9fb701674ce0405a5b4c83c92c48c294f 100644 --- a/ci-scripts/Jenkinsfile-GitLab-Docker +++ b/ci-scripts/Jenkinsfile-GitLab-Docker @@ -172,7 +172,10 @@ pipeline { stage ('Deploy Containers') { steps { script { - sh "sleep 10" + // Deploy and configure MySQL Server + myShCmd('python3 ./ci-scripts/dsTestDeployTools.py --action=DeployMySqlServer', new_host_flag, new_host_user, new_host) + // Deploy and configure AMF + myShCmd('python3 ./ci-scripts/dsTestDeployTools.py --action=DeployAMF --tag=' + amfTag, new_host_flag, new_host_user, new_host) } } } @@ -194,8 +197,7 @@ pipeline { steps { script { // Remove the containers - //myShCmd('python3 ./ci-scripts/dsTestDeployTools.py --action=RemoveAllContainers', new_host_flag, new_host_user, new_host) - sh "sleep 10" + myShCmd('python3 ./ci-scripts/dsTestDeployTools.py --action=RemoveAllContainers', new_host_flag, new_host_user, new_host) } } } diff --git a/ci-scripts/dsTestDeployTools.py b/ci-scripts/dsTestDeployTools.py index 882b473304ab5aede567fcab37f49cdf5ad41553..e97d62ce8eded6e2f0f4472808659ce412390696 100644 --- a/ci-scripts/dsTestDeployTools.py +++ b/ci-scripts/dsTestDeployTools.py @@ -31,6 +31,8 @@ CICD_PUBLIC_NETWORK_RANGE='192.168.61.192/26' CICD_MYSQL_PUBLIC_ADDR='192.168.61.194' CICD_AMF_PUBLIC_ADDR='192.168.61.195' +CICD_SMF_PUBLIC_ADDR='192.168.61.196' +CICD_DUMMY_SMF_PUBLIC_ADDR='192.168.61.200' class deployForDsTester(): def __init__(self): @@ -85,6 +87,24 @@ class deployForDsTester(): time.sleep(2) subprocess_run_w_echo('docker exec -it cicd-mysql-svr /bin/bash -c "mysql -uroot -psecretPassword < /home/mysql-complete.cmd"') + def deployAMF(self): + res = '' + # first check if tag exists + try: + res = subprocess.check_output('docker image inspect oai-amf:' + self.tag, shell=True, universal_newlines=True) + except: + sys.exit(-1) + + # check if there is an entrypoint + entrypoint = re.search('entrypoint', str(res)) + if entrypoint is not None: + print('not supported yet') + else: + subprocess_run_w_echo('docker run --privileged --name cicd-oai-amf --network cicd-oai-public-net --ip ' + CICD_AMF_PUBLIC_ADDR + ' -d oai-amf:' + self.tag + ' /bin/bash -c "sleep infinity"') + subprocess_run_w_echo('sed -e "s@CI_NGAP_IF_NAME@eth0@" -e "s@CI_N11_IF_NAME@eth0@" -e "s@CI_SMF0_IP_ADDRESS@' + CICD_SMF_PUBLIC_ADDR + '@" -e "s@CI_SMF1_IP_ADDRESS@' + CICD_DUMMY_SMF_PUBLIC_ADDR + '@" -e "s@CI_MYSQL_IP_ADDRESS@' + CICD_MYSQL_PUBLIC_ADDR + '@" ci-scripts/temp/generate_amf_conf.sh > ci-scripts/temp/ci-generate_amf_conf.sh') + subprocess_run_w_echo('docker cp ci-scripts/temp/ci-generate_amf_conf.sh cicd-oai-amf:/openair-amf/generate_amf_conf.sh') + subprocess_run_w_echo('docker exec -it cicd-oai-amf /bin/bash -c "chmod 755 generate_amf_conf.sh && ./generate_amf_conf.sh" > archives/amf_config.log') + def removeAllContainers(self): try: subprocess_run_w_echo('docker rm -f cicd-mysql-svr') @@ -111,6 +131,7 @@ def Usage(): print('python3 dsTestDeployTools.py --action=CreateNetworks') print('python3 dsTestDeployTools.py --action=RemoveNetworks') print('python3 dsTestDeployTools.py --action=DeployMySqlServer') + print('python3 dsTestDeployTools.py --action=DeployAMF --tag=[tag]') print('python3 dsTestDeployTools.py --action=RemoveAllContainers') #-------------------------------------------------------------------------------------------------------- @@ -135,6 +156,7 @@ while len(argvs) > 1: if action != 'CreateNetworks' and \ action != 'RemoveNetworks' and \ action != 'DeployMySqlServer' and \ + action != 'DeployAMF' and \ action != 'RemoveAllContainers': print('Unsupported Action => ' + action) Usage() @@ -150,6 +172,12 @@ elif DFDT.action == 'RemoveNetworks': DFDT.removeNetworks() elif DFDT.action == 'DeployMySqlServer': DFDT.deployMySqlServer() +elif DFDT.action == 'DeployAMF': + if DFDT.tag == '': + print('Missing OAI-AMF image tag') + Usage() + sys.exit(-1) + DFDT.deployAMF() elif DFDT.action == 'RemoveAllContainers': DFDT.removeAllContainers() diff --git a/ci-scripts/temp/generate_amf_conf.sh b/ci-scripts/temp/generate_amf_conf.sh new file mode 100755 index 0000000000000000000000000000000000000000..7a5dbc1eba757f7dc49d52054491d88a41031bf1 --- /dev/null +++ b/ci-scripts/temp/generate_amf_conf.sh @@ -0,0 +1,56 @@ +# prompt has been removed for easier Ctrl+C Ctrl+V +# please update the following information according to your configuration + +INSTANCE=1 +PREFIX='/openair-amf/etc' + +declare -A AMF_CONF + +AMF_CONF[@INSTANCE@]=$INSTANCE +AMF_CONF[@PID_DIRECTORY@]='/var/run' + +AMF_CONF[@MCC@]='208' +AMF_CONF[@MNC@]='95' +AMF_CONF[@REGION_ID@]='128' +AMF_CONF[@AMF_SET_ID@]='1' + +AMF_CONF[@SERVED_GUAMI_MCC_0@]='208' +AMF_CONF[@SERVED_GUAMI_MNC_0@]='95' +AMF_CONF[@SERVED_GUAMI_REGION_ID_0@]='128' +AMF_CONF[@SERVED_GUAMI_AMF_SET_ID_0@]='1' +AMF_CONF[@SERVED_GUAMI_MCC_1@]='460' +AMF_CONF[@SERVED_GUAMI_MNC_1@]='11' +AMF_CONF[@SERVED_GUAMI_REGION_ID_1@]='10' +AMF_CONF[@SERVED_GUAMI_AMF_SET_ID_1@]='1' + +AMF_CONF[@PLMN_SUPPORT_MCC@]='208' +AMF_CONF[@PLMN_SUPPORT_MNC@]='95' +AMF_CONF[@PLMN_SUPPORT_TAC@]='0xa000' +AMF_CONF[@SST_0@]='222' +AMF_CONF[@SD_0@]='123' +AMF_CONF[@SST_1@]='1' +AMF_CONF[@SD_1@]='12' + +AMF_CONF[@AMF_INTERFACE_NAME_FOR_NGAP@]='CI_NGAP_IF_NAME' +AMF_CONF[@AMF_INTERFACE_NAME_FOR_N11@]='CI_N11_IF_NAME' + +AMF_CONF[@SMF_INSTANCE_ID_0@]='1' +AMF_CONF[@SMF_IPV4_ADDR_0@]='CI_SMF0_IP_ADDRESS' +AMF_CONF[@SMF_HTTP_VERSION_0@]='v1' +AMF_CONF[@SMF_INSTANCE_ID_1@]='2' +AMF_CONF[@SMF_IPV4_ADDR_1@]='CI_SMF1_IP_ADDRESS' +AMF_CONF[@SMF_HTTP_VERSION_1@]='v1' + + +AMF_CONF[@MYSQL_SERVER@]='CI_MYSQL_IP_ADDRESS' +AMF_CONF[@MYSQL_USER@]='root' +AMF_CONF[@MYSQL_PASS@]='linux' +AMF_CONF[@MYSQL_DB@]='oai_db' +AMF_CONF[@OPERATOR_KEY@]='63bfa50ee6523365ff14c1f45f88737d' + +for K in "${!AMF_CONF[@]}"; do + egrep -lRZ "$K" $PREFIX/amf.conf | xargs -0 -l sed -i -e "s|$K|${AMF_CONF[$K]}|g" + ret=$?;[[ ret -ne 0 ]] && echo "Tried to replace $K with ${AMF_CONF[$K]}" +done + +echo "AMF Configuration Successful"