Commit d7d85ff9 authored by Jaroslava Fiedlerova's avatar Jaroslava Fiedlerova

Remove unused iperf test and analysis functions

- Remove IperfFromContainer
- Remove unused functions IperfExit and PingExit
- Remove unused function for iperf analysis
parent 08f0040a
......@@ -169,97 +169,6 @@ def AnalyzeBuildLogs(buildRoot, images, globalStatus):
collectInfo[image] = files
return collectInfo
def AnalyzeIperf(cliOptions, clientReport, serverReport):
req_bw = 1.0 # default iperf throughput, in Mbps
result = re.search('-b *(?P<iperf_bandwidth>[0-9\.]+)(?P<magnitude>[kKMG])', cliOptions)
if result is not None:
req_bw = float(result.group('iperf_bandwidth'))
magn = result.group('magnitude')
if magn == "k" or magn == "K":
req_bw /= 1000
elif magn == "G":
req_bw *= 1000
req_dur = 10 # default iperf send duration
result = re.search('-t *(?P<duration>[0-9]+)', cliOptions)
if result is not None:
req_dur = int(result.group('duration'))
reportLine = None
# find server report in client status
clientReportLines = clientReport.split('\n')
for l in range(len(clientReportLines)):
res = re.search('read failed: Connection refused', clientReportLines[l])
if res is not None:
message = 'iperf connection refused by server!'
logging.error(f'\u001B[1;37;41mIperf Test FAIL: {message}\u001B[0m')
return (False, message)
res = re.search('Server Report:', clientReportLines[l])
if res is not None and l + 1 < len(clientReportLines):
reportLine = clientReportLines[l+1]
logging.debug(f'found server report: "{reportLine}"')
statusTemplate = '(?:|\[ *\d+\].*) +0\.0-\s*(?P<duration>[0-9\.]+) +sec +[0-9\.]+ [kKMG]Bytes +(?P<bitrate>[0-9\.]+) (?P<magnitude>[kKMG])bits\/sec +(?P<jitter>[0-9\.]+) ms +(\d+\/ *\d+) +(\((?P<packetloss>[0-9\.]+)%\))'
# if we do not find a server report in the client logs, check the server logs
# and use the last line which is typically close/identical to server report
if reportLine is None:
for l in serverReport.split('\n'):
res = re.search(statusTemplate, l)
if res is not None:
reportLine = l
if reportLine is None:
logging.warning('no report in server status found!')
return (False, 'could not parse iperf logs')
logging.debug(f'found client status: {reportLine}')
result = re.search(statusTemplate, reportLine)
if result is None:
logging.error('could not analyze report from statusTemplate')
return (False, 'could not parse iperf logs')
duration = float(result.group('duration'))
bitrate = float(result.group('bitrate'))
magn = result.group('magnitude')
if magn == "k" or magn == "K":
bitrate /= 1000
elif magn == "G": # we assume bitrate in Mbps, therefore it must be G now
bitrate *= 1000
jitter = float(result.group('jitter'))
packetloss = float(result.group('packetloss'))
logging.debug('\u001B[1;37;44m iperf result \u001B[0m')
msg = f'Req Bitrate: {req_bw}'
logging.debug(f'\u001B[1;34m{msg}\u001B[0m')
br_loss = bitrate/req_bw
bmsg = f'Bitrate : {bitrate} (perf {br_loss})'
logging.debug(f'\u001B[1;34m{bmsg}\u001B[0m')
msg += '\n' + bmsg
if br_loss < 0.9:
msg += '\nBitrate performance too low (<90%)'
logging.debug(f'\u001B[1;37;41mBitrate performance too low (<90%)\u001B[0m')
return (False, msg)
plmsg = f'Packet Loss: {packetloss}%'
logging.debug(f'\u001B[1;34m{plmsg}\u001B[0m')
msg += '\n' + plmsg
if packetloss > 5.0:
msg += '\nPacket Loss too high!'
logging.debug(f'\u001B[1;37;41mPacket Loss too high \u001B[0m')
return (False, msg)
dmsg = f'Duration : {duration} (req {req_dur})'
logging.debug(f'\u001B[1;34m{dmsg}\u001B[0m')
msg += '\n' + dmsg
if duration < float(req_dur):
msg += '\nDuration of iperf too short!'
logging.debug(f'\u001B[1;37;41mDuration of iperf too short\u001B[0m')
return (False, msg)
jmsg = f'Jitter : {jitter}'
logging.debug(f'\u001B[1;34m{jmsg}\u001B[0m')
msg += '\n' + jmsg
return (True, msg)
#-----------------------------------------------------------
# Class Declaration
#-----------------------------------------------------------
......@@ -1466,76 +1375,6 @@ class Containerize():
HTML.CreateHtmlTestRowQueue(self.pingOptions, 'OK', [message])
def PingExit(self, HTML, RAN, UE, status, message):
if status:
HTML.CreateHtmlTestRowQueue(self.pingOptions, 'OK', [message])
else:
logging.error('\u001B[1;37;41m ping test FAIL -- ' + message + ' \u001B[0m')
HTML.CreateHtmlTestRowQueue(self.pingOptions, 'KO', [message])
# Automatic undeployment
logging.warning('----------------------------------------')
logging.warning('\u001B[1m Starting Automatic undeployment \u001B[0m')
logging.warning('----------------------------------------')
HTML.testCase_id = 'AUTO-UNDEPLOY'
HTML.desc = 'Automatic Un-Deployment'
self.UndeployGenObject(HTML, RAN, UE)
self.exitStatus = 1
def IperfFromContainer(self, HTML, RAN, UE):
myCmd = cls_cmd.LocalCmd()
self.exitStatus = 0
ymlPath = self.yamlPath[0].split('/')
logPath = '../cmake_targets/log/' + ymlPath[1]
cmd = f'mkdir -p {logPath}'
myCmd.run(cmd, silent=True)
# Start the server process
cmd = f'docker exec -d {self.svrContName} /bin/bash -c "nohup iperf {self.svrOptions} > /tmp/iperf_server.log 2>&1"'
myCmd.run(cmd)
time.sleep(3)
# Start the client process
cmd = f'docker exec {self.cliContName} /bin/bash -c "iperf {self.cliOptions}" 2>&1 | tee {logPath}/iperf_client_{HTML.testCase_id}.log'
clientStatus = myCmd.run(cmd, timeout=100)
# Stop the server process
cmd = f'docker exec {self.svrContName} /bin/bash -c "pkill iperf"'
myCmd.run(cmd)
time.sleep(3)
serverStatusFilename = f'{logPath}/iperf_server_{HTML.testCase_id}.log'
cmd = f'docker cp {self.svrContName}:/tmp/iperf_server.log {serverStatusFilename}'
myCmd.run(cmd, timeout=60)
myCmd.close()
# clientStatus was retrieved above. The serverStatus was
# written in the background, then copied to the local machine
with open(serverStatusFilename, 'r') as f:
serverStatus = f.read()
(iperfStatus, msg) = AnalyzeIperf(self.cliOptions, clientStatus.stdout, serverStatus)
if iperfStatus:
logging.info('\u001B[1m Iperf Test PASS\u001B[0m')
else:
logging.error('\u001B[1;37;41m Iperf Test FAIL\u001B[0m')
self.IperfExit(HTML, RAN, UE, iperfStatus, msg)
def IperfExit(self, HTML, RAN, UE, status, message):
html_cell = f'UE\n{message}'
if status:
HTML.CreateHtmlTestRowQueue(self.cliOptions, 'OK', [html_cell])
else:
logging.error('\u001B[1m Iperf Test FAIL -- ' + message + ' \u001B[0m')
HTML.CreateHtmlTestRowQueue(self.cliOptions, 'KO', [html_cell])
# Automatic undeployment
logging.warning('----------------------------------------')
logging.warning('\u001B[1m Starting Automatic undeployment \u001B[0m')
logging.warning('----------------------------------------')
HTML.testCase_id = 'AUTO-UNDEPLOY'
HTML.desc = 'Automatic Un-Deployment'
self.UndeployGenObject(HTML, RAN, UE)
self.exitStatus = 1
def CheckAndAddRoute(self, svrName, ipAddr, userName, password):
logging.debug('Checking IP routing on ' + svrName)
mySSH = SSH.SSHConnection()
......
......@@ -735,221 +735,6 @@ class OaiCiTest():
HTML.CreateHtmlTestRowQueue(self.ping_args, 'KO', messages)
self.AutoTerminateUEandeNB(HTML,RAN,EPC,CONTAINERS)
def Iperf_analyzeV2TCPOutput(self, SSH, filename):
SSH.command(f'awk -f /tmp/tcp_iperf_stats.awk {filename}', '\$', 5)
result = re.search('Avg Bitrate : (?P<average>[0-9\.]+ Mbits\/sec) Max Bitrate : (?P<maximum>[0-9\.]+ Mbits\/sec) Min Bitrate : (?P<minimum>[0-9\.]+ Mbits\/sec)', SSH.getBefore())
if result is not None:
avgbitrate = result.group('average')
maxbitrate = result.group('maximum')
minbitrate = result.group('minimum')
msg = 'TCP Stats :\n'
if avgbitrate is not None:
msg += f'Avg Bitrate : {avgbitrate} \n'
if maxbitrate is not None:
msg += f'Max Bitrate : {maxbitrate} \n'
if minbitrate is not None:
msg += f'Min Bitrate : {minbitrate} \n'
return (True, msg)
return (False, "could not analyze log file")
def Iperf_analyzeV2Output(self, iperf_real_options, EPC, SSH):
result = re.search('-u', str(iperf_real_options))
if result is None:
filename = f'{EPC.SourceCodePath}/scripts/iperf_{self.testCase_id}_{device_id}.log'
response = self.Iperf_analyzeV2TCPOutput(SSH, filename)
return response
result = re.search('Server Report:', SSH.getBefore())
if result is None:
result = re.search('read failed: Connection refused', SSH.getBefore())
if result is not None:
msg = 'Could not connect to iperf server!'
return (False, msg)
else:
msg = 'Server Report and Connection refused Not Found!'
return (False, msg)
# Computing the requested bandwidth in float
result = re.search('-b (?P<iperf_bandwidth>[0-9\.]+)[KMG]', str(iperf_real_options))
if result is not None:
req_bandwidth = result.group('iperf_bandwidth')
req_bw = float(req_bandwidth)
result = re.search('-b [0-9\.]+K', str(iperf_real_options))
if result is not None:
req_bandwidth = '%.1f Kbits/sec' % req_bw
req_bw = req_bw * 1000
result = re.search('-b [0-9\.]+M', str(iperf_real_options))
if result is not None:
req_bandwidth = '%.1f Mbits/sec' % req_bw
req_bw = req_bw * 1000000
result = re.search('-b [0-9\.]+G', str(iperf_real_options))
if result is not None:
req_bandwidth = '%.1f Gbits/sec' % req_bw
req_bw = req_bw * 1000000000
result = re.search('Server Report:\r\n(?:|\[ *\d+\].*) (?P<bitrate>[0-9\.]+ [KMG]bits\/sec) +(?P<jitter>[0-9\.]+ ms) +(\d+\/..\d+) +(\((?P<packetloss>[0-9\.]+)%\))', SSH.getBefore())
if result is not None:
bitrate = result.group('bitrate')
packetloss = result.group('packetloss')
jitter = result.group('jitter')
iperfStatus = True
msg = f'Req Bitrate : {req_bandwidth} \n'
if bitrate is not None:
msg += f'Bitrate : {bitrate} \n'
result = re.search('(?P<real_bw>[0-9\.]+) [KMG]bits/sec', str(bitrate))
if result is not None:
actual_bw = float(str(result.group('real_bw')))
result = re.search('[0-9\.]+ K', bitrate)
if result is not None:
actual_bw = actual_bw * 1000
result = re.search('[0-9\.]+ M', bitrate)
if result is not None:
actual_bw = actual_bw * 1000000
result = re.search('[0-9\.]+ G', bitrate)
if result is not None:
actual_bw = actual_bw * 1000000000
br_loss = 100 * actual_bw / req_bw
bitperf = '%.2f ' % br_loss
msg += f'Bitrate Perf: {bitperf} %\n'
if packetloss is not None:
msg += f'Packet Loss : {packetloss} %\n'
if float(packetloss) > float(self.iperf_packetloss_threshold):
msg += 'Packet Loss too high!\n'
iperfStatus = False
if jitter is not None:
msg += f'Jitter : {jitter} \n'
return (iperfStatus, msg)
else:
return (False, "could not analyze server log")
def Iperf_analyzeV2BIDIR(self, server_filename, client_filename):
#check the 2 files are here
if (not os.path.isfile(client_filename)) or (not os.path.isfile(server_filename)):
return (False, 'Bidir TCP: Client or Server Log File not present')
#check the 2 files size
if (os.path.getsize(client_filename)==0) and (os.path.getsize(server_filename)==0):
return (False, 'Bidir TCP: Client and Server Log File are empty')
report_msg = ''
#if client is not empty, all the info is in, otherwise we ll use the server file to get some partial info
client_filesize = os.path.getsize(client_filename)
if client_filesize == 0:
report_msg+="Client file (UE) present but !!! EMPTY !!!\n"
report_msg+="Partial report from server file"
filename = server_filename
else :
report_msg+="Report from client file (UE)"
filename = client_filename
report=[] #used to check if relevant lines were found
with open(filename, 'r') as f_client:
for line in f_client.readlines():
result = re.search(rf'^\[\s+\d+\](?P<direction>\[.+\]).*\s+(?P<bitrate>[0-9\.]+ [KMG]bits\/sec).*\s+(?P<role>\bsender|receiver\b)', str(line))
if result is not None:
report.append(str(line))
report_msg += f"\n{result.group('role')} {result.group('direction')}\t: {result.group('bitrate')}"
if len(report) == 0:
return (False, 'Bidir TCP: Could not analyze from Log file')
return (True, report_msg)
def Iperf_analyzeV2Server(self, iperf_real_options, filename, type):
if (not os.path.isfile(filename)):
return (False, 'Could not analyze from server log')
# Computing the requested bandwidth in float
result = re.search('-b (?P<iperf_bandwidth>[0-9\.]+)[KMG]', str(iperf_real_options))
if result is None:
return (False, 'Could not compute Iperf bandwidth!')
else:
req_bandwidth = result.group('iperf_bandwidth')
req_bw = float(req_bandwidth)
result = re.search('-b [0-9\.]+K', str(iperf_real_options))
if result is not None:
req_bandwidth = '%.1f Kbits/sec' % req_bw
req_bw = req_bw * 1000
result = re.search('-b [0-9\.]+M', str(iperf_real_options))
if result is not None:
req_bandwidth = '%.1f Mbits/sec' % req_bw
req_bw = req_bw * 1000000
result = re.search('-b [0-9\.]+G', str(iperf_real_options))
if result is not None:
req_bandwidth = '%.1f Gbits/sec' % req_bw
req_bw = req_bw * 1000000000
server_file = open(filename, 'r')
br_sum = 0.0
ji_sum = 0.0
pl_sum = 0
ps_sum = 0
row_idx = 0
for line in server_file.readlines():
if type==0:
result = re.search('(?P<bitrate>[0-9\.]+ [KMG]bits\/sec) +(?P<jitter>[0-9\.]+ ms) +(?P<lostPack>[0-9]+)/ +(?P<sentPack>[0-9]+)', str(line))
else:
result = re.search('^\[\s+\d\].+ (?P<bitrate>[0-9\.]+ [KMG]bits\/sec) +(?P<jitter>[0-9\.]+ ms) +(?P<lostPack>[0-9]+)\/\s*(?P<sentPack>[0-9]+)', str(line))
if result is not None:
bitrate = result.group('bitrate')
jitter = result.group('jitter')
packetlost = result.group('lostPack')
packetsent = result.group('sentPack')
br = bitrate.split(' ')
ji = jitter.split(' ')
row_idx = row_idx + 1
curr_br = float(br[0])
pl_sum = pl_sum + int(packetlost)
ps_sum = ps_sum + int(packetsent)
if (br[1] == 'Kbits/sec'):
curr_br = curr_br * 1000
if (br[1] == 'Mbits/sec'):
curr_br = curr_br * 1000 * 1000
br_sum = curr_br + br_sum
ji_sum = float(ji[0]) + ji_sum
server_file.close()
if (row_idx > 0):
br_sum = br_sum / row_idx
ji_sum = ji_sum / row_idx
br_loss = 100 * br_sum / req_bw
if (br_sum > 1000):
br_sum = br_sum / 1000
if (br_sum > 1000):
br_sum = br_sum / 1000
bitrate = '%.2f Mbits/sec' % br_sum
else:
bitrate = '%.2f Kbits/sec' % br_sum
else:
bitrate = '%.2f bits/sec' % br_sum
bitperf = '%.2f ' % br_loss
bitperf += '%'
jitter = '%.2f ms' % (ji_sum)
if (ps_sum > 0):
pl = float(100 * pl_sum / ps_sum)
packetloss = '%2.1f ' % (pl)
packetloss += '%'
result = float(br_loss) >= float(self.iperf_bitrate_threshold) and float(pl) <= float(self.iperf_packetloss_threshold)
req_msg = f'Req Bitrate : {req_bandwidth}'
bir_msg = f'Bitrate : {bitrate}'
brl_msg = f'Bitrate Perf: {bitperf}'
if float(br_loss) < float(self.iperf_bitrate_threshold):
brl_msg += f' (too low! <{self.iperf_bitrate_threshold}%)'
jit_msg = f'Jitter : {jitter}'
pal_msg = f'Packet Loss : {packetloss}'
if float(pl) > float(self.iperf_packetloss_threshold):
pal_msg += f' (too high! >{self.iperf_packetloss_threshold}%)'
return (result, f'{req_msg}\n{bir_msg}\n{brl_msg}\n{jit_msg}\n{pal_msg}')
else:
return (False, 'Could not analyze from server log')
def Iperf_Module(self, EPC, ue, svr, RAN, idx, ue_num, CONTAINERS):
ueIP = ue.getIP()
if not ueIP:
......
......@@ -376,20 +376,6 @@ def GetParametersFromXML(action):
if (string_field is not None):
CONTAINERS.ran_checkers['u_retx_th'] = [float(x) for x in string_field.split(',')]
elif action == 'IperfFromContainer':
string_field = test.findtext('server_container_name')
if (string_field is not None):
CONTAINERS.svrContName = string_field
string_field = test.findtext('server_options')
if (string_field is not None):
CONTAINERS.svrOptions = string_field
string_field = test.findtext('client_container_name')
if (string_field is not None):
CONTAINERS.cliContName = string_field
string_field = test.findtext('client_options')
if (string_field is not None):
CONTAINERS.cliOptions = string_field
elif action == 'Run_LDPCTest' or action == 'Run_NRulsimTest' or action == 'Run_LDPCt1Test':
ldpc.runargs = test.findtext('physim_run_args')
......
......@@ -41,7 +41,6 @@
- Deploy_Run_PhySim
- DeployGenObject
- UndeployGenObject
- IperfFromContainer
- StatsFromGenObject
- LicenceAndFormattingCheck
- Push_Local_Registry
......
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