Commit 2668cfd8 authored by Gabriele Perrone's avatar Gabriele Perrone

introduced a class object FailRepeatCnt in place of a static counter

parent a90814b9
...@@ -93,7 +93,7 @@ logging.basicConfig( ...@@ -93,7 +93,7 @@ logging.basicConfig(
#----------------------------------------------------------- #-----------------------------------------------------------
class SSHConnection(): class SSHConnection():
def __init__(self): def __init__(self):
self.cnt = 0 # cnt from index to object of a class self.FailReportCnt = 0 # FailReportCnt was an index inside the SSH instantiation (called "cnt"), now it becomes an object
self.prematureExit = False self.prematureExit = False
self.ranRepository = '' self.ranRepository = ''
self.ranBranch = '' self.ranBranch = ''
...@@ -1433,11 +1433,11 @@ class SSHConnection(): ...@@ -1433,11 +1433,11 @@ class SSHConnection():
html_queue.put(html_cell) html_queue.put(html_cell)
if (attach_status): if (attach_status):
# cnt from index to object of a class # cnt from index to object of a class
self.cnt = 0 cnt = 0
while self.cnt < len(self.UEDevices): while cnt < len(self.UEDevices):
if self.UEDevicesStatus[self.cnt] == UE_STATUS_ATTACHING: if self.UEDevicesStatus[cnt] == UE_STATUS_ATTACHING:
self.UEDevicesStatus[self.cnt] = UE_STATUS_ATTACHED self.UEDevicesStatus[cnt] = UE_STATUS_ATTACHED
self.cnt += 1 cnt += 1
self.CreateHtmlTestRowQueue('N/A', 'OK', len(self.UEDevices), html_queue) self.CreateHtmlTestRowQueue('N/A', 'OK', len(self.UEDevices), html_queue)
result = re.search('T_stdout', str(self.Initialize_eNB_args)) result = re.search('T_stdout', str(self.Initialize_eNB_args))
if result is not None: if result is not None:
...@@ -1474,14 +1474,14 @@ class SSHConnection(): ...@@ -1474,14 +1474,14 @@ class SSHConnection():
self.AutoTerminateUEandeNB() self.AutoTerminateUEandeNB()
return return
multi_jobs = [] multi_jobs = []
self.cnt = 0 cnt = 0
for device_id in self.UEDevices: for device_id in self.UEDevices:
self.UEDevicesStatus[self.cnt] = UE_STATUS_DETACHING self.UEDevicesStatus[cnt] = UE_STATUS_DETACHING
p = Process(target = self.DetachUE_common, args = (device_id,self.cnt,)) p = Process(target = self.DetachUE_common, args = (device_id,cnt,))
p.daemon = True p.daemon = True
p.start() p.start()
multi_jobs.append(p) multi_jobs.append(p)
self.cnt += 1 cnt += 1
for job in multi_jobs: for job in multi_jobs:
job.join() job.join()
self.CreateHtmlTestRow('N/A', 'OK', ALL_PROCESSES_OK) self.CreateHtmlTestRow('N/A', 'OK', ALL_PROCESSES_OK)
...@@ -1489,10 +1489,10 @@ class SSHConnection(): ...@@ -1489,10 +1489,10 @@ class SSHConnection():
if result is not None: if result is not None:
logging.debug('Waiting 5 seconds to fill up record file') logging.debug('Waiting 5 seconds to fill up record file')
time.sleep(5) time.sleep(5)
self.cnt = 0 cnt = 0
while self.cnt < len(self.UEDevices): while cnt < len(self.UEDevices):
self.UEDevicesStatus[self.cnt] = UE_STATUS_DETACHED self.UEDevicesStatus[cnt] = UE_STATUS_DETACHED
self.cnt += 1 cnt += 1
def RebootUE_common(self, device_id): def RebootUE_common(self, device_id):
try: try:
...@@ -1650,10 +1650,10 @@ class SSHConnection(): ...@@ -1650,10 +1650,10 @@ class SSHConnection():
logging.debug('\u001B[1;37;41m UE Not Found! \u001B[0m') logging.debug('\u001B[1;37;41m UE Not Found! \u001B[0m')
sys.exit(1) sys.exit(1)
if len(self.UEDevicesStatus) == 0: if len(self.UEDevicesStatus) == 0:
self.cnt = 0 cnt = 0
while self.cnt < len(self.UEDevices): while cnt < len(self.UEDevices):
self.UEDevicesStatus.append(UE_STATUS_DETACHED) self.UEDevicesStatus.append(UE_STATUS_DETACHED)
self.cnt += 1 cnt += 1
def GetAllCatMDevices(self, terminate_ue_flag): def GetAllCatMDevices(self, terminate_ue_flag):
if self.ADBIPAddress == '' or self.ADBUserName == '' or self.ADBPassword == '': if self.ADBIPAddress == '' or self.ADBUserName == '' or self.ADBPassword == '':
...@@ -3735,38 +3735,38 @@ class SSHConnection(): ...@@ -3735,38 +3735,38 @@ class SSHConnection():
cmd = "jq '.mac_stats | length' " + fileName cmd = "jq '.mac_stats | length' " + fileName
strNbEnbs = subprocess.check_output(cmd, shell=True, universal_newlines=True) strNbEnbs = subprocess.check_output(cmd, shell=True, universal_newlines=True)
self.x2NbENBs = int(strNbEnbs.strip()) self.x2NbENBs = int(strNbEnbs.strip())
self.cnt = 0 cnt = 0
while self.cnt < self.x2NbENBs: while cnt < self.x2NbENBs:
cmd = "jq '.mac_stats[" + str(self.cnt) + "].bs_id' " + fileName cmd = "jq '.mac_stats[" + str(cnt) + "].bs_id' " + fileName
bs_id = subprocess.check_output(cmd, shell=True, universal_newlines=True) bs_id = subprocess.check_output(cmd, shell=True, universal_newlines=True)
self.x2ENBBsIds[idx].append(bs_id.strip()) self.x2ENBBsIds[idx].append(bs_id.strip())
cmd = "jq '.mac_stats[" + str(self.cnt) + "].ue_mac_stats | length' " + fileName cmd = "jq '.mac_stats[" + str(cnt) + "].ue_mac_stats | length' " + fileName
stNbUEs = subprocess.check_output(cmd, shell=True, universal_newlines=True) stNbUEs = subprocess.check_output(cmd, shell=True, universal_newlines=True)
nbUEs = int(stNbUEs.strip()) nbUEs = int(stNbUEs.strip())
ueIdx = 0 ueIdx = 0
self.x2ENBConnectedUEs[idx].append([]) self.x2ENBConnectedUEs[idx].append([])
while ueIdx < nbUEs: while ueIdx < nbUEs:
cmd = "jq '.mac_stats[" + str(self.cnt) + "].ue_mac_stats[" + str(ueIdx) + "].rnti' " + fileName cmd = "jq '.mac_stats[" + str(cnt) + "].ue_mac_stats[" + str(ueIdx) + "].rnti' " + fileName
rnti = subprocess.check_output(cmd, shell=True, universal_newlines=True) rnti = subprocess.check_output(cmd, shell=True, universal_newlines=True)
self.x2ENBConnectedUEs[idx][self.cnt].append(rnti.strip()) self.x2ENBConnectedUEs[idx][cnt].append(rnti.strip())
ueIdx += 1 ueIdx += 1
self.cnt += 1 cnt += 1
msg = "FlexRan Controller is connected to " + str(self.x2NbENBs) + " eNB(s)" msg = "FlexRan Controller is connected to " + str(self.x2NbENBs) + " eNB(s)"
logging.debug(msg) logging.debug(msg)
message += msg + '\n' message += msg + '\n'
self.cnt = 0 cnt = 0
while self.cnt < self.x2NbENBs: while cnt < self.x2NbENBs:
msg = " -- eNB: " + str(self.x2ENBBsIds[idx][self.cnt]) + " is connected to " + str(len(self.x2ENBConnectedUEs[idx][self.cnt])) + " UE(s)" msg = " -- eNB: " + str(self.x2ENBBsIds[idx][cnt]) + " is connected to " + str(len(self.x2ENBConnectedUEs[idx][self.cnt])) + " UE(s)"
logging.debug(msg) logging.debug(msg)
message += msg + '\n' message += msg + '\n'
ueIdx = 0 ueIdx = 0
while ueIdx < len(self.x2ENBConnectedUEs[idx][self.cnt]): while ueIdx < len(self.x2ENBConnectedUEs[idx][cnt]):
msg = " -- UE rnti: " + str(self.x2ENBConnectedUEs[idx][self.cnt][ueIdx]) msg = " -- UE rnti: " + str(self.x2ENBConnectedUEs[idx][cnt][ueIdx])
logging.debug(msg) logging.debug(msg)
message += msg + '\n' message += msg + '\n'
ueIdx += 1 ueIdx += 1
self.cnt += 1 cnt += 1
return message return message
def Perform_X2_Handover(self): def Perform_X2_Handover(self):
...@@ -3789,38 +3789,38 @@ class SSHConnection(): ...@@ -3789,38 +3789,38 @@ class SSHConnection():
logging.debug(msg) logging.debug(msg)
fullMessage += msg + '\n' fullMessage += msg + '\n'
eNB_cnt = self.x2NbENBs eNB_cnt = self.x2NbENBs
self.cnt = 0 cnt = 0
while self.cnt < eNB_cnt: while cnt < eNB_cnt:
cmd = "curl -XPOST http://" + self.EPCIPAddress + ":9999/rrc/x2_ho_net_control/enb/" + str(self.x2ENBBsIds[0][self.cnt]) + "/1" cmd = "curl -XPOST http://" + self.EPCIPAddress + ":9999/rrc/x2_ho_net_control/enb/" + str(self.x2ENBBsIds[0][cnt]) + "/1"
logging.debug(cmd) logging.debug(cmd)
fullMessage += cmd + '\n' fullMessage += cmd + '\n'
subprocess.run(cmd, shell=True) subprocess.run(cmd, shell=True)
self.cnt += 1 cnt += 1
# Waiting for the activation to be active # Waiting for the activation to be active
time.sleep(10) time.sleep(10)
msg = "Switching UE(s) from eNB to eNB" msg = "Switching UE(s) from eNB to eNB"
logging.debug(msg) logging.debug(msg)
fullMessage += msg + '\n' fullMessage += msg + '\n'
self.cnt = 0 cnt = 0
while self.cnt < eNB_cnt: while cnt < eNB_cnt:
ueIdx = 0 ueIdx = 0
while ueIdx < len(self.x2ENBConnectedUEs[0][self.cnt]): while ueIdx < len(self.x2ENBConnectedUEs[0][cnt]):
cmd = "curl -XPOST http://" + self.EPCIPAddress + ":9999/rrc/ho/senb/" + str(self.x2ENBBsIds[0][self.cnt]) + "/ue/" + str(self.x2ENBConnectedUEs[0][cnt][ueIdx]) + "/tenb/" + str(self.x2ENBBsIds[0][eNB_cnt - cnt - 1]) cmd = "curl -XPOST http://" + self.EPCIPAddress + ":9999/rrc/ho/senb/" + str(self.x2ENBBsIds[0][cnt]) + "/ue/" + str(self.x2ENBConnectedUEs[0][cnt][ueIdx]) + "/tenb/" + str(self.x2ENBBsIds[0][eNB_cnt - cnt - 1])
logging.debug(cmd) logging.debug(cmd)
fullMessage += cmd + '\n' fullMessage += cmd + '\n'
subprocess.run(cmd, shell=True) subprocess.run(cmd, shell=True)
ueIdx += 1 ueIdx += 1
self.cnt += 1 cnt += 1
time.sleep(10) time.sleep(10)
# check # check
logging.debug("Checking the Status after X2 Handover") logging.debug("Checking the Status after X2 Handover")
fullMessage += self.X2_Status(1, self.testCase_id + '_post_ho.json') fullMessage += self.X2_Status(1, self.testCase_id + '_post_ho.json')
self.cnt = 0 cnt = 0
x2Status = True x2Status = True
while self.cnt < eNB_cnt: while cnt < eNB_cnt:
if len(self.x2ENBConnectedUEs[0][self.cnt]) == len(self.x2ENBConnectedUEs[1][cnt]): if len(self.x2ENBConnectedUEs[0][cnt]) == len(self.x2ENBConnectedUEs[1][cnt]):
x2Status = False x2Status = False
self.cnt += 1 cnt += 1
if x2Status: if x2Status:
msg = "X2 Handover was successful" msg = "X2 Handover was successful"
logging.debug(msg) logging.debug(msg)
...@@ -4816,10 +4816,10 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re ...@@ -4816,10 +4816,10 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re
SSH.CreateHtmlTabHeader() SSH.CreateHtmlTabHeader()
SSH.cnt = 0 SSH.FailReportCnt = 0
SSH.prematureExit = True SSH.prematureExit = True
SSH.startTime = int(round(time.time() * 1000)) SSH.startTime = int(round(time.time() * 1000))
while SSH.cnt < SSH.repeatCounts[0] and SSH.prematureExit: while SSH.FailReportCnt < SSH.repeatCounts[0] and SSH.prematureExit:
SSH.prematureExit = False SSH.prematureExit = False
for test_case_id in todo_tests: for test_case_id in todo_tests:
if SSH.prematureExit: if SSH.prematureExit:
...@@ -4907,13 +4907,13 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re ...@@ -4907,13 +4907,13 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re
SSH.Perform_X2_Handover() SSH.Perform_X2_Handover()
else: else:
sys.exit('Invalid action') sys.exit('Invalid action')
SSH.cnt += 1 SSH.FailReportCnt += 1
if SSH.cnt == SSH.repeatCounts[0] and SSH.prematureExit: if SSH.FailReportCnt == SSH.repeatCounts[0] and SSH.prematureExit:
logging.debug('Testsuite failed ' + str(SSH.cnt) + ' time(s)') logging.debug('Testsuite failed ' + str(SSH.FailReportCnt) + ' time(s)')
SSH.CreateHtmlTabFooter(False) SSH.CreateHtmlTabFooter(False)
sys.exit('Failed Scenario') sys.exit('Failed Scenario')
else: else:
logging.info('Testsuite passed after ' + str(SSH.cnt) + ' time(s)') logging.info('Testsuite passed after ' + str(SSH.FailReportCnt) + ' time(s)')
SSH.CreateHtmlTabFooter(True) SSH.CreateHtmlTabFooter(True)
else: else:
Usage() Usage()
......
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