Commit 3daeb91a authored by Jaroslava Fiedlerova's avatar Jaroslava Fiedlerova

Constants for CI OC RAN and CN namespace created

- CI_OC_RAN_NAMESPACE for RAN images
- CI_OC_CORE_NAMESPACE for CN deployment
- usage of the created constants for pulling images from cluster, CN deployement, iperf/ping
parent d5b78067
......@@ -42,7 +42,8 @@ IMAGE_REGISTRY_SERVICE_NAME = "image-registry.openshift-image-registry.svc"
NAMESPACE = "oaicicd-ran"
OCUrl = "https://api.oai.cs.eurecom.fr:6443"
OCRegistry = "default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/"
CI_OC_RAN_NAMESPACE = "oaicicd-ran"
CI_OC_CORE_NAMESPACE = "oaicicd-core-for-ci-ran"
def OC_login(cmd, ocUserName, ocPassword, ocProjectName):
if ocUserName == '' or ocPassword == '' or ocProjectName == '':
......@@ -198,24 +199,22 @@ class Cluster:
HELP.GenericHelp(CONST.Version)
HELP.EPCSrvHelp(self.imageToPull)
sys.exit('Insufficient eNB Parameters')
lIpAddr = self.eNBIPAddress
ocProjectName = NAMESPACE
self.testCase_id = HTML.testCase_id
cmd = cls_cmd.getConnection(lIpAddr)
succeeded = OC_login(cmd, self.OCUserName, self.OCPassword, ocProjectName)
cmd = cls_cmd.getConnection(self.eNBIPAddress)
succeeded = OC_login(cmd, self.OCUserName, self.OCPassword, CI_OC_RAN_NAMESPACE)
if not succeeded:
logging.error('\u001B[1m OC Cluster Login Failed\u001B[0m')
HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_LOGIN_FAIL)
return False
ret = cmd.run(f'oc whoami -t | docker login -u oaicicd --password-stdin {self.OCRegistry}')
if ret.returncode != 0:
logging.error(f'\u001B[1m Unable to access OC project {ocProjectName}\u001B[0m')
logging.error(f'\u001B[1m Unable to access OC project {CI_OC_RAN_NAMESPACE}\u001B[0m')
OC_logout(cmd)
cmd.close()
HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_LOGIN_FAIL)
return False
for image in self.imageToPull:
imagePrefix = f'{self.OCRegistry}{ocProjectName}'
imagePrefix = f'{self.OCRegistry}{CI_OC_RAN_NAMESPACE}'
imageTag = cls_containerize.ImageTagToUse(image, self.ranCommitID, self.ranBranch, self.ranAllowMerge)
ret = cmd.run(f'docker pull {imagePrefix}/{imageTag}')
if ret.returncode != 0:
......
......@@ -59,7 +59,6 @@ logging.getLogger("matplotlib").setLevel(logging.WARNING)
import matplotlib.pyplot as plt
import numpy as np
OC_CN_PROJECT = "oaicicd-core-for-ci-ran"
#-----------------------------------------------------------
# OaiCiTest Class Definition
#-----------------------------------------------------------
......@@ -1081,18 +1080,12 @@ class OaiCiTest():
self.Iperf_analyzeV2BIDIR(lock, ue.getHost(), ue.getName(), statusQueue, server_filename, client_filename)
elif self.iperf_direction == "IPERF3":
logging.debug("Iperf3 requested")
cmd = cls_cmd.getConnection(ue.getHost())
cmd.run(f'rm /tmp/{server_filename}', reportNonZero=False)
port = f'-p {5002+idx}'
cmd.run(f'{ue.getCmdPrefix()} iperf3 -c {cn_target_ip} {port} {iperf_opt} &> /tmp/{server_filename}', timeout=iperf_time*1.5)
cmd.close()
time.sleep(1)
cmd = cls_cmd.getConnection(ue.getHost())
cmd.copyin(f'/tmp/{server_filename}', server_filename)
cmd.close()
if udpIperf:
self.Iperf_analyzeV2Server(lock, ue.getIP(), ue.getName(), statusQueue, iperf_opt, server_filename, 1)
else:
......@@ -1240,9 +1233,8 @@ class OaiCiTest():
#if result is not None:
# dummyIperfVersion = '2.0.10'
if (re.match('OC-OAI-CN5G', EPC.Type, re.IGNORECASE)):
lOcProject = OC_CN_PROJECT
mySSH = cls_cmd.getConnection(EPC.IPAddress)
succeeded = OC.OC_login(mySSH, EPC.OCUserName, EPC.OCPassword, lOcProject)
succeeded = OC.OC_login(mySSH, EPC.OCUserName, EPC.OCPassword, OC.CI_OC_CORE_NAMESPACE)
if not succeeded:
logging.error('\u001B[1m OC Cluster Login Failed\u001B[0m')
HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_LOGIN_FAIL)
......
......@@ -75,7 +75,6 @@ class EPCManagement():
self.OCRegistry = "default-route-openshift-image-registry.apps.oai.cs.eurecom.fr/"
self.OCUserName = ''
self.OCPassword = ''
self.OCProjectName = ''
self.imageToPull = ''
self.eNBSourceCodePath = ''
......@@ -299,9 +298,8 @@ class EPCManagement():
imageNames = ["oai-nrf", "oai-amf", "oai-smf", "oai-spgwu-tiny", "oai-ausf", "oai-udm", "oai-udr", "mysql","oai-traffic-server"]
logging.debug('Deploying OAI CN5G on Openshift Cluster')
lIpAddr = self.IPAddress
lOcProject = 'oaicicd-core-for-ci-ran'
lSourcePath = "/opt/oai-cn5g-fed-develop-2023-04-28-20897"
succeeded = OC.OC_login(mySSH, self.OCUserName, self.OCPassword, lOcProject)
succeeded = OC.OC_login(mySSH, self.OCUserName, self.OCPassword, OC.CI_OC_CORE_NAMESPACE)
if not succeeded:
logging.error('\u001B[1m OC Cluster Login Failed\u001B[0m')
HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_LOGIN_FAIL)
......@@ -596,12 +594,11 @@ class EPCManagement():
elif re.match('OC-OAI-CN5G', self.Type, re.IGNORECASE):
logging.debug('Terminating OAI CN5G on Openshift Cluster')
lIpAddr = self.IPAddress
lOcProject = 'oaicicd-core-for-ci-ran'
lSourcePath = self.SourceCodePath
mySSH.run(f'rm -Rf {lSourcePath}/logs')
mySSH.run(f'mkdir -p {lSourcePath}/logs')
logging.debug('OC OAI CN5G - Collecting Log files to workspace')
succeeded = OC.OC_login(mySSH, self.OCUserName, self.OCPassword, lOcProject)
succeeded = OC.OC_login(mySSH, self.OCUserName, self.OCPassword, OC.CI_OC_CORE_NAMESPACE)
if not succeeded:
logging.error('\u001B[1m OC Cluster Login Failed\u001B[0m')
HTML.CreateHtmlTestRow('N/A', 'KO', CONST.OC_LOGIN_FAIL)
......@@ -620,7 +617,7 @@ class EPCManagement():
mySSH.run(f'cd {lSourcePath}/logs && zip -r -qq test_logs_CN.zip *.log')
mySSH.copyin(f'{lSourcePath}/logs/test_logs_CN.zip','test_logs_CN.zip')
ret = mySSH.run(f'oc get pods', silent=True)
res = re.search(f'No resources found in {lOcProject} namespace.', ret.stdout)
res = re.search(f'No resources found in {OC.CI_OC_CORE_NAMESPACE} namespace.', ret.stdout)
if res is not None:
logging.debug('OC OAI CN5G components uninstalled')
message = 'OC OAI CN5G components uninstalled'
......
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