Commit e120cabd authored by Raphael Defosseux's avatar Raphael Defosseux

CI: fix HTML footer generation

Signed-off-by: default avatarRaphael Defosseux <raphael.defosseux@eurecom.fr>
parent 8e8e9d67
......@@ -69,6 +69,14 @@ class HTMLManagement():
self.testCase_id = ''
self.desc = ''
self.OsVersion = ['', '']
self.KernelVersion = ['', '']
self.UhdVersion = ['', '']
self.UsrpBoard = ['', '']
self.CpuNb = ['', '']
self.CpuModel = ['', '']
self.CpuMHz = ['', '']
#-----------------------------------------------------------
# Setters and Getters
#-----------------------------------------------------------
......@@ -90,8 +98,9 @@ class HTMLManagement():
def SettestCase_id(self, tcid):
self.testCase_id = tcid
def GettestCase_id(self):
return self.testCase_id
def SetranRepository(self, repository):
self.ranRepository = repository
def GetranRepository(self):
......@@ -102,7 +111,6 @@ class HTMLManagement():
def GetranAllowMerge(self):
return self.ranAllowMerge
def SetranBranch(self, branch):
self.ranBranch = branch
def GetranBranch(self):
......@@ -132,19 +140,29 @@ class HTMLManagement():
def GetnbTestXMLfiles(self):
return self.nbTestXMLfiles
def SettestXMLfiles(self, xmlFile):
self.testXMLfiles.append(xmlFile)
def SethtmlTabRefs(self, tabRef):
self.htmlTabRefs.append(tabRef)
def SethtmlTabNames(self, tabName):
self.htmlTabNames.append(tabName)
def SethtmlTabIcons(self, tabIcon):
self.htmlTabIcons.append(tabIcon)
def SetOsVersion(self, version, idx):
self.OsVersion[idx] = version
def SetKernelVersion(self, version, idx):
self.KernelVersion[idx] = version
def SetUhdVersion(self, version, idx):
self.UhdVersion[idx] = version
def SetUsrpBoard(self, version, idx):
self.UsrpBoard[idx] = version
def SetCpuNb(self, nb, idx):
self.CpuNb[idx] = nb
def SetCpuModel(self, model, idx):
self.CpuModel[idx] = model
def SetCpuMHz(self, freq, idx):
self.CpuMHz[idx] = freq
#-----------------------------------------------------------
# HTML structure creation functions
......@@ -307,68 +325,40 @@ class HTMLManagement():
def CreateHtmlFooter(self, passStatus):
if (os.path.isfile('test_results.html')):
logging.debug('\u001B[1m----------------------------------------\u001B[0m')
logging.debug('\u001B[1m Creating HTML footer \u001B[0m')
logging.debug('\u001B[1m----------------------------------------\u001B[0m')
self.htmlFile = open('test_results.html', 'a')
self.htmlFile.write('</div>\n')
self.htmlFile.write(' <p></p>\n')
self.htmlFile.write(' <table class="table table-condensed">\n')
# GP machines = [ 'eNB', 'UE' ]
# GP for machine in machines:
#GP This needs to move back to main and be called before CreateHtmlFooter
res = self.reseNB
if res != -1:
self.htmlFile.write(' <tr>\n')
self.htmlFile.write(' <th colspan=8>' + str('eNB') + ' Server Characteristics</th>\n')
self.htmlFile.write(' </tr>\n')
self.htmlFile.write(' <tr>\n')
self.htmlFile.write(' <td>OS Version</td>\n')
self.htmlFile.write(' <td><span class="label label-default">' + self.OsVersion + '</span></td>\n')
self.htmlFile.write(' <td>Kernel Version</td>\n')
self.htmlFile.write(' <td><span class="label label-default">' + self.KernelVersion + '</span></td>\n')
self.htmlFile.write(' <td>UHD Version</td>\n')
self.htmlFile.write(' <td><span class="label label-default">' + self.UhdVersion + '</span></td>\n')
self.htmlFile.write(' <td>USRP Board</td>\n')
self.htmlFile.write(' <td><span class="label label-default">' + self.UsrpBoard + '</span></td>\n')
self.htmlFile.write(' </tr>\n')
self.htmlFile.write(' <tr>\n')
self.htmlFile.write(' <td>Nb CPUs</td>\n')
self.htmlFile.write(' <td><span class="label label-default">' + self.CpuNb + '</span></td>\n')
self.htmlFile.write(' <td>CPU Model Name</td>\n')
self.htmlFile.write(' <td><span class="label label-default">' + self.CpuModel + '</span></td>\n')
self.htmlFile.write(' <td>CPU Frequency</td>\n')
self.htmlFile.write(' <td><span class="label label-default">' + self.CpuMHz + '</span></td>\n')
self.htmlFile.write(' <td></td>\n')
self.htmlFile.write(' <td></td>\n')
self.htmlFile.write(' </tr>\n')
machines = [ 'eNB', 'UE' ]
for machine in machines:
if machine == 'eNB':
idx = 0
else:
idx = 1
if self.OsVersion[idx] == '':
continue
res = self.resUE
if res != -1:
self.htmlFile.write(' <tr>\n')
self.htmlFile.write(' <th colspan=8>' + str('UE') + ' Server Characteristics</th>\n')
self.htmlFile.write(' <th colspan=8>' + str('eNB') + ' Server Characteristics</th>\n')
self.htmlFile.write(' </tr>\n')
self.htmlFile.write(' <tr>\n')
self.htmlFile.write(' <td>OS Version</td>\n')
self.htmlFile.write(' <td><span class="label label-default">' + self.OsVersion + '</span></td>\n')
self.htmlFile.write(' <td><span class="label label-default">' + self.OsVersion[idx] + '</span></td>\n')
self.htmlFile.write(' <td>Kernel Version</td>\n')
self.htmlFile.write(' <td><span class="label label-default">' + self.KernelVersion + '</span></td>\n')
self.htmlFile.write(' <td><span class="label label-default">' + self.KernelVersion[idx] + '</span></td>\n')
self.htmlFile.write(' <td>UHD Version</td>\n')
self.htmlFile.write(' <td><span class="label label-default">' + self.UhdVersion + '</span></td>\n')
self.htmlFile.write(' <td><span class="label label-default">' + self.UhdVersion[idx] + '</span></td>\n')
self.htmlFile.write(' <td>USRP Board</td>\n')
self.htmlFile.write(' <td><span class="label label-default">' + self.UsrpBoard + '</span></td>\n')
self.htmlFile.write(' <td><span class="label label-default">' + self.UsrpBoard[idx] + '</span></td>\n')
self.htmlFile.write(' </tr>\n')
self.htmlFile.write(' <tr>\n')
self.htmlFile.write(' <td>Nb CPUs</td>\n')
self.htmlFile.write(' <td><span class="label label-default">' + self.CpuNb + '</span></td>\n')
self.htmlFile.write(' <td><span class="label label-default">' + self.CpuNb[idx] + '</span></td>\n')
self.htmlFile.write(' <td>CPU Model Name</td>\n')
self.htmlFile.write(' <td><span class="label label-default">' + self.CpuModel + '</span></td>\n')
self.htmlFile.write(' <td><span class="label label-default">' + self.CpuModel[idx] + '</span></td>\n')
self.htmlFile.write(' <td>CPU Frequency</td>\n')
self.htmlFile.write(' <td><span class="label label-default">' + self.CpuMHz + '</span></td>\n')
self.htmlFile.write(' <td><span class="label label-default">' + self.CpuMHz[idx] + '</span></td>\n')
self.htmlFile.write(' <td></td>\n')
self.htmlFile.write(' <td></td>\n')
self.htmlFile.write(' </tr>\n')
......
......@@ -94,13 +94,6 @@ class OaiCiTest():
self.x2ENBConnectedUEs = []
self.repeatCounts = []
self.finalStatus = False
self.OsVersion = ''
self.KernelVersion = ''
self.UhdVersion = ''
self.UsrpBoard = ''
self.CpuNb = ''
self.CpuModel = ''
self.CpuMHz = ''
self.UEIPAddress = ''
self.UEUserName = ''
self.UEPassword = ''
......@@ -2747,26 +2740,26 @@ class OaiCiTest():
def AutoTerminateUEandeNB(self):
if (self.ADBIPAddress != 'none'):
self.testCase_id = 'AUTO-KILL-UE'
RAN.SettestCase_id(self.testCase_id)
HTML.SettestCase_id(self.testCase_id)
self.desc = 'Automatic Termination of UE'
self.ShowTestID()
self.TerminateUE()
if (self.Initialize_OAI_UE_args != ''):
self.testCase_id = 'AUTO-KILL-UE'
RAN.SettestCase_id(self.testCase_id)
HTML.SettestCase_id(self.testCase_id)
self.desc = 'Automatic Termination of UE'
self.ShowTestID()
self.TerminateOAIUE()
if (RAN.GetInitialize_eNB_args() != ''):
self.testCase_id = 'AUTO-KILL-eNB'
RAN.SettestCase_id(self.testCase_id)
HTML.SettestCase_id(self.testCase_id)
self.desc = 'Automatic Termination of eNB'
self.ShowTestID()
RAN.SeteNB_instance('0')
RAN.TerminateeNB()
if RAN.GetflexranCtrlInstalled() and RAN.GetflexranCtrlStarted():
self.testCase_id = 'AUTO-KILL-flexran-ctl'
RAN.SettestCase_id(self.testCase_id)
HTML.SettestCase_id(self.testCase_id)
self.desc = 'Automatic Termination of FlexRan CTL'
self.ShowTestID()
self.TerminateFlexranCtrl()
......@@ -2934,19 +2927,20 @@ class OaiCiTest():
def RetrieveSystemVersion(self, machine):
if RAN.GeteNBIPAddress() == 'none' or self.UEIPAddress == 'none':
self.OsVersion = 'Ubuntu 16.04.5 LTS'
self.KernelVersion = '4.15.0-45-generic'
self.UhdVersion = '3.13.0.1-0'
self.UsrpBoard = 'B210'
self.CpuNb = '4'
self.CpuModel = 'Intel(R) Core(TM) i5-6200U'
self.CpuMHz = '2399.996 MHz'
HTML.SetOsVersion('Ubuntu 16.04.5 LTS', 0)
HTML.SetKernelVersion('4.15.0-45-generic', 0)
HTML.SetUhdVersion('3.13.0.1-0', 0)
HTML.SetUsrpBoard('B210', 0)
HTML.SetCpuNb('4', 0)
HTML.SetCpuModel('Intel(R) Core(TM) i5-6200U', 0)
HTML.SetCpuMHz('2399.996 MHz', 0)
return 0
if machine == 'eNB':
if RAN.GeteNBIPAddress() != '' and RAN.GeteNBUserName() != '' and RAN.GeteNBPassword() != '':
IPAddress = RAN.GeteNBIPAddress()
UserName = RAN.GeteNBUserName()
Password = RAN.GeteNBPassword()
idx = 0
else:
return -1
if machine == 'UE':
......@@ -2954,6 +2948,7 @@ class OaiCiTest():
IPAddress = self.UEIPAddress
UserName = self.UEUserName
Password = self.UEPassword
idx = 1
else:
return -1
......@@ -2961,55 +2956,64 @@ class OaiCiTest():
SSH.command('lsb_release -a', '\$', 5)
result = re.search('Description:\\\\t(?P<os_type>[a-zA-Z0-9\-\_\.\ ]+)', SSH.getBefore())
if result is not None:
self.OsVersion = result.group('os_type')
logging.debug('OS is: ' + self.OsVersion)
OsVersion = result.group('os_type')
logging.debug('OS is: ' + OsVersion)
HTML.SetOsVersion(OsVersion, idx)
else:
SSH.command('hostnamectl', '\$', 5)
result = re.search('Operating System: (?P<os_type>[a-zA-Z0-9\-\_\.\ ]+)', SSH.getBefore())
if result is not None:
self.OsVersion = result.group('os_type')
if self.OsVersion == 'CentOS Linux 7 ':
OsVersion = result.group('os_type')
if OsVersion == 'CentOS Linux 7 ':
SSH.command('cat /etc/redhat-release', '\$', 5)
result = re.search('CentOS Linux release (?P<os_version>[0-9\.]+)', SSH.getBefore())
if result is not None:
self.OsVersion = self.OsVersion.replace('7 ', result.group('os_version'))
logging.debug('OS is: ' + self.OsVersion)
OsVersion = OsVersion.replace('7 ', result.group('os_version'))
logging.debug('OS is: ' + OsVersion)
HTML.SetOsVersion(OsVersion, idx)
SSH.command('uname -r', '\$', 5)
result = re.search('uname -r\\\\r\\\\n(?P<kernel_version>[a-zA-Z0-9\-\_\.]+)', SSH.getBefore())
if result is not None:
self.KernelVersion = result.group('kernel_version')
logging.debug('Kernel Version is: ' + self.KernelVersion)
KernelVersion = result.group('kernel_version')
logging.debug('Kernel Version is: ' + KernelVersion)
HTML.SetKernelVersion(KernelVersion, idx)
SSH.command('dpkg --list | egrep --color=never libuhd003', '\$', 5)
result = re.search('libuhd003:amd64 *(?P<uhd_version>[0-9\.]+)', SSH.getBefore())
if result is not None:
self.UhdVersion = result.group('uhd_version')
logging.debug('UHD Version is: ' + self.UhdVersion)
UhdVersion = result.group('uhd_version')
logging.debug('UHD Version is: ' + UhdVersion)
HTML.SetUhdVersion(UhdVersion, idx)
else:
SSH.command('uhd_config_info --version', '\$', 5)
result = re.search('UHD (?P<uhd_version>[a-zA-Z0-9\.\-]+)', SSH.getBefore())
if result is not None:
self.UhdVersion = result.group('uhd_version')
logging.debug('UHD Version is: ' + self.UhdVersion)
UhdVersion = result.group('uhd_version')
logging.debug('UHD Version is: ' + UhdVersion)
HTML.SetUhdVersion(UhdVersion, idx)
SSH.command('echo ' + Password + ' | sudo -S uhd_find_devices', '\$', 60)
usrp_boards = re.findall('product: ([0-9A-Za-z]+)\\\\r\\\\n', SSH.getBefore())
count = 0
for board in usrp_boards:
if count == 0:
self.UsrpBoard = board
UsrpBoard = board
else:
self.UsrpBoard += ',' + board
UsrpBoard += ',' + board
count += 1
if count > 0:
logging.debug('USRP Board(s) : ' + self.UsrpBoard)
logging.debug('USRP Board(s) : ' + UsrpBoard)
HTML.SetUsrpBoard(UsrpBoard, idx)
SSH.command('lscpu', '\$', 5)
result = re.search('CPU\(s\): *(?P<nb_cpus>[0-9]+).*Model name: *(?P<model>[a-zA-Z0-9\-\_\.\ \(\)]+).*CPU MHz: *(?P<cpu_mhz>[0-9\.]+)', SSH.getBefore())
if result is not None:
self.CpuNb = result.group('nb_cpus')
logging.debug('nb_cpus: ' + self.CpuNb)
self.CpuModel = result.group('model')
logging.debug('model: ' + self.CpuModel)
self.CpuMHz = result.group('cpu_mhz') + ' MHz'
logging.debug('cpu_mhz: ' + self.CpuMHz)
CpuNb = result.group('nb_cpus')
logging.debug('nb_cpus: ' + CpuNb)
HTML.SetCpuNb(CpuNb, idx)
CpuModel = result.group('model')
logging.debug('model: ' + CpuModel)
HTML.SetCpuModel(CpuModel, idx)
CpuMHz = result.group('cpu_mhz') + ' MHz'
logging.debug('cpu_mhz: ' + CpuMHz)
HTML.SetCpuMHz(CpuMHz, idx)
SSH.close()
#-----------------------------------------------------------
......@@ -3199,6 +3203,8 @@ RAN = ran.RANManagement()
HTML = html.HTMLManagement()
EPC.SetHtmlObj(HTML)
RAN.SetHtmlObj(HTML)
RAN.SetEpcObj(EPC)
argvs = sys.argv
argc = len(argvs)
......@@ -3293,19 +3299,15 @@ while len(argvs) > 1:
elif re.match('^\-\-EPCIPAddress=(.+)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-EPCIPAddress=(.+)$', myArgv, re.IGNORECASE)
EPC.SetIPAddress(matchReg.group(1))
RAN.SetIPAddress(matchReg.group(1))
elif re.match('^\-\-EPCUserName=(.+)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-EPCUserName=(.+)$', myArgv, re.IGNORECASE)
EPC.SetUserName(matchReg.group(1))
RAN.SetUserName(matchReg.group(1))
elif re.match('^\-\-EPCPassword=(.+)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-EPCPassword=(.+)$', myArgv, re.IGNORECASE)
EPC.SetPassword(matchReg.group(1))
RAN.SetPassword(matchReg.group(1))
elif re.match('^\-\-EPCSourceCodePath=(.+)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-EPCSourceCodePath=(.+)$', myArgv, re.IGNORECASE)
EPC.SetSourceCodePath(matchReg.group(1))
RAN.SetSourceCodePath(matchReg.group(1))
elif re.match('^\-\-EPCType=(.+)$', myArgv, re.IGNORECASE):
matchReg = re.match('^\-\-EPCType=(.+)$', myArgv, re.IGNORECASE)
if re.match('OAI', matchReg.group(1), re.IGNORECASE) or re.match('ltebox', matchReg.group(1), re.IGNORECASE) or re.match('OAI-Rel14-CUPS', matchReg.group(1), re.IGNORECASE):
......@@ -3466,8 +3468,12 @@ elif re.match('^InitiateHtml$', mode, re.IGNORECASE):
HTML.SethtmlNb_CATM_Modules(len(CiTestObj.CatMDevices))
HTML.CreateHtmlHeader(CiTestObj.ADBIPAddress)
elif re.match('^FinalizeHtml$', mode, re.IGNORECASE):
HTML.SetreseNB(RetrieveSystemVersion('eNB'))
HTML.SetresUE(RetrieveSystemVersion('UE'))
logging.debug('\u001B[1m----------------------------------------\u001B[0m')
logging.debug('\u001B[1m Creating HTML footer \u001B[0m')
logging.debug('\u001B[1m----------------------------------------\u001B[0m')
CiTestObj.RetrieveSystemVersion('eNB')
CiTestObj.RetrieveSystemVersion('UE')
HTML.CreateHtmlFooter(CiTestObj.finalStatus)
elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re.IGNORECASE):
if re.match('^TesteNB$', mode, re.IGNORECASE):
......@@ -3575,7 +3581,6 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re
if test_case_id != id:
continue
CiTestObj.testCase_id = id
RAN.SettestCase_id(CiTestObj.testCase_id)
HTML.SettestCase_id(CiTestObj.testCase_id)
CiTestObj.desc = test.findtext('desc')
HTML.Setdesc(CiTestObj.desc)
......
......@@ -46,10 +46,7 @@ import sshconnection as SSH
import epc
import helpreadme as HELP
import constants as CONST
import html as HTML
EPC = epc.EPCManagement()
import html
#-----------------------------------------------------------
# Class Declaration
......@@ -90,23 +87,19 @@ class RANManagement():
self.eNBstatuses = [-1, -1, -1]
self.flexranCtrlInstalled = False
self.flexranCtrlStarted = False
self.epcPcapFile = ''
self.htmlObj = None
self.epcObj = None
#-----------------------------------------------------------
# Setters and Getters
# Setters and Getters on Public members
#-----------------------------------------------------------
def SetIPAddress(self, ipaddress):
self.EPCIPAddress = ipaddress
def SetUserName(self, username):
self.EPCUserName = username
def SetPassword(self, password):
self.EPCPassword = password
def SetSourceCodePath(self, sourcecodepath):
self.EPCSourceCodePath = sourcecodepath
def SetHtmlObj(self, obj):
self.htmlObj = obj
def SetEpcObj(self, obj):
self.epcObj = obj
def SettestCase_id(self,tcid):
self.testCase_id = tcid
def SetflexranCtrlInstalled(self,fxrctin):
self.flexranCtrlInstalled = fxrctin
def GetflexranCtrlInstalled(self):
......@@ -242,7 +235,6 @@ class RANManagement():
def BuildeNB(self):
myHTML = HTML.HTMLManagement()
if self.ranRepository == '' or self.ranBranch == '' or self.ranCommitID == '':
GenericHelp(Version)
sys.exit('Insufficient Parameter')
......@@ -315,7 +307,8 @@ class RANManagement():
mismatch = True
if not mismatch:
mySSH.close()
myHTML.CreateHtmlTestRow(self.Build_eNB_args, 'OK', CONST.ALL_PROCESSES_OK)
if self.htmlObj is not None:
self.htmlObj.CreateHtmlTestRow(self.Build_eNB_args, 'OK', CONST.ALL_PROCESSES_OK)
return
mySSH.command('echo ' + lPassWord + ' | sudo -S git clean -x -d -ff', '\$', 30)
......@@ -341,12 +334,17 @@ class RANManagement():
mySSH.command('chmod 775 ./my-lte-softmodem-build.sh', '\$', 5)
mySSH.command('echo ' + lPassWord + ' | sudo -S -E daemon --inherit --unsafe --name=build_enb_daemon --chdir=' + lSourcePath + '/cmake_targets -o ' + lSourcePath + '/cmake_targets/compile_oai_enb.log ./my-lte-softmodem-build.sh', '\$', 5)
mySSH.close()
myHTML.CreateHtmlTestRow(self.Build_eNB_args, 'OK', CONST.ALL_PROCESSES_OK)
self.backgroundBuildTestId[int(self.eNB_instance)] = self.testCase_id
if self.htmlObj is not None:
self.htmlObj.CreateHtmlTestRow(self.Build_eNB_args, 'OK', CONST.ALL_PROCESSES_OK)
self.backgroundBuildTestId[int(self.eNB_instance)] = self.htmlObj.GettestCase_id()
return
mySSH.command('stdbuf -o0 ./build_oai ' + self.Build_eNB_args + ' 2>&1 | stdbuf -o0 tee compile_oai_enb.log', 'Bypassing the Tests|build have failed', 1500)
mySSH.close()
self.checkBuildeNB(lIpAddr, lUserName, lPassWord, lSourcePath, self.testCase_id)
if self.htmlObj is not None:
tId = self.htmlObj.GettestCase_id()
else:
tId = '0000'
self.checkBuildeNB(lIpAddr, lUserName, lPassWord, lSourcePath, tId)
......@@ -385,8 +383,8 @@ class RANManagement():
self.checkBuildeNB(lIpAddr, lUserName, lPassWord, lSourcePath, self.backgroundBuildTestId[int(self.eNB_instance)])
def checkBuildeNB(self, lIpAddr, lUserName, lPassWord, lSourcePath, testcaseId):
myHTML = HTML.HTMLManagement()
myHTML.SettestCase_id(testcaseId)
if self.htmlObj is not None:
self.htmlObj.SettestCase_id(testcaseId)
mySSH = SSH.SSHConnection()
mySSH.open(lIpAddr, lUserName, lPassWord)
mySSH.command('cd ' + lSourcePath + '/cmake_targets', '\$', 3)
......@@ -436,16 +434,17 @@ class RANManagement():
if buildStatus:
logging.info('\u001B[1m Building OAI ' + nodeB_prefix + 'NB Pass\u001B[0m')
myHTML.CreateHtmlTestRow(self.Build_eNB_args, 'OK', CONST.ALL_PROCESSES_OK)
if self.htmlObj is not None:
self.htmlObj.CreateHtmlTestRow(self.Build_eNB_args, 'OK', CONST.ALL_PROCESSES_OK)
else:
logging.error('\u001B[1m Building OAI ' + nodeB_prefix + 'NB Failed\u001B[0m')
myHTML.CreateHtmlTestRow(self.Build_eNB_args, 'KO', CONST.ALL_PROCESSES_OK)
myHTML.CreateHtmlTabFooter(False)
if self.htmlObj is not None:
self.htmlObj.CreateHtmlTestRow(self.Build_eNB_args, 'KO', CONST.ALL_PROCESSES_OK)
self.htmlObj.CreateHtmlTabFooter(False)
sys.exit(1)
def InitializeeNB(self):
myHTML = HTML.HTMLManagement()
if self.eNB_serverId == '0':
lIpAddr = self.eNBIPAddress
lUserName = self.eNBUserName
......@@ -467,21 +466,25 @@ class RANManagement():
mySSH = SSH.SSHConnection()
if (self.pStatus < 0):
myHTML.CreateHtmlTestRow(self.Initialize_eNB_args, 'KO', self.pStatus)
myHTML.CreateHtmlTabFooter(False)
if self.htmlObj is not None:
self.htmlObj.CreateHtmlTestRow(self.Initialize_eNB_args, 'KO', self.pStatus)
self.htmlObj.CreateHtmlTabFooter(False)
sys.exit(1)
# If tracer options is on, running tshark on EPC side and capture traffic b/ EPC and eNB
result = re.search('T_stdout', str(self.Initialize_eNB_args))
if result is not None:
mySSH.open(self.EPCIPAddress, self.EPCUserName, self.EPCPassword)
if (result is not None) and (self.epcObj is not None):
localEpcIpAddr = self.epcObj.GetIPAddress()
localEpcUserName = self.epcObj.GetUserName()
localEpcPassword = self.epcObj.GetPassword()
mySSH.open(localEpcIpAddr, localEpcUserName, localEpcPassword)
mySSH.command('ip addr show | awk -f /tmp/active_net_interfaces.awk | egrep -v "lo|tun"', '\$', 5)
result = re.search('interfaceToUse=(?P<eth_interface>[a-zA-Z0-9\-\_]+)done', mySSH.getBefore())
if result is not None:
eth_interface = result.group('eth_interface')
logging.debug('\u001B[1m Launching tshark on interface ' + eth_interface + '\u001B[0m')
EPC.Set_PcapFileName('enb_' + self.testCase_id + '_s1log.pcap')
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S rm -f /tmp/' + EPC.Get_PcapFileName() , '\$', 5)
mySSH.command('echo $USER; nohup sudo tshark -f "host ' + lIpAddr +'" -i ' + eth_interface + ' -w /tmp/' + EPC.Get_PcapFileName() + ' > /tmp/tshark.log 2>&1 &', self.EPCUserName, 5)
self.epcPcapFile = 'enb_' + self.testCase_id + '_s1log.pcap'
mySSH.command('echo ' + localEpcPassword + ' | sudo -S rm -f /tmp/' + self.epcPcapFile , '\$', 5)
mySSH.command('echo $USER; nohup sudo tshark -f "host ' + lIpAddr +'" -i ' + eth_interface + ' -w /tmp/' + self.epcPcapFile + ' > /tmp/tshark.log 2>&1 &', localEpcUserName, 5)
mySSH.close()
mySSH.open(lIpAddr, lUserName, lPassWord)
mySSH.command('cd ' + lSourcePath, '\$', 5)
......@@ -520,7 +523,9 @@ class RANManagement():
mySSH.command('echo ' + lPassWord + ' | sudo -S uhd_find_devices', '\$', 60)
# Make a copy and adapt to EPC / eNB IP addresses
mySSH.command('cp ' + full_config_file + ' ' + ci_full_config_file, '\$', 5)
mySSH.command('sed -i -e \'s/CI_MME_IP_ADDR/' + self.EPCIPAddress + '/\' ' + ci_full_config_file, '\$', 2);
if self.epcObj is not None:
localEpcIpAddr = self.epcObj.GetIPAddress()
mySSH.command('sed -i -e \'s/CI_MME_IP_ADDR/' + localEpcIpAddr + '/\' ' + ci_full_config_file, '\$', 2);
mySSH.command('sed -i -e \'s/CI_ENB_IP_ADDR/' + lIpAddr + '/\' ' + ci_full_config_file, '\$', 2);
mySSH.command('sed -i -e \'s/CI_RCC_IP_ADDR/' + self.eNBIPAddress + '/\' ' + ci_full_config_file, '\$', 2);
mySSH.command('sed -i -e \'s/CI_RRU1_IP_ADDR/' + self.eNB1IPAddress + '/\' ' + ci_full_config_file, '\$', 2);
......@@ -569,22 +574,26 @@ class RANManagement():
mySSH.close()
doLoop = False
logging.error('\u001B[1;37;41m eNB logging system did not show got sync! \u001B[0m')
myHTML.CreateHtmlTestRow('-O ' + config_file + extra_options, 'KO', CONST.ALL_PROCESSES_OK)
if self.htmlObj is not None:
self.htmlObj.CreateHtmlTestRow('-O ' + config_file + extra_options, 'KO', CONST.ALL_PROCESSES_OK)
# In case of T tracer recording, we need to kill tshark on EPC side
result = re.search('T_stdout', str(self.Initialize_eNB_args))
if result is not None:
mySSH.open(self.EPCIPAddress, self.EPCUserName, self.EPCPassword)
if (result is not None) and (self.epcObj is not None):
localEpcIpAddr = self.epcObj.GetIPAddress()
localEpcUserName = self.epcObj.GetUserName()
localEpcPassword = self.epcObj.GetPassword()
mySSH.open(localEpcIpAddr, localEpcUserName, localEpcPassword)
logging.debug('\u001B[1m Stopping tshark \u001B[0m')
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S killall --signal SIGKILL tshark', '\$', 5)
if EPC.Get_PcapFileName() != '':
mySSH.command('echo ' + localEpcPassword + ' | sudo -S killall --signal SIGKILL tshark', '\$', 5)
if self.epcPcapFile != '':
time.sleep(0.5)
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S chmod 666 /tmp/' + EPC.Get_PcapFileName() , '\$', 5)
mySSH.command('echo ' + localEpcPassword + ' | sudo -S chmod 666 /tmp/' + self.epcPcapFile, '\$', 5)
mySSH.close()
time.sleep(1)
if EPC.Get_PcapFileName() != '':
copyin_res = mySSH.copyin(self.EPCIPAddress, self.EPCUserName, self.EPCPassword, '/tmp/' + EPC.Get_PcapFileName() , '.')
if self.epcPcapFile != '':
copyin_res = mySSH.copyin(localEpcIpAddr, localEpcUserName, localEpcPassword, '/tmp/' + self.epcPcapFile, '.')
if (copyin_res == 0):
mySSH.copyout(lIpAddr, lUserName, lPassWord, EPC.Get_PcapFileName() , lSourcePath + '/cmake_targets/.')
mySSH.copyout(lIpAddr, lUserName, lPassWord, self.epcPcapFile, lSourcePath + '/cmake_targets/.')
self.prematureExit = True
return
else:
......@@ -619,7 +628,8 @@ class RANManagement():
self.eNBstatuses[int(self.eNB_instance)] = int(self.eNB_serverId)
mySSH.close()
myHTML.CreateHtmlTestRow('-O ' + config_file + extra_options, 'OK', CONST.ALL_PROCESSES_OK)
if self.htmlObj is not None:
self.htmlObj.CreateHtmlTestRow('-O ' + config_file + extra_options, 'OK', CONST.ALL_PROCESSES_OK)
logging.debug('\u001B[1m Initialize eNB Completed\u001B[0m')
......@@ -659,7 +669,6 @@ class RANManagement():
def TerminateeNB(self):
myHTML = HTML.HTMLManagement()
if self.eNB_serverId == '0':
lIpAddr = self.eNBIPAddress
lUserName = self.eNBUserName
......@@ -700,15 +709,18 @@ class RANManagement():
mySSH.close()
# If tracer options is on, stopping tshark on EPC side
result = re.search('T_stdout', str(self.Initialize_eNB_args))
if result is not None:
mySSH.open(self.EPCIPAddress, self.EPCUserName, self.EPCPassword)
if (result is not None) and (self.epcObj is not None):
localEpcIpAddr = self.epcObj.GetIPAddress()
localEpcUserName = self.epcObj.GetUserName()
localEpcPassword = self.epcObj.GetPassword()
mySSH.open(localEpcIpAddr, localEpcUserName, localEpcPassword)
logging.debug('\u001B[1m Stopping tshark \u001B[0m')
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S killall --signal SIGKILL tshark', '\$', 5)
mySSH.command('echo ' + localEpcPassword + ' | sudo -S killall --signal SIGKILL tshark', '\$', 5)
time.sleep(1)
if EPC.Get_PcapFileName() != '':
mySSH.command('echo ' + self.EPCPassword + ' | sudo -S chmod 666 /tmp/' + EPC.Get_PcapFileName() , '\$', 5)
mySSH.copyin(self.EPCIPAddress, self.EPCUserName, self.EPCPassword, '/tmp/' + EPC.Get_PcapFileName() , '.')
mySSH.copyout(lIpAddr, lUserName, lPassWord, EPC.Get_PcapFileName() , lSourcePath + '/cmake_targets/.')
if self.epcPcapFile != '':
mySSH.command('echo ' + localEpcPassword + ' | sudo -S chmod 666 /tmp/' + self.epcPcapFile, '\$', 5)
mySSH.copyin(localEpcIpAddr, localEpcUserName, localEpcPassword, '/tmp/' + self.epcPcapFile, '.')
mySSH.copyout(lIpAddr, lUserName, lPassWord, self.epcPcapFile, lSourcePath + '/cmake_targets/.')
mySSH.close()
logging.debug('\u001B[1m Replaying RAW record file\u001B[0m')
mySSH.open(lIpAddr, lUserName, lPassWord)
......@@ -725,7 +737,8 @@ class RANManagement():
mySSH.copyin(lIpAddr, lUserName, lPassWord, lSourcePath + '/cmake_targets/' + extracted_log_file, '.')
logging.debug('\u001B[1m Analyzing eNB replay logfile \u001B[0m')
logStatus = self.AnalyzeLogFile_eNB(extracted_log_file)
myHTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK)
if self.htmlObj is not None:
self.htmlObj.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK)
self.eNBLogFiles[int(self.eNB_instance)] = ''
else:
analyzeFile = False
......@@ -738,7 +751,8 @@ class RANManagement():
if (copyin_res == -1):
logging.debug('\u001B[1;37;41m Could not copy ' + nodeB_prefix + 'NB logfile to analyze it! \u001B[0m')
self.htmleNBFailureMsg = 'Could not copy ' + nodeB_prefix + 'NB logfile to analyze it!'
myHTML.CreateHtmlTestRow('N/A', 'KO', CONST.ENB_PROCESS_NOLOGFILE_TO_ANALYZE)
if self.htmlObj is not None:
self.htmlObj.CreateHtmlTestRow('N/A', 'KO', CONST.ENB_PROCESS_NOLOGFILE_TO_ANALYZE)
self.eNBmbmsEnables[int(self.eNB_instance)] = False
return
if self.eNB_serverId != '0':
......@@ -746,14 +760,17 @@ class RANManagement():
logging.debug('\u001B[1m Analyzing ' + nodeB_prefix + 'NB logfile \u001B[0m ' + fileToAnalyze)
logStatus = self.AnalyzeLogFile_eNB(fileToAnalyze)
if (logStatus < 0):
myHTML.CreateHtmlTestRow('N/A', 'KO', logStatus)
if self.htmlObj is not None:
self.htmlObj.CreateHtmlTestRow('N/A', 'KO', logStatus)
self.preamtureExit = True
self.eNBmbmsEnables[int(self.eNB_instance)] = False
return
else:
myHTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK)
if self.htmlObj is not None:
self.htmlObj.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK)
else:
myHTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK)
if self.htmlObj is not None:
self.htmlObj.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK)
self.eNBmbmsEnables[int(self.eNB_instance)] = False
self.eNBstatuses[int(self.eNB_instance)] = -1
......
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