Commit b6daabc2 authored by hardy's avatar hardy

tentative to improve Module control encapsulation

parent 8def7528
...@@ -2,9 +2,12 @@ idefix: ...@@ -2,9 +2,12 @@ idefix:
ID: idefix ID: idefix
State : enabled State : enabled
Kind : quectel Kind : quectel
Process : quectel-CM Process :
Name : quectel-CM
Cmd : /home/oaicicd/quectel-CM/quectel-CM -s oai.ipv4 -4
WakeupScript : ci_ctl_qtel.py /dev/ttyUSB2 wup WakeupScript : ci_ctl_qtel.py /dev/ttyUSB2 wup
DetachScript : ci_ctl_qtel.py /dev/ttyUSB2 detach DetachScript : ci_ctl_qtel.py /dev/ttyUSB2 detach
PLMN : 22201
UENetwork : wwan0 UENetwork : wwan0
HostIPAddress : 192.168.18.188 HostIPAddress : 192.168.18.188
HostUsername : oaicicd HostUsername : oaicicd
......
...@@ -56,7 +56,8 @@ class Module_UE: ...@@ -56,7 +56,8 @@ class Module_UE:
for k, v in Module.items(): for k, v in Module.items():
setattr(self, k, v) setattr(self, k, v)
self.UEIPAddress = "" self.UEIPAddress = ""
#dictionary linking command names and related module scripts
self.cmd_dict= {"wup": self.WakeupScript,"detach":self.DetachScript}#dictionary of function scripts
...@@ -65,56 +66,72 @@ class Module_UE: ...@@ -65,56 +66,72 @@ class Module_UE:
#-----------------$ #-----------------$
#this method checks if the specified Process is running on the server hosting the module #this method checks if the specified Process is running on the server hosting the module
def CheckIsModule(self): #if not it will be started
def CheckCMProcess(self):
HOST=self.HostIPAddress HOST=self.HostIPAddress
COMMAND="ps aux | grep " + self.Process + " | grep -v grep " COMMAND="ps aux | grep " + self.Process['Name'] + " | grep -v grep "
logging.debug(COMMAND) logging.debug(COMMAND)
ssh = subprocess.Popen(["ssh", "%s" % HOST, COMMAND],shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE) ssh = subprocess.Popen(["ssh", "%s" % HOST, COMMAND],shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
result = ssh.stdout.readlines() result = ssh.stdout.readlines()
if len(result)!=0: if len(result)!=0:
logging.debug(self.Process + " process found") logging.debug(self.Process['Name'] + " process found")
return True return True
else: else:#start process and check again
logging.debug(self.Process + " process NOT found") logging.debug(self.Process['Name'] + " process NOT found")
return False #starting the process
logging.debug('Starting ' + self.Process['Name'])
#Wakeup/Detach can probably be improved with encapsulation of the command such def Command(self, command)
#this method wakes up the module by calling the specified python script
def WakeUp(self):
mySSH = sshconnection.SSHConnection() mySSH = sshconnection.SSHConnection()
mySSH.open(self.HostIPAddress, self.HostUsername, self.HostPassword) mySSH.open(self.HostIPAddress, self.HostUsername, self.HostPassword)
mySSH.command('echo ' + self.HostPassword + ' | sudo -S python3 ' + self.WakeupScript + ' ','\$',5) mySSH.command('echo ' + self.HostPassword + ' | sudo -S ' + self.Process['Cmd'] + ' &','\$',5)
time.sleep(5)
logging.debug("Module wake-up")
mySSH.close() mySSH.close()
#checking the process
HOST=self.HostIPAddress
COMMAND="ps aux | grep " + self.Process['Name'] + " | grep -v grep "
logging.debug(COMMAND)
ssh = subprocess.Popen(["ssh", "%s" % HOST, COMMAND],shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
result = ssh.stdout.readlines()
if len(result)!=0:
logging.debug(self.Process['Name'] + " process found")
return True
else:
logging.debug(self.Process['Name'] + " process NOT found")
return False
#this method detaches the module by calling the specified python script #Generic command function, using function pointers dictionary
def Detach(self): def Command(self,cmd):
mySSH = sshconnection.SSHConnection() mySSH = sshconnection.SSHConnection()
mySSH.open(self.HostIPAddress, self.HostUsername, self.HostPassword) mySSH.open(self.HostIPAddress, self.HostUsername, self.HostPassword)
mySSH.command('echo ' + self.HostPassword + ' | sudo -S python3 ' + self.DetachScript + ' ','\$',5) mySSH.command('echo ' + self.HostPassword + ' | sudo -S python3 ' + self.cmd_dict[cmd],'\$',5)
time.sleep(5) time.sleep(5)
logging.debug("Module detach") logging.debug("Module "+ cmd)
mySSH.close() mySSH.close()
#this method retrieves the Module IP address (not the Host IP address) #this method retrieves the Module IP address (not the Host IP address)
def GetModuleIPAddress(self): def GetModuleIPAddress(self):
HOST=self.HostIPAddress HOST=self.HostIPAddress
response= []
tentative = 10
while (len(response)==0) and (tentative>0):
COMMAND="ip a show dev " + self.UENetwork + " | grep inet | grep " + self.UENetwork COMMAND="ip a show dev " + self.UENetwork + " | grep inet | grep " + self.UENetwork
logging.debug(COMMAND)
ssh = subprocess.Popen(["ssh", "%s" % HOST, COMMAND],shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE) ssh = subprocess.Popen(["ssh", "%s" % HOST, COMMAND],shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
response = ssh.stdout.readlines() response = ssh.stdout.readlines()
if len(response)!=0: tentative-=1
time.sleep(10)
if (tentative==0) and (len(response)==0):
logging.debug('\u001B[1;37;41m Module IP Address Not Found! Time expired \u001B[0m')
return -1
else: #check response
result = re.search('inet (?P<moduleipaddress>[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)', response[0].decode("utf-8") ) result = re.search('inet (?P<moduleipaddress>[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)', response[0].decode("utf-8") )
if result is not None: if result is not None:
if result.group('moduleipaddress') is not None: if result.group('moduleipaddress') is not None:
self.UEIPAddress = result.group('moduleipaddress') self.UEIPAddress = result.group('moduleipaddress')
logging.debug('\u001B[1mUE Module IP Address is ' + self.UEIPAddress + '\u001B[0m') logging.debug('\u001B[1mUE Module IP Address is ' + self.UEIPAddress + '\u001B[0m')
return 0
else: else:
logging.debug('\u001B[1;37;41m Module IP Address Not Found! \u001B[0m') logging.debug('\u001B[1;37;41m Module IP Address Not Found! \u001B[0m')
else: return -1
logging.debug('\u001B[1;37;41m Module IP Address Not Found! \u001B[0m')
else:
logging.debug('\u001B[1;37;41m Module IP Address Not Found! \u001B[0m')
......
...@@ -386,13 +386,13 @@ class OaiCiTest(): ...@@ -386,13 +386,13 @@ class OaiCiTest():
else: #if an ID is specified, it is a module from the yaml infrastructure file else: #if an ID is specified, it is a module from the yaml infrastructure file
#RH #RH
Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra[self.ue_id]) Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra[self.ue_id])
is_module=Module_UE.CheckIsModule() is_module=Module_UE.CheckCMProcess()
if is_module: if is_module:
Module_UE.WakeUp() Module_UE.Command("wup")
Module_UE.GetModuleIPAddress() Module_UE.GetModuleIPAddress()
HTML.CreateHtmlTestRow(Module_UE.UEIPAddress, 'OK', CONST.ALL_PROCESSES_OK) HTML.CreateHtmlTestRow(Module_UE.UEIPAddress, 'OK', CONST.ALL_PROCESSES_OK)
self.UEIPAddresses.append(Module_UE.UEIPAddress) self.UEIPAddresses.append(Module_UE.UEIPAddress)
logging.debug('UEs IP addresses : '+ self.UEIPAddresses) logging.debug('UE IP addresss : '+ Module_UE.UEIPAddress)
def InitializeOAIUE(self,HTML,RAN,EPC,COTS_UE): def InitializeOAIUE(self,HTML,RAN,EPC,COTS_UE):
if self.UEIPAddress == '' or self.UEUserName == '' or self.UEPassword == '' or self.UESourceCodePath == '': if self.UEIPAddress == '' or self.UEUserName == '' or self.UEPassword == '' or self.UESourceCodePath == '':
...@@ -1039,7 +1039,7 @@ class OaiCiTest(): ...@@ -1039,7 +1039,7 @@ class OaiCiTest():
except: except:
os.kill(os.getppid(),signal.SIGUSR1) os.kill(os.getppid(),signal.SIGUSR1)
def DetachUE(self,HTML,RAN,EPC,COTS_UE): def DetachUE(self,HTML,RAN,EPC,COTS_UE,InfraUE):
if self.ue_id=='':#no ID specified, then it is a COTS controlled by ADB if self.ue_id=='':#no ID specified, then it is a COTS controlled by ADB
if self.ADBIPAddress == '' or self.ADBUserName == '' or self.ADBPassword == '': if self.ADBIPAddress == '' or self.ADBUserName == '' or self.ADBPassword == '':
HELP.GenericHelp(CONST.Version) HELP.GenericHelp(CONST.Version)
...@@ -1073,9 +1073,9 @@ class OaiCiTest(): ...@@ -1073,9 +1073,9 @@ class OaiCiTest():
cnt += 1 cnt += 1
else:#if an ID is specified, it is a module from the yaml infrastructure file else:#if an ID is specified, it is a module from the yaml infrastructure file
Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra[self.ue_id]) Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra[self.ue_id])
is_module=Module_UE.CheckIsModule() is_module=Module_UE.CheckCMProcess()
if is_module: if is_module:
Module_UE.Detach() Module_UE.Command("detach")
Module_UE.GetModuleIPAddress() Module_UE.GetModuleIPAddress()
HTML.CreateHtmlTestRow(Module_UE.UEIPAddress, 'OK', CONST.ALL_PROCESSES_OK) HTML.CreateHtmlTestRow(Module_UE.UEIPAddress, 'OK', CONST.ALL_PROCESSES_OK)
......
...@@ -717,7 +717,7 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re ...@@ -717,7 +717,7 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re
elif action == 'Attach_UE': elif action == 'Attach_UE':
CiTestObj.AttachUE(HTML,RAN,EPC,COTS_UE) CiTestObj.AttachUE(HTML,RAN,EPC,COTS_UE)
elif action == 'Detach_UE': elif action == 'Detach_UE':
CiTestObj.DetachUE(HTML,RAN,EPC,COTS_UE) CiTestObj.DetachUE(HTML,RAN,EPC,COTS_UE,InfraUE)
elif action == 'DataDisable_UE': elif action == 'DataDisable_UE':
CiTestObj.DataDisableUE(HTML) CiTestObj.DataDisableUE(HTML)
elif action == 'DataEnable_UE': elif action == 'DataEnable_UE':
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
040000 040000
000001 000001
010000 010000
000001 000002
050000 050000
050001 050001
000001 000001
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
000001 000001
070001 070001
000001 000001
010002
000001
080001 080001
080000 080000
...@@ -70,7 +72,7 @@ ...@@ -70,7 +72,7 @@
<testCase id="040000"> <testCase id="040000">
<class>Initialize_eNB</class> <class>Initialize_eNB</class>
<desc>Initialize gNB</desc> <desc>Initialize gNB</desc>
<Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpb210.conf -E</Initialize_eNB_args> <Initialize_eNB_args>-O ci-scripts/conf_files/gnb.band78.tm1.fr1.106PRB.usrpn310.conf -q</Initialize_eNB_args>
<eNB_instance>1</eNB_instance> <eNB_instance>1</eNB_instance>
<eNB_serverId>1</eNB_serverId> <eNB_serverId>1</eNB_serverId>
<air_interface>nr</air_interface> <air_interface>nr</air_interface>
...@@ -79,9 +81,16 @@ ...@@ -79,9 +81,16 @@
<testCase id="000001"> <testCase id="000001">
<class>IdleSleep</class> <class>IdleSleep</class>
<desc>Sleep</desc> <desc>Sleep</desc>
<idle_sleep_time_in_sec>10</idle_sleep_time_in_sec> <idle_sleep_time_in_sec>5</idle_sleep_time_in_sec>
</testCase> </testCase>
<testCase id="000002">
<class>IdleSleep</class>
<desc>Sleep</desc>
<idle_sleep_time_in_sec>30</idle_sleep_time_in_sec>
</testCase>
<testCase id="050000"> <testCase id="050000">
<class>Ping</class> <class>Ping</class>
<desc>Ping: 20pings in 20sec</desc> <desc>Ping: 20pings in 20sec</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