Commit df209625 authored by Robert Schmidt's avatar Robert Schmidt

Improve cls_oaicitest.py to use cls_module_up.py

- Remove cls_ci_ueinfra
- Use new UE module in cls_oaicitest
- Remove useless code
parent 41e81915
# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
# * contributor license agreements. See the NOTICE file distributed with
# * this work for additional information regarding copyright ownership.
# * The OpenAirInterface Software Alliance licenses this file to You under
# * the OAI Public License, Version 1.1 (the "License"); you may not use this file
# * except in compliance with the License.
# * You may obtain a copy of the License at
# *
# * http://www.openairinterface.org/?page_id=698
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# *-------------------------------------------------------------------------------
# * For more information about the OpenAirInterface (OAI) Software Alliance:
# * contact@openairinterface.org
# */
#---------------------------------------------------------------------
#
# Required Python Version
# Python 3.x
#
#---------------------------------------------------------------------
#to use isfile
import os
import sys
import logging
#to create a SSH object locally in the methods
import sshconnection
#time.sleep
import time
#to load ue infrastructure dictionary
import yaml
class InfraUE:
def __init__(self):
self.ci_ue_infra ={}
#-----------------$
#PUBLIC Methods$
#-----------------$
#This method reads the yaml file describing the multi-UE infrastructure
#and stores the infra permanently in the related class attribute self.ci_ue_infra
def Get_UE_Infra(self,ue_infra_filename):
f_yaml=ue_infra_filename
with open(f_yaml,'r') as file:
logging.debug('Loading UE infrastructure from file '+f_yaml)
#load it permanently in the class attribute
self.ci_ue_infra = yaml.load(file,Loader=yaml.FullLoader)
...@@ -51,7 +51,6 @@ import constants as CONST ...@@ -51,7 +51,6 @@ import constants as CONST
import sshconnection import sshconnection
import cls_module_ue import cls_module_ue
import cls_ci_ueinfra #class defining the multi Ue infrastrucure
logging.getLogger("matplotlib").setLevel(logging.WARNING) logging.getLogger("matplotlib").setLevel(logging.WARNING)
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
...@@ -170,7 +169,6 @@ class OaiCiTest(): ...@@ -170,7 +169,6 @@ class OaiCiTest():
self.UEDevicesOffCmd = [] self.UEDevicesOffCmd = []
self.UEDevicesOnCmd = [] self.UEDevicesOnCmd = []
self.UEDevicesRebootCmd = [] self.UEDevicesRebootCmd = []
self.UEIPAddresses = []
self.idle_sleep_time = 0 self.idle_sleep_time = 0
self.x2_ho_options = 'network' self.x2_ho_options = 'network'
self.x2NbENBs = 0 self.x2NbENBs = 0
...@@ -188,9 +186,7 @@ class OaiCiTest(): ...@@ -188,9 +186,7 @@ class OaiCiTest():
self.Initialize_OAI_UE_args = '' self.Initialize_OAI_UE_args = ''
self.clean_repository = True self.clean_repository = True
self.air_interface='' self.air_interface=''
self.expectedNbOfConnectedUEs = 0
self.ue_id = '' #used for module identification self.ue_id = '' #used for module identification
self.ue_trace ='' #used to enable QLog trace for Module UE, passed to Module UE object at InitializeUE()
self.cmd_prefix = '' # prefix before {lte,nr}-uesoftmodem self.cmd_prefix = '' # prefix before {lte,nr}-uesoftmodem
...@@ -298,139 +294,12 @@ class OaiCiTest(): ...@@ -298,139 +294,12 @@ class OaiCiTest():
HTML.CreateHtmlTabFooter(False) HTML.CreateHtmlTabFooter(False)
self.ConditionalExit() self.ConditionalExit()
def InitializeUE_common(self, device_id, idx,COTS_UE):
try:
SSH = sshconnection.SSHConnection()
SSH.open(self.ADBIPAddress, self.ADBUserName, self.ADBPassword)
if not self.ADBCentralized:
# Reboot UE
#SSH.command('ssh ' + self.UEDevicesRemoteUser[idx] + '@' + self.UEDevicesRemoteServer[idx] + ' ' + self.UEDevicesRebootCmd[idx], '\$', 60)
# Wait
#time.sleep(60)
# Put in LTE-Mode only
#SSH.command('ssh ' + self.UEDevicesRemoteUser[idx] + '@' + self.UEDevicesRemoteServer[idx] + ' \'adb -s ' + device_id + ' shell "settings put global preferred_network_mode 11"\'', '\$', 60)
#SSH.command('ssh ' + self.UEDevicesRemoteUser[idx] + '@' + self.UEDevicesRemoteServer[idx] + ' \'adb -s ' + device_id + ' shell "settings put global preferred_network_mode1 11"\'', '\$', 60)
#SSH.command('ssh ' + self.UEDevicesRemoteUser[idx] + '@' + self.UEDevicesRemoteServer[idx] + ' \'adb -s ' + device_id + ' shell "settings put global preferred_network_mode2 11"\'', '\$', 60)
#SSH.command('ssh ' + self.UEDevicesRemoteUser[idx] + '@' + self.UEDevicesRemoteServer[idx] + ' \'adb -s ' + device_id + ' shell "settings put global preferred_network_mode3 11"\'', '\$', 60)
# enable data service
#SSH.command('ssh ' + self.UEDevicesRemoteUser[idx] + '@' + self.UEDevicesRemoteServer[idx] + ' \'adb -s ' + device_id + ' shell "svc data enable"\'', '\$', 60)
# we need to do radio on/off cycle to make sure of above changes
# airplane mode off // radio on
#SSH.command('ssh ' + self.UEDevicesRemoteUser[idx] + '@' + self.UEDevicesRemoteServer[idx] + ' ' + self.UEDevicesOnCmd[idx], '\$', 60)
#time.sleep(10)
# airplane mode on // radio off
#SSH.command('ssh ' + self.UEDevicesRemoteUser[idx] + '@' + self.UEDevicesRemoteServer[idx] + ' ' + self.UEDevicesOffCmd[idx], '\$', 60)
# normal procedure without reboot
# enable data service
SSH.command('ssh ' + self.UEDevicesRemoteUser[idx] + '@' + self.UEDevicesRemoteServer[idx] + ' \'adb -s ' + device_id + ' shell "svc data enable"\'', '\$', 60)
# airplane mode on // radio off
SSH.command('ssh ' + self.UEDevicesRemoteUser[idx] + '@' + self.UEDevicesRemoteServer[idx] + ' ' + self.UEDevicesOffCmd[idx], '\$', 60)
SSH.close()
return
#RH quick add-on to integrate cots control defined by yaml def InitializeUE(self,HTML,RAN,EPC, COTS_UE, CONTAINERS):
#if device_id exists in yaml dictionary, we execute the new procedure defined in cots_ue class ue = cls_module_ue.Module_UE(self.ue_id)
#otherwise we use the legacy procedure ue.initialize()
logging.debug('Device id ' + str(device_id) + ', in COTS UE dict : ' + str(COTS_UE.Check_Exists(device_id)))
if COTS_UE.Check_Exists(device_id):
#switch device to Airplane mode ON (ie Radio OFF)
COTS_UE.Set_Airplane(device_id, 'ON')
else:
# enable data service
SSH.command('stdbuf -o0 adb -s ' + device_id + ' shell "svc data enable"', '\$', 60)
# The following commands are deprecated since we no longer work on Android 7+
# SSH.command('stdbuf -o0 adb -s ' + device_id + ' shell settings put global airplane_mode_on 1', '\$', 10)
# SSH.command('stdbuf -o0 adb -s ' + device_id + ' shell am broadcast -a android.intent.action.AIRPLANE_MODE --ez state true', '\$', 60)
# a dedicated script has to be installed inside the UE
# airplane mode on means call /data/local/tmp/off
if device_id == '84B7N16418004022':
SSH.command('stdbuf -o0 adb -s ' + device_id + ' shell "su - root -c /data/local/tmp/off"', '\$', 60)
else:
SSH.command('stdbuf -o0 adb -s ' + device_id + ' shell /data/local/tmp/off', '\$', 60)
#airplane mode off means call /data/local/tmp/on
logging.debug('\u001B[1mUE (' + device_id + ') Initialize Completed\u001B[0m')
SSH.close()
except:
os.kill(os.getppid(),signal.SIGUSR1)
def InitializeUE(self,HTML,RAN,EPC, COTS_UE, InfraUE,ue_trace,CONTAINERS): def InitializeOAIUE(self,HTML,RAN,EPC,COTS_UE,CONTAINERS):
if self.ue_id=='':#no ID specified, then it is a COTS controlled by ADB
if self.ADBIPAddress == '' or self.ADBUserName == '' or self.ADBPassword == '':
HELP.GenericHelp(CONST.Version)
sys.exit('Insufficient Parameter')
multi_jobs = []
i = 0
for device_id in self.UEDevices:
p = Process(target = self.InitializeUE_common, args = (device_id,i,COTS_UE,))
p.daemon = True
p.start()
multi_jobs.append(p)
i += 1
for job in multi_jobs:
job.join()
HTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK)
else: #if an ID is specified, it is a UE from the yaml infrastructure file
ue_kind = InfraUE.ci_ue_infra[self.ue_id]['Kind']
logging.debug("Detected UE Kind : " + ue_kind)
#case it is a quectel module (only 1 at a time supported at the moment)
if ue_kind == 'quectel':
Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra[self.ue_id])
Module_UE.ue_trace=ue_trace
is_module=Module_UE.CheckCMProcess(EPC.Type)
if is_module:
Module_UE.EnableTrace()
time.sleep(5)
# Looping attach / detach / wait to be successful at least once
cnt = 0
status = -1
while cnt < 4:
Module_UE.Command("wup")
logging.debug("Waiting for IP address to be assigned")
time.sleep(5)
logging.debug("Retrieve IP address")
status=Module_UE.GetModuleIPAddress()
if status==0:
cnt = 10
else:
cnt += 1
Module_UE.Command("detach")
time.sleep(20)
if cnt == 10 and status == 0:
HTML.CreateHtmlTestRow(Module_UE.UEIPAddress, 'OK', CONST.ALL_PROCESSES_OK)
logging.debug('UE IP addresss : '+ Module_UE.UEIPAddress)
#execute additional commands from yaml file after UE attach
SSH = sshconnection.SSHConnection()
SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword)
if hasattr(Module_UE,'StartCommands'):
for startcommand in Module_UE.StartCommands:
cmd = 'echo ' + Module_UE.HostPassword + ' | ' + startcommand
SSH.command(cmd,'\$',5)
SSH.close()
#check that the MTU is as expected / requested
Module_UE.CheckModuleMTU()
else: #status==-1 failed to retrieve IP address
HTML.CreateHtmlTestRow('N/A', 'KO', CONST.UE_IP_ADDRESS_ISSUE)
self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS)
return
#case it is a amarisoft ue (only 1 at a time supported at the moment)
elif ue_kind == 'amarisoft':
AS_UE = cls_amarisoft_ue.AS_UE(InfraUE.ci_ue_infra[self.ue_id])
HTML.CreateHtmlTestRow(AS_UE.Config, 'OK', CONST.ALL_PROCESSES_OK)
AS_UE.RunScenario()
AS_UE.WaitEndScenario()
AS_UE.KillASUE()
else:
logging.debug("Incorrect UE Kind was detected")
def InitializeOAIUE(self,HTML,RAN,EPC,COTS_UE,InfraUE,CONTAINERS):
if self.UEIPAddress == '' or self.UEUserName == '' or self.UEPassword == '' or self.UESourceCodePath == '': if self.UEIPAddress == '' or self.UEUserName == '' or self.UEPassword == '' or self.UESourceCodePath == '':
HELP.GenericHelp(CONST.Version) HELP.GenericHelp(CONST.Version)
sys.exit('Insufficient Parameter') sys.exit('Insufficient Parameter')
...@@ -643,249 +512,21 @@ class OaiCiTest(): ...@@ -643,249 +512,21 @@ class OaiCiTest():
HTML.htmlUEFailureMsg='nr-uesoftmodem did NOT synced' HTML.htmlUEFailureMsg='nr-uesoftmodem did NOT synced'
HTML.CreateHtmlTestRow(self.air_interface + ' ' + self.Initialize_OAI_UE_args, 'KO', CONST.OAI_UE_PROCESS_COULD_NOT_SYNC, 'OAI UE') HTML.CreateHtmlTestRow(self.air_interface + ' ' + self.Initialize_OAI_UE_args, 'KO', CONST.OAI_UE_PROCESS_COULD_NOT_SYNC, 'OAI UE')
logging.error('\033[91mInitialize OAI UE Failed! \033[0m') logging.error('\033[91mInitialize OAI UE Failed! \033[0m')
self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS) self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,CONTAINERS)
def AttachUE_common(self, device_id, statusQueue, lock, idx,COTS_UE):
try:
SSH = sshconnection.SSHConnection()
SSH.open(self.ADBIPAddress, self.ADBUserName, self.ADBPassword)
if self.ADBCentralized:
#RH quick add on to integrate cots control defined by yaml
#if device Id exists in yaml dictionary, we execute the new procedure defined in cots_ue class
#otherwise we use the legacy procedure
if COTS_UE.Check_Exists(device_id):
#switch device to Airplane mode OFF (ie Radio ON)
COTS_UE.Set_Airplane(device_id, 'OFF')
elif device_id == '84B7N16418004022':
SSH.command('stdbuf -o0 adb -s ' + device_id + ' shell "su - root -c /data/local/tmp/on"', '\$', 60)
else:
SSH.command('stdbuf -o0 adb -s ' + device_id + ' shell /data/local/tmp/on', '\$', 60)
else:
# airplane mode off // radio on
SSH.command('ssh ' + self.UEDevicesRemoteUser[idx] + '@' + self.UEDevicesRemoteServer[idx] + ' ' + self.UEDevicesOnCmd[idx], '\$', 60)
time.sleep(2)
max_count = 45
count = max_count
while count > 0:
if self.ADBCentralized:
SSH.command('stdbuf -o0 adb -s ' + device_id + ' shell "dumpsys telephony.registry" | grep -m 1 mDataConnectionState', '\$', 15)
else:
SSH.command('ssh ' + self.UEDevicesRemoteUser[idx] + '@' + self.UEDevicesRemoteServer[idx] + ' \'adb -s ' + device_id + ' shell "dumpsys telephony.registry"\' | grep -m 1 mDataConnectionState', '\$', 60)
result = re.search('mDataConnectionState.*=(?P<state>[0-9\-]+)', SSH.getBefore())
if result is None:
logging.debug('\u001B[1;37;41m mDataConnectionState Not Found! \u001B[0m')
lock.acquire()
statusQueue.put(-1)
statusQueue.put(device_id)
statusQueue.put('mDataConnectionState Not Found!')
lock.release()
break
mDataConnectionState = int(result.group('state'))
if mDataConnectionState == 2:
logging.debug('\u001B[1mUE (' + device_id + ') Attach Completed\u001B[0m')
lock.acquire()
statusQueue.put(max_count - count)
statusQueue.put(device_id)
statusQueue.put('Attach Completed')
lock.release()
break
count = count - 1
if count == 15 or count == 30:
logging.debug('\u001B[1;30;43m Retry UE (' + device_id + ') Flight Mode Off \u001B[0m')
if self.ADBCentralized:
#RH quick add on to intgrate cots control defined by yaml
#if device id exists in yaml dictionary, we execute the new procedure defined in cots_ue class
#otherwise we use the legacy procedure
if COTS_UE.Check_Exists(device_id):
#switch device to Airplane mode ON (ie Radio OFF)
COTS_UE.Set_Airplane(device_id, 'ON')
elif device_id == '84B7N16418004022':
SSH.command('stdbuf -o0 adb -s ' + device_id + ' shell "su - root -c /data/local/tmp/off"', '\$', 60)
else:
SSH.command('stdbuf -o0 adb -s ' + device_id + ' shell /data/local/tmp/off', '\$', 60)
else:
SSH.command('ssh ' + self.UEDevicesRemoteUser[idx] + '@' + self.UEDevicesRemoteServer[idx] + ' ' + self.UEDevicesOffCmd[idx], '\$', 60)
time.sleep(0.5)
if self.ADBCentralized:
#RH quick add on to integrate cots control defined by yaml
#if device id exists in yaml dictionary, we execute the new procedre defined incots_ue class
#otherwise we use the legacy procedure
if COTS_UE.Check_Exists(device_id):
#switch device to Airplane mode OFF (ie Radio ON)
COTS_UE.Set_Airplane(device_id, 'OFF')
elif device_id == '84B7N16418004022':
SSH.command('stdbuf -o0 adb -s ' + device_id + ' shell "su - root -c /data/local/tmp/on"', '\$', 60)
else:
SSH.command('stdbuf -o0 adb -s ' + device_id + ' shell /data/local/tmp/on', '\$', 60)
else:
SSH.command('ssh ' + self.UEDevicesRemoteUser[idx] + '@' + self.UEDevicesRemoteServer[idx] + ' ' + self.UEDevicesOnCmd[idx], '\$', 60)
time.sleep(0.5)
logging.debug('\u001B[1mWait UE (' + device_id + ') a second until mDataConnectionState=2 (' + str(max_count-count) + ' times)\u001B[0m')
time.sleep(1)
if count == 0:
logging.debug('\u001B[1;37;41m UE (' + device_id + ') Attach Failed \u001B[0m')
lock.acquire()
statusQueue.put(-1)
statusQueue.put(device_id)
statusQueue.put('Attach Failed')
lock.release()
SSH.close()
except:
os.kill(os.getppid(),signal.SIGUSR1)
def AttachUE(self,HTML,RAN,EPC,COTS_UE,InfraUE,CONTAINERS): def AttachUE(self,HTML,RAN,EPC,COTS_UE,CONTAINERS):
if self.ue_id=='':#no ID specified, then it is a COTS controlled by ADB ue = cls_module_ue.Module_UE(self.ue_id)
if self.ADBIPAddress == '' or self.ADBUserName == '' or self.ADBPassword == '': connected = ue.attach()
HELP.GenericHelp(CONST.Version) if connected:
sys.exit('Insufficient Parameter') HTML.CreateHtmlTestRow(f"{ue.getIP()}", 'OK', CONST.ALL_PROCESSES_OK)
check_eNB = True ue.checkMTU()
check_OAI_UE = False
pStatus = self.CheckProcessExist(check_eNB, check_OAI_UE,RAN,EPC)
if (pStatus < 0):
HTML.CreateHtmlTestRow('N/A', 'KO', pStatus)
self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS)
return
multi_jobs = []
status_queue = SimpleQueue()
lock = Lock()
nb_ue_to_connect = 0
for device_id in self.UEDevices:
if (self.nbMaxUEtoAttach == -1) or (nb_ue_to_connect < self.nbMaxUEtoAttach):
self.UEDevicesStatus[nb_ue_to_connect] = CONST.UE_STATUS_ATTACHING
p = Process(target = self.AttachUE_common, args = (device_id, status_queue, lock,nb_ue_to_connect,COTS_UE,))
p.daemon = True
p.start()
multi_jobs.append(p)
nb_ue_to_connect = nb_ue_to_connect + 1
for job in multi_jobs:
job.join()
if (status_queue.empty()):
HTML.CreateHtmlTestRow('N/A', 'KO', CONST.ALL_PROCESSES_OK)
self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS)
return
else: else:
attach_status = True
message = ''
while (not status_queue.empty()):
count = status_queue.get()
if (count < 0):
attach_status = False
device_id = status_queue.get()
message = status_queue.get()
if (count < 0):
message = 'UE (' + device_id + ')\n' + message
else:
message = 'UE (' + device_id + ')\n' + message + ' in ' + str(count + 2) + ' seconds'
if (attach_status):
cnt = 0
while cnt < len(self.UEDevices):
if self.UEDevicesStatus[cnt] == CONST.UE_STATUS_ATTACHING:
self.UEDevicesStatus[cnt] = CONST.UE_STATUS_ATTACHED
cnt += 1
HTML.CreateHtmlTestRowQueue('N/A', 'OK', [message])
result = re.search('T_stdout', str(RAN.Initialize_eNB_args))
if result is not None:
logging.debug('Waiting 5 seconds to fill up record file')
time.sleep(5)
else:
HTML.CreateHtmlTestRowQueue('N/A', 'KO', [message])
self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS)
else: #if an ID is specified, it is a module from the yaml infrastructure file
#Attention, as opposed to InitializeUE, the connect manager process is not checked as it is supposed to be active already
#only 1- module wakeup, 2- check IP address
Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra[self.ue_id])
status = -1
cnt = 0
while cnt < 4:
Module_UE.Command("wup")
logging.debug("Waiting for IP address to be assigned")
time.sleep(5)
logging.debug("Retrieve IP address")
status=Module_UE.GetModuleIPAddress()
if status==0:
cnt = 10
else:
cnt += 1
Module_UE.Command("detach")
time.sleep(20)
if cnt == 10 and status == 0:
HTML.CreateHtmlTestRow(Module_UE.UEIPAddress, 'OK', CONST.ALL_PROCESSES_OK)
logging.debug('UE IP addresss : '+ Module_UE.UEIPAddress)
#execute additional commands from yaml file after UE attach
SSH = sshconnection.SSHConnection()
SSH.open(Module_UE.HostIPAddress, Module_UE.HostUsername, Module_UE.HostPassword)
if hasattr(Module_UE,'StartCommands'):
for startcommand in Module_UE.StartCommands:
cmd = 'echo ' + Module_UE.HostPassword + ' | ' + startcommand
SSH.command(cmd,'\$',5)
SSH.close()
#check that the MTU is as expected / requested
Module_UE.CheckModuleMTU()
else: #status==-1 failed to retrieve IP address
HTML.CreateHtmlTestRow('N/A', 'KO', CONST.UE_IP_ADDRESS_ISSUE) HTML.CreateHtmlTestRow('N/A', 'KO', CONST.UE_IP_ADDRESS_ISSUE)
self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS) self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,CONTAINERS)
return
def DetachUE_common(self, device_id, idx,COTS_UE):
try:
SSH = sshconnection.SSHConnection()
SSH.open(self.ADBIPAddress, self.ADBUserName, self.ADBPassword)
if self.ADBCentralized:
#RH quick add on to integrate cots control defined by yaml
#if device id exists in yaml dictionary, we execute the new procedure defined in cots_ue class
#otherwise we use the legacy procedure
if COTS_UE.Check_Exists(device_id):
#switch device to Airplane mode ON (ie Radio OFF)
COTS_UE.Set_Airplane(device_id,'ON')
elif device_id == '84B7N16418004022':
SSH.command('stdbuf -o0 adb -s ' + device_id + ' shell "su - root -c /data/local/tmp/off"', '\$', 60)
else:
SSH.command('stdbuf -o0 adb -s ' + device_id + ' shell /data/local/tmp/off', '\$', 60)
else:
SSH.command('ssh ' + self.UEDevicesRemoteUser[idx] + '@' + self.UEDevicesRemoteServer[idx] + ' ' + self.UEDevicesOffCmd[idx], '\$', 60)
logging.debug('\u001B[1mUE (' + device_id + ') Detach Completed\u001B[0m')
SSH.close()
except:
os.kill(os.getppid(),signal.SIGUSR1)
def DetachUE(self,HTML,RAN,EPC,COTS_UE,InfraUE,CONTAINERS): def DetachUE(self,HTML,RAN,EPC,COTS_UE,CONTAINERS):
if self.ue_id=='':#no ID specified, then it is a COTS controlled by ADB ue = cls_module_ue.Module_UE(self.ue_id)
if self.ADBIPAddress == '' or self.ADBUserName == '' or self.ADBPassword == '': ue.detach()
HELP.GenericHelp(CONST.Version)
sys.exit('Insufficient Parameter')
check_eNB = True
check_OAI_UE = False
pStatus = self.CheckProcessExist(check_eNB, check_OAI_UE,RAN,EPC)
if (pStatus < 0):
HTML.CreateHtmlTestRow('N/A', 'KO', pStatus)
self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS)
return
multi_jobs = []
cnt = 0
for device_id in self.UEDevices:
self.UEDevicesStatus[cnt] = CONST.UE_STATUS_DETACHING
p = Process(target = self.DetachUE_common, args = (device_id,cnt,COTS_UE,))
p.daemon = True
p.start()
multi_jobs.append(p)
cnt += 1
for job in multi_jobs:
job.join()
HTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK)
result = re.search('T_stdout', str(RAN.Initialize_eNB_args))
if result is not None:
logging.debug('Waiting 5 seconds to fill up record file')
time.sleep(5)
cnt = 0
while cnt < len(self.UEDevices):
self.UEDevicesStatus[cnt] = CONST.UE_STATUS_DETACHED
cnt += 1
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.Command("detach")
HTML.CreateHtmlTestRow('NA', 'OK', CONST.ALL_PROCESSES_OK) HTML.CreateHtmlTestRow('NA', 'OK', CONST.ALL_PROCESSES_OK)
...@@ -1112,7 +753,7 @@ class OaiCiTest(): ...@@ -1112,7 +753,7 @@ class OaiCiTest():
except: except:
os.kill(os.getppid(),signal.SIGUSR1) os.kill(os.getppid(),signal.SIGUSR1)
def CheckStatusUE(self,HTML,RAN,EPC,COTS_UE,InfraUE,CONTAINERS): def CheckStatusUE(self,HTML,RAN,EPC,COTS_UE,CONTAINERS):
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)
sys.exit('Insufficient Parameter') sys.exit('Insufficient Parameter')
...@@ -1140,7 +781,7 @@ class OaiCiTest(): ...@@ -1140,7 +781,7 @@ class OaiCiTest():
if (status_queue.empty()): if (status_queue.empty()):
HTML.CreateHtmlTestRow(htmlOptions, 'KO', CONST.ALL_PROCESSES_OK) HTML.CreateHtmlTestRow(htmlOptions, 'KO', CONST.ALL_PROCESSES_OK)
self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS) self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,CONTAINERS)
else: else:
check_status = True check_status = True
messages = [] messages = []
...@@ -1154,68 +795,7 @@ class OaiCiTest(): ...@@ -1154,68 +795,7 @@ class OaiCiTest():
HTML.CreateHtmlTestRowQueue(htmlOptions, 'OK', messages) HTML.CreateHtmlTestRowQueue(htmlOptions, 'OK', messages)
else: else:
HTML.CreateHtmlTestRowQueue(htmlOptions, 'KO', messages) HTML.CreateHtmlTestRowQueue(htmlOptions, 'KO', messages)
self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS) self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,CONTAINERS)
def GetAllUEIPAddresses(self):
SSH = sshconnection.SSHConnection()
if self.ADBIPAddress == '' or self.ADBUserName == '' or self.ADBPassword == '':
HELP.GenericHelp(CONST.Version)
sys.exit('Insufficient Parameter')
ue_ip_status = 0
self.UEIPAddresses = []
if (len(self.UEDevices) == 1) and (self.UEDevices[0] == 'OAI-UE'):
if self.UEIPAddress == '' or self.UEUserName == '' or self.UEPassword == '' or self.UESourceCodePath == '':
HELP.GenericHelp(CONST.Version)
sys.exit('Insufficient Parameter')
SSH.open(self.UEIPAddress, self.UEUserName, self.UEPassword)
SSH.command('ifconfig oaitun_ue1', '\$', 4)
result = re.search('inet addr:(?P<ueipaddress>[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)|inet (?P<ueipaddress2>[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)', SSH.getBefore())
if result is not None:
if result.group('ueipaddress') is not None:
UE_IPAddress = result.group('ueipaddress')
else:
UE_IPAddress = result.group('ueipaddress2')
logging.debug('\u001B[1mUE (' + self.UEDevices[0] + ') IP Address is ' + UE_IPAddress + '\u001B[0m')
self.UEIPAddresses.append(UE_IPAddress)
else:
logging.debug('\u001B[1;37;41m UE IP Address Not Found! \u001B[0m')
ue_ip_status -= 1
SSH.close()
return ue_ip_status
SSH.open(self.ADBIPAddress, self.ADBUserName, self.ADBPassword)
idx = 0
for device_id in self.UEDevices:
if self.UEDevicesStatus[idx] != CONST.UE_STATUS_ATTACHED:
idx += 1
continue
count = 0
while count < 4:
if self.ADBCentralized:
SSH.command('stdbuf -o0 adb -s ' + device_id + ' shell "ip addr show | grep rmnet"', '\$', 15)
else:
SSH.command('ssh ' + self.UEDevicesRemoteUser[idx] + '@' + self.UEDevicesRemoteServer[idx] + ' \'adb -s ' + device_id + ' shell "ip addr show | grep rmnet"\'', '\$', 60)
result = re.search('inet (?P<ueipaddress>[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\/[0-9]+[0-9a-zA-Z\.\s]+', SSH.getBefore())
if result is None:
logging.debug('\u001B[1;37;41m UE IP Address Not Found! \u001B[0m')
time.sleep(1)
count += 1
else:
count = 10
if count < 9:
ue_ip_status -= 1
continue
UE_IPAddress = result.group('ueipaddress')
logging.debug('\u001B[1mUE (' + device_id + ') IP Address is ' + UE_IPAddress + '\u001B[0m')
for ueipaddress in self.UEIPAddresses:
if ueipaddress == UE_IPAddress:
logging.debug('\u001B[1mUE (' + device_id + ') IP Address ' + UE_IPAddress + ': has already been allocated to another device !' + '\u001B[0m')
ue_ip_status -= 1
continue
self.UEIPAddresses.append(UE_IPAddress)
idx += 1
SSH.close()
return ue_ip_status
def ping_iperf_wrong_exit(self, lock, UE_IPAddress, device_id, statusQueue, message): def ping_iperf_wrong_exit(self, lock, UE_IPAddress, device_id, statusQueue, message):
lock.acquire() lock.acquire()
...@@ -1420,14 +1000,14 @@ class OaiCiTest(): ...@@ -1420,14 +1000,14 @@ class OaiCiTest():
message = 'OAI UE ping result\n{qMsg}' message = 'OAI UE ping result\n{qMsg}'
HTML.CreateHtmlTestRowQueue(self.ping_args, 'KO', [message]) HTML.CreateHtmlTestRowQueue(self.ping_args, 'KO', [message])
def PingNoS1(self,HTML,RAN,EPC,COTS_UE,InfraUE,CONTAINERS): def PingNoS1(self,HTML,RAN,EPC,COTS_UE,CONTAINERS):
SSH=sshconnection.SSHConnection() SSH=sshconnection.SSHConnection()
check_eNB = True check_eNB = True
check_OAI_UE = True check_OAI_UE = True
pStatus = self.CheckProcessExist(check_eNB, check_OAI_UE,RAN,EPC) pStatus = self.CheckProcessExist(check_eNB, check_OAI_UE,RAN,EPC)
if (pStatus < 0): if (pStatus < 0):
HTML.CreateHtmlTestRow(self.ping_args, 'KO', pStatus) HTML.CreateHtmlTestRow(self.ping_args, 'KO', pStatus)
self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS) self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,CONTAINERS)
return return
ping_from_eNB = re.search('oaitun_enb1', str(self.ping_args)) ping_from_eNB = re.search('oaitun_enb1', str(self.ping_args))
if ping_from_eNB is not None: if ping_from_eNB is not None:
...@@ -1510,10 +1090,10 @@ class OaiCiTest(): ...@@ -1510,10 +1090,10 @@ class OaiCiTest():
except: except:
os.kill(os.getppid(),signal.SIGUSR1) os.kill(os.getppid(),signal.SIGUSR1)
def Ping(self,HTML,RAN,EPC,COTS_UE, InfraUE, CONTAINERS): def Ping(self,HTML,RAN,EPC,COTS_UE, CONTAINERS):
result = re.search('noS1', str(RAN.Initialize_eNB_args)) result = re.search('noS1', str(RAN.Initialize_eNB_args))
if result is not None: if result is not None:
self.PingNoS1(HTML,RAN,EPC,COTS_UE,InfraUE,CONTAINERS) self.PingNoS1(HTML,RAN,EPC,COTS_UE,CONTAINERS)
return return
if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.SourceCodePath == '': if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.SourceCodePath == '':
HELP.GenericHelp(CONST.Version) HELP.GenericHelp(CONST.Version)
...@@ -1526,30 +1106,22 @@ class OaiCiTest(): ...@@ -1526,30 +1106,22 @@ class OaiCiTest():
pStatus = self.CheckProcessExist(check_eNB, check_OAI_UE,RAN,EPC) pStatus = self.CheckProcessExist(check_eNB, check_OAI_UE,RAN,EPC)
if (pStatus < 0): if (pStatus < 0):
HTML.CreateHtmlTestRow(self.ping_args, 'KO', pStatus) HTML.CreateHtmlTestRow(self.ping_args, 'KO', pStatus)
self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS) self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,CONTAINERS)
return return
if self.ue_id=="": if self.ue_id == "":
Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra['dummy']) #RH, temporary, we need a dummy Module_UE object to pass to Ping_common logging.error("no module ID!!!")
ueIpStatus = self.GetAllUEIPAddresses() exit(1)
if (ueIpStatus < 0):
HTML.CreateHtmlTestRow(self.ping_args, 'KO', CONST.UE_IP_ADDRESS_ISSUE)
self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS)
return
else: #if an ID is specified, it is a UE from the yaml infrastructure file
ue_kind = InfraUE.ci_ue_infra[self.ue_id]['Kind']
logging.debug("Detected UE Kind : " + ue_kind)
if ue_kind == 'quectel': self.UEIPAddresses = []
self.UEIPAddresses=[] ue = cls_module_ue.Module_UE(self.ue_id)
Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra[self.ue_id]) ip = ue.getIP()
Module_UE.GetModuleIPAddress() if ip is None:
self.UEIPAddresses.append(Module_UE.UEIPAddress) logging.error("no IP addresses returned")
elif ue_kind == 'amarisoft': html_queue = SimpleQueue()
self.UEIPAddresses=['AS UE IP'] HTML.CreateHtmlTestRowQueue(self.ping_args, 'KO', len(self.UEDevices), html_queue)
Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra[self.ue_id]) self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,CONTAINERS)
else: self.UEIPAddresses.append(ip)
logging.debug("Incorrect UE Kind was detected")
logging.debug(self.UEIPAddresses) logging.debug(self.UEIPAddresses)
multi_jobs = [] multi_jobs = []
...@@ -1572,7 +1144,7 @@ class OaiCiTest(): ...@@ -1572,7 +1144,7 @@ class OaiCiTest():
if (status_queue.empty()): if (status_queue.empty()):
HTML.CreateHtmlTestRow(self.ping_args, 'KO', CONST.ALL_PROCESSES_OK) HTML.CreateHtmlTestRow(self.ping_args, 'KO', CONST.ALL_PROCESSES_OK)
self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS) self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,CONTAINERS)
else: else:
ping_status = True ping_status = True
messages = [] messages = []
...@@ -1588,7 +1160,7 @@ class OaiCiTest(): ...@@ -1588,7 +1160,7 @@ class OaiCiTest():
HTML.CreateHtmlTestRowQueue(self.ping_args, 'OK', messages) HTML.CreateHtmlTestRowQueue(self.ping_args, 'OK', messages)
else: else:
HTML.CreateHtmlTestRowQueue(self.ping_args, 'KO', messages) HTML.CreateHtmlTestRowQueue(self.ping_args, 'KO', messages)
self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS) self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,CONTAINERS)
def Iperf_ComputeTime(self): def Iperf_ComputeTime(self):
result = re.search('-t (?P<iperf_time>\d+)', str(self.iperf_args)) result = re.search('-t (?P<iperf_time>\d+)', str(self.iperf_args))
...@@ -2535,7 +2107,7 @@ class OaiCiTest(): ...@@ -2535,7 +2107,7 @@ class OaiCiTest():
except: except:
os.kill(os.getppid(),signal.SIGUSR1) os.kill(os.getppid(),signal.SIGUSR1)
def IperfNoS1(self,HTML,RAN,EPC,COTS_UE,InfraUE,CONTAINERS): def IperfNoS1(self,HTML,RAN,EPC,COTS_UE,CONTAINERS):
SSH = sshconnection.SSHConnection() SSH = sshconnection.SSHConnection()
if RAN.eNBIPAddress == '' or RAN.eNBUserName == '' or RAN.eNBPassword == '' or self.UEIPAddress == '' or self.UEUserName == '' or self.UEPassword == '': if RAN.eNBIPAddress == '' or RAN.eNBUserName == '' or RAN.eNBPassword == '' or self.UEIPAddress == '' or self.UEUserName == '' or self.UEPassword == '':
HELP.GenericHelp(CONST.Version) HELP.GenericHelp(CONST.Version)
...@@ -2545,7 +2117,7 @@ class OaiCiTest(): ...@@ -2545,7 +2117,7 @@ class OaiCiTest():
pStatus = self.CheckProcessExist(check_eNB, check_OAI_UE,RAN,EPC) pStatus = self.CheckProcessExist(check_eNB, check_OAI_UE,RAN,EPC)
if (pStatus < 0): if (pStatus < 0):
HTML.CreateHtmlTestRow(self.iperf_args, 'KO', pStatus) HTML.CreateHtmlTestRow(self.iperf_args, 'KO', pStatus)
self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS) self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,CONTAINERS)
return return
server_on_enb = re.search('-R', str(self.iperf_args)) server_on_enb = re.search('-R', str(self.iperf_args))
if server_on_enb is not None: if server_on_enb is not None:
...@@ -2643,12 +2215,12 @@ class OaiCiTest(): ...@@ -2643,12 +2215,12 @@ class OaiCiTest():
HTML.CreateHtmlTestRowQueue(self.iperf_args, 'OK', messages) HTML.CreateHtmlTestRowQueue(self.iperf_args, 'OK', messages)
else: else:
HTML.CreateHtmlTestRowQueue(self.iperf_args, 'KO', messages) HTML.CreateHtmlTestRowQueue(self.iperf_args, 'KO', messages)
self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS) self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,CONTAINERS)
def Iperf(self,HTML,RAN,EPC,COTS_UE, InfraUE,CONTAINERS): def Iperf(self,HTML,RAN,EPC,COTS_UE,CONTAINERS):
result = re.search('noS1', str(RAN.Initialize_eNB_args)) result = re.search('noS1', str(RAN.Initialize_eNB_args))
if result is not None: if result is not None:
self.IperfNoS1(HTML,RAN,EPC,COTS_UE,InfraUE,CONTAINERS) self.IperfNoS1(HTML,RAN,EPC,COTS_UE,CONTAINERS)
return return
if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.SourceCodePath == '' or self.ADBIPAddress == '' or self.ADBUserName == '' or self.ADBPassword == '': if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.SourceCodePath == '' or self.ADBIPAddress == '' or self.ADBUserName == '' or self.ADBPassword == '':
HELP.GenericHelp(CONST.Version) HELP.GenericHelp(CONST.Version)
...@@ -2661,20 +2233,21 @@ class OaiCiTest(): ...@@ -2661,20 +2233,21 @@ class OaiCiTest():
pStatus = self.CheckProcessExist(check_eNB, check_OAI_UE,RAN,EPC) pStatus = self.CheckProcessExist(check_eNB, check_OAI_UE,RAN,EPC)
if (pStatus < 0): if (pStatus < 0):
HTML.CreateHtmlTestRow(self.iperf_args, 'KO', pStatus) HTML.CreateHtmlTestRow(self.iperf_args, 'KO', pStatus)
self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS) self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,CONTAINERS)
return return
# TODO take out
if self.ue_id=="":#is not a module, follow legacy code if self.ue_id=="":#is not a module, follow legacy code
ueIpStatus = self.GetAllUEIPAddresses() ueIpStatus = self.GetAllUEIPAddresses()
if (ueIpStatus < 0): if (ueIpStatus < 0):
HTML.CreateHtmlTestRow(self.iperf_args, 'KO', CONST.UE_IP_ADDRESS_ISSUE) HTML.CreateHtmlTestRow(self.iperf_args, 'KO', CONST.UE_IP_ADDRESS_ISSUE)
self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS) self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,CONTAINERS)
return return
else: #is a module else: #is a module
self.UEIPAddresses=[] self.UEIPAddresses=[]
Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra[self.ue_id]) Module_UE = cls_module_ue.Module_UE(self.ue_id)
Module_UE.GetModuleIPAddress() ip = Module_UE.getIP()
self.UEIPAddresses.append(Module_UE.UEIPAddress) self.UEIPAddresses.append(ip)
...@@ -2713,7 +2286,7 @@ class OaiCiTest(): ...@@ -2713,7 +2286,7 @@ class OaiCiTest():
if (status_queue.empty()): if (status_queue.empty()):
HTML.CreateHtmlTestRow(self.iperf_args, 'KO', CONST.ALL_PROCESSES_OK) HTML.CreateHtmlTestRow(self.iperf_args, 'KO', CONST.ALL_PROCESSES_OK)
self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS) self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,CONTAINERS)
else: else:
iperf_status = True iperf_status = True
iperf_noperf = False iperf_noperf = False
...@@ -2734,7 +2307,7 @@ class OaiCiTest(): ...@@ -2734,7 +2307,7 @@ class OaiCiTest():
HTML.CreateHtmlTestRowQueue(self.iperf_args, 'OK', messages) HTML.CreateHtmlTestRowQueue(self.iperf_args, 'OK', messages)
else: else:
HTML.CreateHtmlTestRowQueue(self.iperf_args, 'KO', messages) HTML.CreateHtmlTestRowQueue(self.iperf_args, 'KO', messages)
self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS) self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,CONTAINERS)
def CheckProcessExist(self, check_eNB, check_OAI_UE,RAN,EPC): def CheckProcessExist(self, check_eNB, check_OAI_UE,RAN,EPC):
multi_jobs = [] multi_jobs = []
...@@ -3101,77 +2674,15 @@ class OaiCiTest(): ...@@ -3101,77 +2674,15 @@ class OaiCiTest():
global_status = CONST.OAI_UE_PROCESS_COULD_NOT_SYNC global_status = CONST.OAI_UE_PROCESS_COULD_NOT_SYNC
return global_status return global_status
def TerminateUE(self, HTML):
def TerminateUE_common(self, device_id, idx,COTS_UE): ue = cls_module_ue.Module_UE(self.ue_id)
try: archive_destination = ue.terminate()
SSH = sshconnection.SSHConnection() if archive_destination:
SSH.open(self.ADBIPAddress, self.ADBUserName, self.ADBPassword) HTML.CreateHtmlTestRow(f'QLog at: {archive_destination}', 'OK', CONST.ALL_PROCESSES_OK)
# back in airplane mode on (ie radio off)
if self.ADBCentralized:
#RH quick add on to intgrate cots control defined by yaml
#if device Id exists in yaml dictionary, we execute the new procedure defined in cots_ue class
#otherwise we use the legacy procedure
if COTS_UE.Check_Exists(device_id):
#switch device to Airplane mode ON (ie Radio OFF)
COTS_UE.Set_Airplane(device_id, 'ON')
elif device_id == '84B7N16418004022':
SSH.command('stdbuf -o0 adb -s ' + device_id + ' shell "su - root -c /data/local/tmp/off"', '\$', 60)
else:
SSH.command('stdbuf -o0 adb -s ' + device_id + ' shell /data/local/tmp/off', '\$', 60)
else:
SSH.command('ssh ' + self.UEDevicesRemoteUser[idx] + '@' + self.UEDevicesRemoteServer[idx] + ' ' + self.UEDevicesOffCmd[idx], '\$', 60)
logging.debug('\u001B[1mUE (' + device_id + ') Detach Completed\u001B[0m')
if self.ADBCentralized:
SSH.command('stdbuf -o0 adb -s ' + device_id + ' shell "ps | grep --color=never iperf | grep -v grep"', '\$', 5)
else:
SSH.command('ssh ' + self.UEDevicesRemoteUser[idx] + '@' + self.UEDevicesRemoteServer[idx] + ' \'adb -s ' + device_id + ' shell "ps | grep --color=never iperf | grep -v grep"\'', '\$', 60)
result = re.search('shell +(?P<pid>\d+)', SSH.getBefore())
if result is not None:
pid_iperf = result.group('pid')
if self.ADBCentralized:
SSH.command('stdbuf -o0 adb -s ' + device_id + ' shell "kill -KILL ' + pid_iperf + '"', '\$', 5)
else:
SSH.command('ssh ' + self.UEDevicesRemoteUser[idx] + '@' + self.UEDevicesRemoteServer[idx] + ' \'adb -s ' + device_id + ' shell "kill -KILL ' + pid_iperf + '"\'', '\$', 60)
SSH.close()
except:
os.kill(os.getppid(),signal.SIGUSR1)
def TerminateUE(self,HTML,COTS_UE,InfraUE,ue_trace):
if self.ue_id=='':#no ID specified, then it is a COTS controlled by ADB
terminate_ue_flag = False
self.GetAllUEDevices(terminate_ue_flag)
multi_jobs = []
i = 0
for device_id in self.UEDevices:
p = Process(target= self.TerminateUE_common, args = (device_id,i,COTS_UE,))
p.daemon = True
p.start()
multi_jobs.append(p)
i += 1
for job in multi_jobs:
job.join()
HTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK)
else: #if an ID is specified, it is a module from the yaml infrastructure file
ue_kind = InfraUE.ci_ue_infra[self.ue_id]['Kind']
logging.debug("Detected UE Kind : " + ue_kind)
if ue_kind == 'quectel':
Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra[self.ue_id])
Module_UE.ue_trace=ue_trace
Module_UE.Command("detach")
Module_UE.DisableTrace()
Module_UE.DisableCM()
archive_destination=Module_UE.LogCollect()
if Module_UE.ue_trace=='yes':
HTML.CreateHtmlTestRow('QLog at : '+archive_destination, 'OK', CONST.ALL_PROCESSES_OK)
else: else:
HTML.CreateHtmlTestRow('QLog trace is disabled', 'OK', CONST.ALL_PROCESSES_OK) HTML.CreateHtmlTestRow('QLog trace is disabled', 'OK', CONST.ALL_PROCESSES_OK)
elif ue_kind == 'amarisoft':
HTML.CreateHtmlTestRow('AS UE is already terminated', 'OK', CONST.ALL_PROCESSES_OK)
else:
logging.debug("Incorrect UE Kind was detected")
def TerminateOAIUE(self,HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS): def TerminateOAIUE(self,HTML,RAN,COTS_UE,EPC,CONTAINERS):
SSH = sshconnection.SSHConnection() SSH = sshconnection.SSHConnection()
SSH.open(self.UEIPAddress, self.UEUserName, self.UEPassword) SSH.open(self.UEIPAddress, self.UEUserName, self.UEPassword)
SSH.command('cd ' + self.UESourceCodePath + '/cmake_targets', '\$', 5) SSH.command('cd ' + self.UESourceCodePath + '/cmake_targets', '\$', 5)
...@@ -3212,11 +2723,11 @@ class OaiCiTest(): ...@@ -3212,11 +2723,11 @@ class OaiCiTest():
# Not an error then # Not an error then
if (logStatus != CONST.OAI_UE_PROCESS_COULD_NOT_SYNC) or (ueAction != 'Sniffing'): if (logStatus != CONST.OAI_UE_PROCESS_COULD_NOT_SYNC) or (ueAction != 'Sniffing'):
self.Initialize_OAI_UE_args = '' self.Initialize_OAI_UE_args = ''
self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS) self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,CONTAINERS)
else: else:
if (logStatus == CONST.OAI_UE_PROCESS_COULD_NOT_SYNC): if (logStatus == CONST.OAI_UE_PROCESS_COULD_NOT_SYNC):
self.Initialize_OAI_UE_args = '' self.Initialize_OAI_UE_args = ''
self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS) self.AutoTerminateUEandeNB(HTML,RAN,COTS_UE,EPC,CONTAINERS)
else: else:
logging.debug('\u001B[1m' + ueAction + ' Completed \u001B[0m') logging.debug('\u001B[1m' + ueAction + ' Completed \u001B[0m')
HTML.htmlUEFailureMsg='<b>' + ueAction + ' Completed</b>\n' + HTML.htmlUEFailureMsg HTML.htmlUEFailureMsg='<b>' + ueAction + ' Completed</b>\n' + HTML.htmlUEFailureMsg
...@@ -3225,21 +2736,21 @@ class OaiCiTest(): ...@@ -3225,21 +2736,21 @@ class OaiCiTest():
else: else:
HTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK) HTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK)
def AutoTerminateUEandeNB(self,HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS): def AutoTerminateUEandeNB(self,HTML,RAN,COTS_UE,EPC,CONTAINERS):
if (self.ADBIPAddress != 'none'): if (self.ADBIPAddress != 'none'):
self.testCase_id = 'AUTO-KILL-UE' self.testCase_id = 'AUTO-KILL-UE'
HTML.testCase_id = self.testCase_id HTML.testCase_id = self.testCase_id
self.desc = 'Automatic Termination of UE' self.desc = 'Automatic Termination of UE'
HTML.desc = self.desc HTML.desc = self.desc
self.ShowTestID() self.ShowTestID()
self.TerminateUE(HTML,COTS_UE,InfraUE,self.ue_trace) self.TerminateUE(HTML,COTS_UE)
if (self.Initialize_OAI_UE_args != ''): if (self.Initialize_OAI_UE_args != ''):
self.testCase_id = 'AUTO-KILL-OAI-UE' self.testCase_id = 'AUTO-KILL-OAI-UE'
HTML.testCase_id = self.testCase_id HTML.testCase_id = self.testCase_id
self.desc = 'Automatic Termination of OAI-UE' self.desc = 'Automatic Termination of OAI-UE'
HTML.desc = self.desc HTML.desc = self.desc
self.ShowTestID() self.ShowTestID()
self.TerminateOAIUE(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS) self.TerminateOAIUE(HTML,RAN,COTS_UE,EPC,CONTAINERS)
if (RAN.Initialize_eNB_args != ''): if (RAN.Initialize_eNB_args != ''):
self.testCase_id = 'AUTO-KILL-RAN' self.testCase_id = 'AUTO-KILL-RAN'
HTML.testCase_id = self.testCase_id HTML.testCase_id = self.testCase_id
...@@ -3290,7 +2801,14 @@ class OaiCiTest(): ...@@ -3290,7 +2801,14 @@ class OaiCiTest():
CONTAINERS.eNB_instance=instance CONTAINERS.eNB_instance=instance
CONTAINERS.UndeployObject(HTML,RAN) CONTAINERS.UndeployObject(HTML,RAN)
RAN.prematureExit=True RAN.prematureExit=True
def GetAllUEDevices(self,terminate_ue_flag):
SSH = sshconnection.SSHConnection()
SSH.open(self.ADBIPAddress, self.ADBUserName, self.ADBPassword)
SSH.command('adb devices', '\$', 15)
self.UEDevices = re.findall('\r\n([A-Za-z0-9]+)\tdevice',SSH.getBefore())
msg = "UEDevices found by GetAllUEDevices : " + " ".join(self.UEDevices)
logging.debug(msg)
SSH.close()
def IdleSleep(self,HTML): def IdleSleep(self,HTML):
time.sleep(self.idle_sleep_time) time.sleep(self.idle_sleep_time)
......
...@@ -43,7 +43,6 @@ import cls_physim #class PhySim for physical simulators build and ...@@ -43,7 +43,6 @@ import cls_physim #class PhySim for physical simulators build and
import cls_cots_ue #class CotsUe for Airplane mode control import cls_cots_ue #class CotsUe for Airplane mode control
import cls_containerize #class Containerize for all container-based operations on RAN/UE objects import cls_containerize #class Containerize for all container-based operations on RAN/UE objects
import cls_static_code_analysis #class for static code analysis import cls_static_code_analysis #class for static code analysis
import cls_ci_ueinfra #class defining the multi Ue infrastrucure
import cls_physim1 #class PhySim for physical simulators deploy and run 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
...@@ -222,7 +221,6 @@ def GetParametersFromXML(action): ...@@ -222,7 +221,6 @@ def GetParametersFromXML(action):
elif action == 'Initialize_UE': elif action == 'Initialize_UE':
ue_id = test.findtext('id') ue_id = test.findtext('id')
CiTestObj.ue_trace=test.findtext('UE_Trace')#temporary variable, to be passed to Module_UE in Initialize_UE call
if (ue_id is None): if (ue_id is None):
CiTestObj.ue_id = "" CiTestObj.ue_id = ""
else: else:
...@@ -544,22 +542,6 @@ with open(yaml_file,'r') as f: ...@@ -544,22 +542,6 @@ with open(yaml_file,'r') as f:
#from YAML scalar values to Python dictionary format$ #from YAML scalar values to Python dictionary format$
xml_class_list = yaml.load(f,Loader=yaml.FullLoader) xml_class_list = yaml.load(f,Loader=yaml.FullLoader)
#loading UE infrastructure from yaml
ue_infra_file='ci_ueinfra.yaml'
if (os.path.isfile(ue_infra_file)):
yaml_file=ue_infra_file
elif (os.path.isfile('ci-scripts/'+ue_infra_file)):
yaml_file='ci-scripts/'+ue_infra_file
else:
logging.error("UE infrastructure yaml file cannot be found")
sys.exit("UE infrastructure file cannot be found")
InfraUE=cls_ci_ueinfra.InfraUE() #initialize UE infrastructure class
InfraUE.Get_UE_Infra(yaml_file) #read the UE infra, filename is hardcoded and unique for the moment but should be passed as parameter from the test suite
mode = '' mode = ''
CiTestObj = cls_oaicitest.OaiCiTest() CiTestObj = cls_oaicitest.OaiCiTest()
...@@ -621,13 +603,13 @@ elif re.match('^TerminateUE$', mode, re.IGNORECASE): ...@@ -621,13 +603,13 @@ elif re.match('^TerminateUE$', mode, re.IGNORECASE):
HELP.GenericHelp(CONST.Version) HELP.GenericHelp(CONST.Version)
sys.exit('Insufficient Parameter') sys.exit('Insufficient Parameter')
signal.signal(signal.SIGUSR1, receive_signal) signal.signal(signal.SIGUSR1, receive_signal)
CiTestObj.TerminateUE(HTML,COTS_UE,InfraUE,CiTestObj.ue_trace) CiTestObj.TerminateUE(HTML,COTS_UE)
elif re.match('^TerminateOAIUE$', mode, re.IGNORECASE): elif re.match('^TerminateOAIUE$', mode, re.IGNORECASE):
if CiTestObj.UEIPAddress == '' or CiTestObj.UEUserName == '' or CiTestObj.UEPassword == '': if CiTestObj.UEIPAddress == '' or CiTestObj.UEUserName == '' or CiTestObj.UEPassword == '':
HELP.GenericHelp(CONST.Version) HELP.GenericHelp(CONST.Version)
sys.exit('Insufficient Parameter') sys.exit('Insufficient Parameter')
signal.signal(signal.SIGUSR1, receive_signal) signal.signal(signal.SIGUSR1, receive_signal)
CiTestObj.TerminateOAIUE(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS) CiTestObj.TerminateOAIUE(HTML,RAN,COTS_UE,EPC,CONTAINERS)
elif re.match('^TerminateHSS$', mode, re.IGNORECASE): elif re.match('^TerminateHSS$', mode, re.IGNORECASE):
if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.Type == '' or EPC.SourceCodePath == '': if EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.Type == '' or EPC.SourceCodePath == '':
HELP.GenericHelp(CONST.Version) HELP.GenericHelp(CONST.Version)
...@@ -859,15 +841,15 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re ...@@ -859,15 +841,15 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re
continue continue
CiTestObj.ShowTestID() CiTestObj.ShowTestID()
GetParametersFromXML(action) GetParametersFromXML(action)
if action == 'Initialize_UE' or action == 'Attach_UE' or action == 'Detach_UE' or action == 'Ping' or action == 'Iperf' or action == 'Reboot_UE' or action == 'DataDisable_UE' or action == 'DataEnable_UE' or action == 'CheckStatusUE': #if action == 'Initialize_UE' or action == 'Attach_UE' or action == 'Detach_UE' or action == 'Ping' or action == 'Iperf' or action == 'Reboot_UE' or action == 'DataDisable_UE' or action == 'DataEnable_UE' or action == 'CheckStatusUE':
if (CiTestObj.ADBIPAddress != 'none') and (CiTestObj.ADBIPAddress != 'modules'): # if (CiTestObj.ADBIPAddress != 'none') and (CiTestObj.ADBIPAddress != 'modules'):
#in these cases, having no devices is critical, GetAllUEDevices function has to manage it as a critical error, reason why terminate_ue_flag is set to True #in these cases, having no devices is critical, GetAllUEDevices function has to manage it as a critical error, reason why terminate_ue_flag is set to True
terminate_ue_flag = True # terminate_ue_flag = True
# Now we stop properly the test-suite --> clean reporting # Now we stop properly the test-suite --> clean reporting
status = CiTestObj.GetAllUEDevices(terminate_ue_flag) # status = CiTestObj.GetAllUEDevices(terminate_ue_flag)
if not status: # if not status:
RAN.prematureExit = True # RAN.prematureExit = True
break # break
if action == 'Build_eNB': if action == 'Build_eNB':
RAN.BuildeNB(HTML) RAN.BuildeNB(HTML)
elif action == 'WaitEndBuild_eNB': elif action == 'WaitEndBuild_eNB':
...@@ -885,29 +867,29 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re ...@@ -885,29 +867,29 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re
elif action == 'Terminate_eNB': elif action == 'Terminate_eNB':
RAN.TerminateeNB(HTML, EPC) RAN.TerminateeNB(HTML, EPC)
elif action == 'Initialize_UE': elif action == 'Initialize_UE':
CiTestObj.InitializeUE(HTML,RAN, EPC, COTS_UE, InfraUE, CiTestObj.ue_trace, CONTAINERS) CiTestObj.InitializeUE(HTML,RAN, EPC, COTS_UE, CONTAINERS)
elif action == 'Terminate_UE': elif action == 'Terminate_UE':
CiTestObj.TerminateUE(HTML,COTS_UE, InfraUE, CiTestObj.ue_trace) CiTestObj.TerminateUE(HTML)
elif action == 'Attach_UE': elif action == 'Attach_UE':
CiTestObj.AttachUE(HTML,RAN,EPC,COTS_UE,InfraUE,CONTAINERS) CiTestObj.AttachUE(HTML,RAN,EPC,COTS_UE,CONTAINERS)
elif action == 'Detach_UE': elif action == 'Detach_UE':
CiTestObj.DetachUE(HTML,RAN,EPC,COTS_UE,InfraUE,CONTAINERS) CiTestObj.DetachUE(HTML,RAN,EPC,COTS_UE,CONTAINERS)
elif action == 'DataDisable_UE': elif action == 'DataDisable_UE':
CiTestObj.DataDisableUE(HTML) CiTestObj.DataDisableUE(HTML)
elif action == 'DataEnable_UE': elif action == 'DataEnable_UE':
CiTestObj.DataEnableUE(HTML) CiTestObj.DataEnableUE(HTML)
elif action == 'CheckStatusUE': elif action == 'CheckStatusUE': # still used?
CiTestObj.CheckStatusUE(HTML,RAN,EPC,COTS_UE,InfraUE,CONTAINERS) CiTestObj.CheckStatusUE(HTML,RAN,EPC,COTS_UE,CONTAINERS)
elif action == 'Build_OAI_UE': elif action == 'Build_OAI_UE':
CiTestObj.BuildOAIUE(HTML) CiTestObj.BuildOAIUE(HTML)
elif action == 'Initialize_OAI_UE': elif action == 'Initialize_OAI_UE':
CiTestObj.InitializeOAIUE(HTML,RAN,EPC,COTS_UE,InfraUE,CONTAINERS) CiTestObj.InitializeOAIUE(HTML,RAN,EPC,COTS_UE,CONTAINERS)
elif action == 'Terminate_OAI_UE': elif action == 'Terminate_OAI_UE':
CiTestObj.TerminateOAIUE(HTML,RAN,COTS_UE,EPC,InfraUE,CONTAINERS) CiTestObj.TerminateOAIUE(HTML,RAN,COTS_UE,EPC,CONTAINERS)
elif action == 'Ping': elif action == 'Ping':
CiTestObj.Ping(HTML,RAN,EPC,COTS_UE, InfraUE, CONTAINERS) CiTestObj.Ping(HTML,RAN,EPC,COTS_UE, CONTAINERS)
elif action == 'Iperf': elif action == 'Iperf':
CiTestObj.Iperf(HTML,RAN,EPC,COTS_UE, InfraUE, CONTAINERS) CiTestObj.Iperf(HTML,RAN,EPC,COTS_UE, CONTAINERS)
elif action == 'Reboot_UE': elif action == 'Reboot_UE':
CiTestObj.RebootUE(HTML,RAN,EPC) CiTestObj.RebootUE(HTML,RAN,EPC)
elif action == 'Initialize_HSS': elif action == 'Initialize_HSS':
......
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