Commit 085d4830 authored by Robert Schmidt's avatar Robert Schmidt

Merge remote-tracking branch 'origin/remove-use-old-ssh-class' into integration_2024_w45 (!3087)

Remove some usage of the old CI sshConnection class
parents c0e386e4 0784d190
This diff is collapsed.
...@@ -43,7 +43,6 @@ import json ...@@ -43,7 +43,6 @@ import json
#import our libs #import our libs
import helpreadme as HELP import helpreadme as HELP
import constants as CONST import constants as CONST
import sshconnection
import cls_module import cls_module
import cls_cmd import cls_cmd
...@@ -895,55 +894,43 @@ class OaiCiTest(): ...@@ -895,55 +894,43 @@ class OaiCiTest():
SourceCodePath = self.UESourceCodePath SourceCodePath = self.UESourceCodePath
else: else:
sys.exit('Insufficient Parameter') sys.exit('Insufficient Parameter')
SSH = sshconnection.SSHConnection() with cls_cmd.getConnection(IPAddress) as cmd:
SSH.open(IPAddress, UserName, Password) d = f'{SourceCodePath}/cmake_targets'
SSH.command(f'cd {SourceCodePath}', '\$', 5) cmd.run(f'rm -f {d}/build.log.zip')
SSH.command('cd cmake_targets', '\$', 5) cmd.run(f'cd {d} && zip -r build.log.zip build_log_*/*')
SSH.command('rm -f build.log.zip', '\$', 5)
SSH.command('zip -r build.log.zip build_log_*/*', '\$', 60)
SSH.close()
def LogCollectPing(self,EPC): def LogCollectPing(self,EPC):
# Some pipelines are using "none" IP / Credentials # Some pipelines are using "none" IP / Credentials
# In that case, just forget about it # In that case, just forget about it
if EPC.IPAddress == 'none': if EPC.IPAddress == 'none':
sys.exit(0) sys.exit(0)
SSH = sshconnection.SSHConnection() with cls_cmd.getConnection(EPC.IPAddress) as cmd:
SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) d = f"{EPC.SourceCodePath}/scripts"
SSH.command(f'cd {EPC.SourceCodePath}', '\$', 5) cmd.run(f'rm -f {d}/ping.log.zip')
SSH.command('cd scripts', '\$', 5) cmd.run(f'cd {d} && zip ping.log.zip ping*.log')
SSH.command('rm -f ping.log.zip', '\$', 5) cmd.run(f'rm {d}/ping*.log')
SSH.command('zip ping.log.zip ping*.log', '\$', 60)
SSH.command('rm ping*.log', '\$', 5)
SSH.close()
def LogCollectIperf(self,EPC): def LogCollectIperf(self,EPC):
# Some pipelines are using "none" IP / Credentials # Some pipelines are using "none" IP / Credentials
# In that case, just forget about it # In that case, just forget about it
if EPC.IPAddress == 'none': if EPC.IPAddress == 'none':
sys.exit(0) sys.exit(0)
SSH = sshconnection.SSHConnection() with cls_cmd.getConnection(EPC.IPAddress) as cmd:
SSH.open(EPC.IPAddress, EPC.UserName, EPC.Password) d = f"{EPC.SourceCodePath}/scripts"
SSH.command(f'cd {EPC.SourceCodePath}', '\$', 5) cmd.run(f'rm -f {d}/iperf.log.zip')
SSH.command('cd scripts', '\$', 5) cmd.run(f'cd {d} && zip iperf.log.zip iperf*.log')
SSH.command('rm -f iperf.log.zip', '\$', 5) cmd.run(f'rm {d}/iperf*.log')
SSH.command('zip iperf.log.zip iperf*.log', '\$', 60)
SSH.command('rm iperf*.log', '\$', 5)
SSH.close()
def LogCollectOAIUE(self): def LogCollectOAIUE(self):
# Some pipelines are using "none" IP / Credentials # Some pipelines are using "none" IP / Credentials
# In that case, just forget about it # In that case, just forget about it
if self.UEIPAddress == 'none': if self.UEIPAddress == 'none':
sys.exit(0) sys.exit(0)
SSH = sshconnection.SSHConnection() with cls_cmd.getConnection(self.UEIPAddress) as cmd:
SSH.open(self.UEIPAddress, self.UEUserName, self.UEPassword) d = f'{self.UESourceCodePath}/cmake_targets'
SSH.command(f'cd {self.UESourceCodePath}', '\$', 5) cmd.run(f'echo {self.UEPassword} | sudo -S rm -f {d}/ue.log.zip')
SSH.command(f'cd cmake_targets', '\$', 5) cmd.run(f'cd {d} && echo {self.UEPassword} | sudo -S zip ue.log.zip ue*.log core* ue_*record.raw ue_*.pcap ue_*txt')
SSH.command(f'echo {self.UEPassword} | sudo -S rm -f ue.log.zip', '\$', 5) cmd.run(f'echo {self.UEPassword} | sudo -S rm {d}/ue*.log {d}/core* {d}/ue_*record.raw {d}/ue_*.pcap {d}/ue_*txt')
SSH.command(f'echo {self.UEPassword} | sudo -S zip ue.log.zip ue*.log core* ue_*record.raw ue_*.pcap ue_*txt', '\$', 60)
SSH.command(f'echo {self.UEPassword} | sudo -S rm ue*.log core* ue_*record.raw ue_*.pcap ue_*txt', '\$', 5)
SSH.close()
def ShowTestID(self): def ShowTestID(self):
logging.info(f'\u001B[1m----------------------------------------\u001B[0m') logging.info(f'\u001B[1m----------------------------------------\u001B[0m')
......
...@@ -46,7 +46,6 @@ import cls_physim1 #class PhySim for physical simulators deploy and run ...@@ -46,7 +46,6 @@ import cls_physim1 #class PhySim for physical simulators deploy and run
import cls_cluster # class for building/deploying on cluster import cls_cluster # class for building/deploying on cluster
import cls_native # class for all native/source-based operations import cls_native # class for all native/source-based operations
import sshconnection
import epc import epc
import ran import ran
import cls_oai_html import cls_oai_html
...@@ -100,7 +99,6 @@ def AssignParams(params_dict): ...@@ -100,7 +99,6 @@ def AssignParams(params_dict):
def ExecuteActionWithParam(action): def ExecuteActionWithParam(action):
global SSH
global EPC global EPC
global RAN global RAN
global HTML global HTML
...@@ -484,7 +482,6 @@ mode = '' ...@@ -484,7 +482,6 @@ mode = ''
CiTestObj = cls_oaicitest.OaiCiTest() CiTestObj = cls_oaicitest.OaiCiTest()
SSH = sshconnection.SSHConnection()
EPC = epc.EPCManagement() EPC = epc.EPCManagement()
RAN = ran.RANManagement() RAN = ran.RANManagement()
HTML = cls_oai_html.HTMLManagement() HTML = cls_oai_html.HTMLManagement()
...@@ -696,26 +693,6 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re ...@@ -696,26 +693,6 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re
HTML.CreateHtmlTabHeader() HTML.CreateHtmlTabHeader()
# On CI bench w/ containers, we need to validate if IP routes are set
if EPC.IPAddress == '172.21.16.136':
CONTAINERS.CheckAndAddRoute('porcepix', EPC.IPAddress, EPC.UserName, EPC.Password)
if EPC.IPAddress == '172.21.16.137':
CONTAINERS.CheckAndAddRoute('nepes', EPC.IPAddress, EPC.UserName, EPC.Password)
if CONTAINERS.eNBIPAddress == '172.21.16.127':
CONTAINERS.CheckAndAddRoute('asterix', CONTAINERS.eNBIPAddress, CONTAINERS.eNBUserName, CONTAINERS.eNBPassword)
if CONTAINERS.eNB1IPAddress == '172.21.16.127':
CONTAINERS.CheckAndAddRoute('asterix', CONTAINERS.eNB1IPAddress, CONTAINERS.eNB1UserName, CONTAINERS.eNB1Password)
if CONTAINERS.eNBIPAddress == '172.21.16.128':
CONTAINERS.CheckAndAddRoute('obelix', CONTAINERS.eNBIPAddress, CONTAINERS.eNBUserName, CONTAINERS.eNBPassword)
if CONTAINERS.eNB1IPAddress == '172.21.16.128':
CONTAINERS.CheckAndAddRoute('obelix', CONTAINERS.eNB1IPAddress, CONTAINERS.eNB1UserName, CONTAINERS.eNB1Password)
if CONTAINERS.eNBIPAddress == '172.21.16.109' or CONTAINERS.eNBIPAddress == 'ofqot':
CONTAINERS.CheckAndAddRoute('ofqot', CONTAINERS.eNBIPAddress, CONTAINERS.eNBUserName, CONTAINERS.eNBPassword)
if CONTAINERS.eNBIPAddress == '172.21.16.137':
CONTAINERS.CheckAndAddRoute('nepes', CONTAINERS.eNBIPAddress, CONTAINERS.eNBUserName, CONTAINERS.eNBPassword)
if CONTAINERS.eNB1IPAddress == '172.21.16.137':
CONTAINERS.CheckAndAddRoute('nepes', CONTAINERS.eNB1IPAddress, CONTAINERS.eNB1UserName, CONTAINERS.eNB1Password)
task_set_succeeded = True task_set_succeeded = True
HTML.startTime=int(round(time.time() * 1000)) HTML.startTime=int(round(time.time() * 1000))
......
...@@ -15,7 +15,7 @@ ref=$3 ...@@ -15,7 +15,7 @@ ref=$3
merge=$4 merge=$4
rm -rf ${dir} rm -rf ${dir}
git clone --filter=blob:none -n -b develop ${repo} ${dir} git clone --filter=blob:none -n ${repo} ${dir}
cd ${dir} cd ${dir}
git config user.email "jenkins@openairinterface.org" git config user.email "jenkins@openairinterface.org"
git config user.name "OAI Jenkins" git config user.name "OAI Jenkins"
......
...@@ -3,18 +3,28 @@ scripts. ...@@ -3,18 +3,28 @@ scripts.
# Unit test # Unit test
There are some unit tests. From the parent directory, i.e., `ci-scripts/`, This repository contains unit tests. To run them, switch to the parent
start with directory, i.e., `ci-scripts/`, and run
python3 -m unittest tests/*.py
To run individual unit tests, start them like so:
python tests/build.py -v
python tests/cmd.py -v
python tests/deployment.py -v python tests/deployment.py -v
python tests/ping-iperf.py -v
python tests/iperf-analysis.py -v python tests/iperf-analysis.py -v
python tests/ping-iperf.py -v
It will indicate if all tests passed. It assumes that these images are present: The logs will indicate if all tests passed. `tests/deployment.py` requires
these images to be present:
- `oai-ci/oai-nr-ue:develop-12345678` - `oai-ci/oai-nr-ue:develop-12345678`
- `oai-ci/oai-gnb:develop-12345678` - `oai-ci/oai-gnb:develop-12345678`
It will try to download `oaisoftwarealliance/oai-{gnb,nr-ue}:develop`
automatically and retag the images.
# test-runner test # test-runner test
This is not a true test, because the results need to be manually inspected. To This is not a true test, because the results need to be manually inspected. To
......
import sys
import logging
logging.basicConfig(
level=logging.DEBUG,
stream=sys.stdout,
format="[%(asctime)s] %(levelname)8s: %(message)s"
)
import unittest
import tempfile
sys.path.append('./') # to find OAI imports below
import cls_oai_html
import cls_containerize
import cls_cmd
class TestBuild(unittest.TestCase):
def setUp(self):
self.html = cls_oai_html.HTMLManagement()
self.html.testCase_id = "000000"
self.cont = cls_containerize.Containerize()
self.cont.eNB_serverId[0] = '0'
self.cont.eNBIPAddress = 'localhost'
self.cont.eNBUserName = None
self.cont.eNBPassword = None
self._d = tempfile.mkdtemp()
logging.warning(f"temporary directory: {self._d}")
self.cont.eNBSourceCodePath = self._d
def tearDown(self):
logging.warning(f"removing directory contents")
with cls_cmd.getConnection(None) as cmd:
cmd.run(f"rm -rf {self._d}")
def test_build_proxy(self):
self.cont.proxyCommit = "b64d9bce986b38ca59e8582864ade3fcdd05c0dc"
success = self.cont.BuildProxy(self.html)
self.assertTrue(success)
if __name__ == '__main__':
unittest.main()
...@@ -15,9 +15,24 @@ import cls_oai_html ...@@ -15,9 +15,24 @@ import cls_oai_html
import cls_oaicitest import cls_oaicitest
import cls_containerize import cls_containerize
import ran import ran
import cls_cmd
class TestDeploymentMethods(unittest.TestCase): class TestDeploymentMethods(unittest.TestCase):
def _pull_image(self, cmd, image):
ret = cmd.run(f"docker inspect oai-ci/{image}:develop-12345678")
if ret.returncode == 0: # exists
return
ret = cmd.run(f"docker pull oaisoftwarealliance/{image}:develop")
self.assertEqual(ret.returncode, 0)
ret = cmd.run(f"docker tag oaisoftwarealliance/{image}:develop oai-ci/{image}:develop-12345678")
self.assertEqual(ret.returncode, 0)
ret = cmd.run(f"docker rmi oaisoftwarealliance/{image}:develop")
self.assertEqual(ret.returncode, 0)
def setUp(self): def setUp(self):
with cls_cmd.getConnection("localhost") as cmd:
self._pull_image(cmd, "oai-gnb")
self._pull_image(cmd, "oai-nr-ue")
self.html = cls_oai_html.HTMLManagement() self.html = cls_oai_html.HTMLManagement()
self.html.testCaseId = "000000" self.html.testCaseId = "000000"
self.ci = cls_oaicitest.OaiCiTest() self.ci = cls_oaicitest.OaiCiTest()
......
...@@ -25,17 +25,10 @@ ...@@ -25,17 +25,10 @@
<htmlTabName>Build L2sim proxy image</htmlTabName> <htmlTabName>Build L2sim proxy image</htmlTabName>
<htmlTabIcon>wrench</htmlTabIcon> <htmlTabIcon>wrench</htmlTabIcon>
<TestCaseRequestedList> <TestCaseRequestedList>
100001
000001 000001
</TestCaseRequestedList> </TestCaseRequestedList>
<TestCaseExclusionList></TestCaseExclusionList> <TestCaseExclusionList></TestCaseExclusionList>
<testCase id="100001">
<class>Create_Workspace</class>
<desc>Create new Workspace</desc>
<eNB_instance>1</eNB_instance>
<eNB_serverId>1</eNB_serverId>
</testCase>
<testCase id="000001"> <testCase id="000001">
<class>Build_Proxy</class> <class>Build_Proxy</class>
<desc>Build L2sim Proxy Image</desc> <desc>Build L2sim Proxy Image</desc>
......
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