Commit d244ea4b authored by hardy's avatar hardy

slight reformatiing of main.py ; introducing yaml for xml class definition

parent dfe6278e
...@@ -28,15 +28,30 @@ ...@@ -28,15 +28,30 @@
# pexpect # pexpect
#--------------------------------------------------------------------- #---------------------------------------------------------------------
#-----------------------------------------------------------
# Import Components
#-----------------------------------------------------------
import helpreadme as HELP
import constants as CONST import constants as CONST
import cls_physim #class PhySim for physical simulators build and test
import cls_cots_ue #class CotsUe for Airplane mode control
import sshconnection
import epc
import ran
import html
#----------------------------------------------------------- #-----------------------------------------------------------
# Import # Import Libs
#----------------------------------------------------------- #-----------------------------------------------------------
import sys # arg import sys # arg
import re # reg import re # reg
import pexpect # pexpect import pexpect # pexpect
import time # sleep import time # sleep
import os import os
import subprocess import subprocess
...@@ -50,10 +65,10 @@ logging.basicConfig( ...@@ -50,10 +65,10 @@ logging.basicConfig(
format="[%(asctime)s] %(name)s:%(levelname)s: %(message)s" format="[%(asctime)s] %(name)s:%(levelname)s: %(message)s"
) )
import cls_cots_ue
#----------------------------------------------------------- #-----------------------------------------------------------
# Class Declaration # OaiCiTest Class Definition
#----------------------------------------------------------- #-----------------------------------------------------------
class OaiCiTest(): class OaiCiTest():
...@@ -3054,20 +3069,33 @@ class OaiCiTest(): ...@@ -3054,20 +3069,33 @@ class OaiCiTest():
HTML.CpuMHz[idx]=CpuMHz HTML.CpuMHz[idx]=CpuMHz
SSH.close() SSH.close()
#-----------------------------------------------------------
# ShowTestID()
#-----------------------------------------------------------
def ShowTestID(self): def ShowTestID(self):
logging.debug('\u001B[1m----------------------------------------\u001B[0m') logging.debug('\u001B[1m----------------------------------------\u001B[0m')
logging.debug('\u001B[1mTest ID:' + self.testCase_id + '\u001B[0m') logging.debug('\u001B[1mTest ID:' + self.testCase_id + '\u001B[0m')
logging.debug('\u001B[1m' + self.desc + '\u001B[0m') logging.debug('\u001B[1m' + self.desc + '\u001B[0m')
logging.debug('\u001B[1m----------------------------------------\u001B[0m') logging.debug('\u001B[1m----------------------------------------\u001B[0m')
#-----------------------------------------------------------
# General Functions
#-----------------------------------------------------------
def CheckClassValidity(action,id): def CheckClassValidity(action,id):
if action!='COTS_UE_Airplane' and action!='Build_PhySim' and action!='Run_PhySim' and action != 'Build_eNB' and action != 'WaitEndBuild_eNB' and action != 'Initialize_eNB' and action != 'Terminate_eNB' and action != 'Initialize_UE' and action != 'Terminate_UE' and action != 'Attach_UE' and action != 'Detach_UE' and action != 'Build_OAI_UE' and action != 'Initialize_OAI_UE' and action != 'Terminate_OAI_UE' and action != 'DataDisable_UE' and action != 'DataEnable_UE' and action != 'CheckStatusUE' and action != 'Ping' and action != 'Iperf' and action != 'Reboot_UE' and action != 'Initialize_FlexranCtrl' and action != 'Terminate_FlexranCtrl' and action != 'Initialize_HSS' and action != 'Terminate_HSS' and action != 'Initialize_MME' and action != 'Terminate_MME' and action != 'Initialize_SPGW' and action != 'Terminate_SPGW' and action != 'Initialize_CatM_module' and action != 'Terminate_CatM_module' and action != 'Attach_CatM_module' and action != 'Detach_CatM_module' and action != 'Ping_CatM_module' and action != 'IdleSleep' and action != 'Perform_X2_Handover': # if action !='COTS_UE_Airplane' and action!='Build_PhySim' and action!='Run_PhySim' and action != 'Build_eNB' and action != 'WaitEndBuild_eNB' and action != 'Initialize_eNB' and action != 'Terminate_eNB' and
logging.debug('ERROR: test-case ' + id + ' has wrong class ' + action) # action != 'Initialize_UE' and action != 'Terminate_UE' and action != 'Attach_UE' and action != 'Detach_UE' and action != 'Build_OAI_UE' and action != 'Initialize_OAI_UE' and action != 'Terminate_OAI_UE' and
return False # action != 'DataDisable_UE' and action != 'DataEnable_UE' and action != 'CheckStatusUE' and action != 'Ping' and action != 'Iperf' and action != 'Reboot_UE' and action != 'Initialize_FlexranCtrl' and
return True # action != 'Terminate_FlexranCtrl' and action != 'Initialize_HSS' and action != 'Terminate_HSS' and action != 'Initialize_MME' and action != 'Terminate_MME' and action != 'Initialize_SPGW' and
# action != 'Terminate_SPGW' and action != 'Initialize_CatM_module' and action != 'Terminate_CatM_module' and action != 'Attach_CatM_module' and action != 'Detach_CatM_module' and
# action != 'Ping_CatM_module' and action != 'IdleSleep' and action != 'Perform_X2_Handover':
if action not in xml_class_list:
logging.debug('ERROR: test-case ' + id + ' has unlisted class ' + action + ' ##CHECK xml_class_list.yml')
resp=False
else:
resp=True
return resp
def GetParametersFromXML(action): def GetParametersFromXML(action):
if action == 'Build_eNB': if action == 'Build_eNB':
...@@ -3253,18 +3281,25 @@ def test_in_list(test, list): ...@@ -3253,18 +3281,25 @@ def test_in_list(test, list):
def receive_signal(signum, frame): def receive_signal(signum, frame):
sys.exit(1) sys.exit(1)
#----------------------------------------------------------- #-----------------------------------------------------------
# Parameter Check # MAIN PART
#----------------------------------------------------------- #-----------------------------------------------------------
#loading xml action list from yaml
import yaml
with open('xml_class_list.yml','r') as file:
# The FullLoader parameter handles the conversion from YAML
# scalar values to Python the dictionary format
xml_class_list = yaml.load(file,Loader=yaml.FullLoader)
mode = '' mode = ''
CiTestObj = OaiCiTest()
import sshconnection CiTestObj = OaiCiTest()
import epc
import helpreadme as HELP
import ran
import html
import constants
SSH = sshconnection.SSHConnection() SSH = sshconnection.SSHConnection()
EPC = epc.EPCManagement() EPC = epc.EPCManagement()
...@@ -3275,11 +3310,15 @@ EPC.HtmlObj=HTML ...@@ -3275,11 +3310,15 @@ EPC.HtmlObj=HTML
RAN.HtmlObj=HTML RAN.HtmlObj=HTML
RAN.EpcObj=EPC RAN.EpcObj=EPC
import cls_physim #class PhySim for physical simulators build and test
ldpc=cls_physim.PhySim() #create an instance for LDPC test using GPU or CPU build ldpc=cls_physim.PhySim() #create an instance for LDPC test using GPU or CPU build
#-----------------------------------------------------------
# Parameter Check
#-----------------------------------------------------------
argvs = sys.argv argvs = sys.argv
argc = len(argvs) argc = len(argvs)
cwd = os.getcwd() cwd = os.getcwd()
...@@ -3450,10 +3489,16 @@ while len(argvs) > 1: ...@@ -3450,10 +3489,16 @@ while len(argvs) > 1:
sys.exit('Invalid Parameter: ' + myArgv) sys.exit('Invalid Parameter: ' + myArgv)
#-----------------------------------------------------------
# COTS UE instanciation
#-----------------------------------------------------------
#COTS_UE instanciation can only be done here for the moment, due to code architecture
COTS_UE=cls_cots_ue.CotsUe('oppo', CiTestObj.UEIPAddress, CiTestObj.UEUserName,CiTestObj.UEPassword) COTS_UE=cls_cots_ue.CotsUe('oppo', CiTestObj.UEIPAddress, CiTestObj.UEUserName,CiTestObj.UEPassword)
#-----------------------------------------------------------
# XML class (action) analysis
#-----------------------------------------------------------
if re.match('^TerminateeNB$', mode, re.IGNORECASE): if re.match('^TerminateeNB$', mode, re.IGNORECASE):
if RAN.eNBIPAddress == '' or RAN.eNBUserName == '' or RAN.eNBPassword == '': if RAN.eNBIPAddress == '' or RAN.eNBUserName == '' or RAN.eNBPassword == '':
...@@ -3762,7 +3807,7 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re ...@@ -3762,7 +3807,7 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re
elif action == 'COTS_UE_Airplane': elif action == 'COTS_UE_Airplane':
COTS_UE.Set_Airplane(COTS_UE.runargs) COTS_UE.Set_Airplane(COTS_UE.runargs)
else: else:
sys.exit('Invalid action') sys.exit('Invalid class (action) from xml')
CiTestObj.FailReportCnt += 1 CiTestObj.FailReportCnt += 1
if CiTestObj.FailReportCnt == CiTestObj.repeatCounts[0] and RAN.prematureExit: if CiTestObj.FailReportCnt == CiTestObj.repeatCounts[0] and RAN.prematureExit:
logging.debug('Testsuite failed ' + str(CiTestObj.FailReportCnt) + ' time(s)') logging.debug('Testsuite failed ' + str(CiTestObj.FailReportCnt) + ' time(s)')
......
- COTS_UE_Airplane
- Build_PhySim
- Run_PhySim
- Build_eNB
- WaitEndBuild_eNB
- Initialize_eNB
- Terminate_eNB
- Initialize_UE
- Terminate_UE
- Attach_UE
- Detach_UE
- Build_OAI_UE
- Initialize_OAI_UE
- Terminate_OAI_UE
- DataDisable_UE
- DataEnable_
- CheckStatusUE
- Ping
- Iperf
- Reboot_UE
- Initialize_FlexranCtrl
- Terminate_FlexranCtrl
- Initialize_HSS
- Terminate_HSS
- Initialize_MME
- Terminate_MME
- Initialize_SPGW
- Terminate_SPGW
- Initialize_CatM_module
- Terminate_CatM_module
- Attach_CatM_module
- Detach_CatM_module
- Ping_CatM_module
- IdleSleep
- Perform_X2_Handover
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