From 586e51227e7ecec38ce9e5dded30a32295087ce6 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 18 Nov 2024 08:46:19 +0100 Subject: [PATCH] CI: deploy docker-based OAI 5GC through CoreNetwork, use in Ping/Iperf - issue OAI 5GC docker commands/scripts from ci_infra.yaml - use for matix-cn5g (un)deployment, ping, iperf in all XML files --- ci-scripts/ci_infra.yaml | 7 +- ci-scripts/epc.py | 84 ++----------------- .../container_sa_n310_2X2_100MHz_quectel.xml | 1 + .../container_sa_n310_2X2_60MHz_quectel.xml | 1 + .../container_sa_n310_4X4_60MHz_quectel.xml | 1 + .../xml_files/fr1_cn5g_basic_deploy.xml | 11 +-- .../xml_files/fr1_cn5g_basic_undeploy.xml | 4 +- 7 files changed, 19 insertions(+), 90 deletions(-) diff --git a/ci-scripts/ci_infra.yaml b/ci-scripts/ci_infra.yaml index e47645b951..261167aeaa 100644 --- a/ci-scripts/ci_infra.yaml +++ b/ci-scripts/ci_infra.yaml @@ -88,8 +88,13 @@ oc-cn5g-20897-aerial2: matix-cn5g: Host: matix NetworkScript: docker exec prod-trf-gen ip a show dev eth0 - CmdPrefix: docker exec prod-trf-gen RunIperf3Server: False + Deploy: "cd /opt/oai-cn5g-fed-v2/docker-compose && python3 ./core-network.py --type start-basic" + Undeploy: "cd /opt/oai-cn5g-fed-v2/docker-compose && python3 ./core-network.py --type stop-basic" + LogCollect: + - "docker logs oai-smf > %%log_dir%%/oai-smf.log" + - "docker logs oai-amf > %%log_dir%%/oai-amf.log" + - "docker logs oai-upf > %%log_dir%%/oai-upf.log" porcepix-cn4g: Host: porcepix diff --git a/ci-scripts/epc.py b/ci-scripts/epc.py index bb9d056fae..715f0848df 100644 --- a/ci-scripts/epc.py +++ b/ci-scripts/epc.py @@ -197,44 +197,7 @@ class EPCManagement(): if re.match('ltebox', self.Type, re.IGNORECASE): raise NotImplemented("use cls_corenetwork.py") elif re.match('OAICN5G', self.Type, re.IGNORECASE): - logging.debug('Starting OAI CN5G') - mySSH.command('if [ -d ' + self.SourceCodePath + '/scripts ]; then echo ' + self.Password + ' | sudo -S rm -Rf ' + self.SourceCodePath + '/scripts ; fi', '\$', 5) - mySSH.command('mkdir -p ' + self.SourceCodePath + '/scripts', '\$', 5) - mySSH.command(f'cd {self.SourceCodePath}/docker-compose', '\$', 5) - mySSH.command('python3 ./core-network.py '+self.cfgDeploy, '\$', 60) - if re.search('start-mini-as-ue', self.cfgDeploy): - dFile = 'docker-compose-mini-nrf-asue.yaml' - elif re.search('basic', self.cfgDeploy):\ - dFile = 'docker-compose-basic-nrf.yaml' - else: - dFile = 'docker-compose-mini-nrf.yaml' - mySSH.command('docker-compose -f ' + dFile + ' ps -a', '\$', 60) - if mySSH.getBefore().count('Up (healthy)') != 6: - logging.error('Not all container healthy') - else: - logging.debug('OK --> all containers are healthy') - mySSH.command('docker-compose -f ' + dFile + ' config | grep --colour=never image', '\$', 10) - listOfImages = mySSH.getBefore() - for imageLine in listOfImages.split('\\r\\n'): - res1 = re.search('image: (?P[a-zA-Z0-9\-/]+):(?P[a-zA-Z0-9\-]+)', str(imageLine)) - res2 = re.search('mysql', str(imageLine)) - if res1 is not None and res2 is None: - html_cell += res1.group('name') + ':' + res1.group('tag') + ' ' - nbChars = len(res1.group('name')) + len(res1.group('tag')) + 2 - while (nbChars < 32): - html_cell += ' ' - nbChars += 1 - mySSH.command('docker image inspect --format="Size = {{.Size}} bytes" ' + res1.group('name') + ':' + res1.group('tag'), '\$', 10) - res3 = re.search('Size *= *(?P[0-9\-]*) *bytes', mySSH.getBefore()) - if res3 is not None: - imageSize = int(res3.group('size')) - imageSize = int(imageSize/(1024*1024)) - html_cell += str(imageSize) + ' MBytes ' - mySSH.command('docker image inspect --format="Date = {{.Created}}" ' + res1.group('name') + ':' + res1.group('tag'), '\$', 10) - res4 = re.search('Date *= *(?P[0-9\-]*)T', mySSH.getBefore()) - if res4 is not None: - html_cell += '(' + res4.group('date') + ')' - html_cell += '\n' + raise NotImplemented("use cls_corenetwork.py") elif re.match('OC-OAI-CN5G', self.Type, re.IGNORECASE): raise NotImplemented("use cls_corenetwork.py") else: @@ -252,17 +215,7 @@ class EPCManagement(): if re.match('ltebox', self.Type, re.IGNORECASE): raise NotImplemented("use cls_corenetwork.py") elif re.match('OAICN5G', self.Type, re.IGNORECASE): - mySSH = SSH.SSHConnection() - mySSH.open(self.IPAddress, self.UserName, self.Password) - response=mySSH.command3('docker container ls -f name=oai-amf', 10) - if len(response)>1: - response=mySSH.command3('docker inspect --format=\'{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}\' oai-amf', 10) - tmp = str(response[0],'utf-8') - self.MmeIPAddress = tmp.rstrip() - logging.debug('AMF IP Address ' + self.MmeIPAddress) - else: - logging.error('no container with name oai-amf found, could not retrieve AMF IP address') - mySSH.close() + raise NotImplemented("use cls_corenetwork.py") elif re.match('OC-OAI-CN5G', self.Type, re.IGNORECASE): raise NotImplemented("use cls_corenetwork.py") @@ -341,27 +294,7 @@ class EPCManagement(): if re.match('ltebox', self.Type, re.IGNORECASE): raise NotImplemented("use cls_corenetwork.py") elif re.match('OAICN5G', self.Type, re.IGNORECASE): - logging.debug('OAI CN5G Collecting Log files to workspace') - mySSH.command('echo ' + self.Password + ' | sudo rm -rf ' + self.SourceCodePath + '/logs', '\$', 5) - mySSH.command('mkdir ' + self.SourceCodePath + '/logs','\$', 5) - containers_list=['oai-smf','oai-spgwu','oai-amf','oai-nrf'] - for c in containers_list: - mySSH.command('docker logs ' + c + ' > ' + self.SourceCodePath + '/logs/' + c + '.log', '\$', 5) - - logging.debug('Terminating OAI CN5G') - mySSH.command(f'cd {self.SourceCodePath}/docker-compose', '\$', 5) - mySSH.command('python3 ./core-network.py '+self.cfgUnDeploy, '\$', 60) - mySSH.command('docker volume prune --force || true', '\$', 60) - time.sleep(2) - mySSH.command('tshark -r /tmp/oai-cn5g-v1.5.pcap | grep -E --colour=never "Tracking area update" ','\$', 30) - result = re.search('Tracking area update request', mySSH.getBefore()) - if result is not None: - message = 'UE requested ' + str(mySSH.getBefore().count('Tracking area update request')) + 'Tracking area update request(s)' - else: - message = 'No Tracking area update request' - mySSH.run(f'cd {self.SourceCodePath}/logs && zip -r -qq test_logs_CN.zip *.log') - mySSH.copyin(f'{self.SourceCodePath}/logs/test_logs_CN.zip','test_logs_CN.zip') - logging.debug(message) + raise NotImplemented("use cls_corenetwork.py") elif re.match('OC-OAI-CN5G', self.Type, re.IGNORECASE): raise NotImplemented("use cls_corenetwork.py") else: @@ -611,7 +544,7 @@ class EPCManagement(): mySSH.command('docker cp ' + self.containerPrefix + '-oai-hss:/tmp/hss_check_run.pcap .', '\$', 60) mySSH.command('zip hss.log.zip hss_check_run.*', '\$', 60) elif re.match('OAICN5G', self.Type, re.IGNORECASE): - logging.debug('LogCollect is bypassed for that variant') + raise NotImplemented("use cls_corenetwork.py") elif re.match('OC-OAI-CN5G', self.Type, re.IGNORECASE): raise NotImplemented("use cls_corenetwork.py") elif re.match('OAI', self.Type, re.IGNORECASE) or re.match('OAI-Rel14-CUPS', self.Type, re.IGNORECASE): @@ -643,10 +576,7 @@ class EPCManagement(): mySSH.command('docker cp ' + self.containerPrefix + '-oai-mme:/tmp/mme_check_run.pcap .', '\$', 60) mySSH.command('zip mme.log.zip mme_check_run.*', '\$', 60) elif re.match('OAICN5G', self.Type, re.IGNORECASE): - mySSH.command('cd ' + self.SourceCodePath + '/logs','\$', 5) - mySSH.command('cp -f /tmp/oai-cn5g-v1.5.pcap .','\$', 30) - mySSH.command('zip mme.log.zip oai-amf.log oai-nrf.log oai-cn5g*.pcap','\$', 30) - mySSH.command('mv mme.log.zip ' + self.SourceCodePath + '/scripts','\$', 30) + raise NotImplemented("use cls_corenetwork.py") elif re.match('OC-OAI-CN5G', self.Type, re.IGNORECASE): raise NotImplemented("use cls_corenetwork.py") elif re.match('OAI', self.Type, re.IGNORECASE) or re.match('OAI-Rel14-CUPS', self.Type, re.IGNORECASE): @@ -677,9 +607,7 @@ class EPCManagement(): mySSH.command('docker cp ' + self.containerPrefix + '-oai-spgwu-tiny:/tmp/spgwu_check_run.pcap .', '\$', 60) mySSH.command('zip spgw.log.zip spgw*_check_run.*', '\$', 60) elif re.match('OAICN5G', self.Type, re.IGNORECASE): - mySSH.command('cd ' + self.SourceCodePath + '/logs','\$', 5) - mySSH.command('zip spgw.log.zip oai-smf.log oai-spgwu.log','\$', 30) - mySSH.command('mv spgw.log.zip ' + self.SourceCodePath + '/scripts','\$', 30) + raise NotImplemented("use cls_corenetwork.py") elif re.match('OC-OAI-CN5G', self.Type, re.IGNORECASE): raise NotImplemented("use cls_corenetwork.py") elif re.match('OAI', self.Type, re.IGNORECASE) or re.match('OAI-Rel14-CUPS', self.Type, re.IGNORECASE): diff --git a/ci-scripts/xml_files/container_sa_n310_2X2_100MHz_quectel.xml b/ci-scripts/xml_files/container_sa_n310_2X2_100MHz_quectel.xml index 15a9ad4065..90687e39f0 100644 --- a/ci-scripts/xml_files/container_sa_n310_2X2_100MHz_quectel.xml +++ b/ci-scripts/xml_files/container_sa_n310_2X2_100MHz_quectel.xml @@ -108,6 +108,7 @@ Ping Ping: 100pings in 20sec up2 + matix-cn5g -c 100 -i 0.2 %cn_ip% 1 15 diff --git a/ci-scripts/xml_files/container_sa_n310_2X2_60MHz_quectel.xml b/ci-scripts/xml_files/container_sa_n310_2X2_60MHz_quectel.xml index 52b05df661..631acc3285 100644 --- a/ci-scripts/xml_files/container_sa_n310_2X2_60MHz_quectel.xml +++ b/ci-scripts/xml_files/container_sa_n310_2X2_60MHz_quectel.xml @@ -108,6 +108,7 @@ Ping Ping: 100pings in 20sec up2 + matix-cn5g -c 100 -i 0.2 %cn_ip% 1 15 diff --git a/ci-scripts/xml_files/container_sa_n310_4X4_60MHz_quectel.xml b/ci-scripts/xml_files/container_sa_n310_4X4_60MHz_quectel.xml index 9ec5b37245..58e2825ff3 100644 --- a/ci-scripts/xml_files/container_sa_n310_4X4_60MHz_quectel.xml +++ b/ci-scripts/xml_files/container_sa_n310_4X4_60MHz_quectel.xml @@ -108,6 +108,7 @@ Ping Ping: 100pings in 20sec up2 + matix-cn5g -c 100 -i 0.2 %cn_ip% 1 15 diff --git a/ci-scripts/xml_files/fr1_cn5g_basic_deploy.xml b/ci-scripts/xml_files/fr1_cn5g_basic_deploy.xml index 0ea2311a1f..3561d11fc9 100644 --- a/ci-scripts/xml_files/fr1_cn5g_basic_deploy.xml +++ b/ci-scripts/xml_files/fr1_cn5g_basic_deploy.xml @@ -26,20 +26,13 @@ log-in 000100 - 000200 - Terminate_5GCN - Terminate 5G Core - --type stop-basic - - - - Initialize_5GCN + DeployCoreNetwork Initialize 5G Core - --type start-basic + matix-cn5g diff --git a/ci-scripts/xml_files/fr1_cn5g_basic_undeploy.xml b/ci-scripts/xml_files/fr1_cn5g_basic_undeploy.xml index 190b58ac1b..56d7cf74c0 100644 --- a/ci-scripts/xml_files/fr1_cn5g_basic_undeploy.xml +++ b/ci-scripts/xml_files/fr1_cn5g_basic_undeploy.xml @@ -31,9 +31,9 @@ - Terminate_5GCN + UndeployCoreNetwork Terminate 5G Core - --type stop-basic + matix-cn5g