[GITLAB] - A technical upgrade is planned on Thursday the 1st of July at noon on our GITLAB server.

Commit 8031eaa0 authored by Rohit Gupta's avatar Rohit Gupta

[Gitlab-CI]: Merge from Enhancement-142-OAI_UE_autotest_framework

parent 057de071
#! /usr/bin/python
#******************************************************************************
#
# \file autotest_analyser.py
#
# \par Informations
# - \b Project : UED Autotest Framework
# - \b Software :
#
# \date 16 september 2016
#
# \version 0.1
#
# \brief helper to test lib_autotest_analyser.py
#
# \author Benoit ROBERT (benoit.robert@syrtem.com)
#
# \par Statement of Ownership
# COPYRIGHT (c) 2016 BY SYRTEM S.A.R.L
# This software is furnished under license and may be used and copied
# only in accordance with the terms of such license and with the inclusion
# of the above COPYRIGHT notice. This SOFTWARE or any other copies thereof
# may not be provided or otherwise made available to any other person.
# No title to and ownership of the SOFTWARE is hereby transferred.
#
# The information in this SOFTWARE is subject to change without notice
# and should not be constructed as a commitment by SYRTEM.
# SYRTEM assumes no responsibility for the use or reliability of its
# SOFTWARE on equipment or platform not explicitly validated by SYRTEM.
#
# *******************************************************************************
import os
import getopt
import sys
from subprocess import call
#test_cases = ('030001', '030901', '031001', '031601', '031701', '031801', '031901', '032001', '032101', '032201', '032301', '032501', '032601', '032801')
test_cases = ('030030' , '030030' )
nb_run = 3
def error_opt(msg):
print("Option error: " + msg)
def main(args):
try:
analyser = __import__("lib_autotest_analyser")
except ImportError as err:
print('Import error: ' + str(err))
exit(0)
log_path = 'log_save_2016-08-14/log/'
metric = {}
metric['id'] = 'UE_DLSCH_BITRATE'
metric['description'] = 'UE downlink physical throughput'
metric['regex'] = '(UE_DLSCH_BITRATE) =\s+(\d+\.\d+) kbps.+frame = (\d+)\)'
metric['unit_of_meas'] = 'kbps'
metric['min_limit'] = 14668.8
#report_path = log_path+'/report/'
#os.system(' mkdir -p ' + report_path)
#analyser.create_report_html(report_path)
#return(0)
for test_case in test_cases:
# print test_case
if test_case == '030001':
metric['min_limit'] = 500.0
if test_case == '030901':
metric['min_limit'] = 640.0
if test_case == '031001':
metric['min_limit'] = 3200.0
if test_case == '031601':
metric['min_limit'] = 5920.0
if test_case == '031701':
metric['min_limit'] = 6000.0
if test_case == '031801':
metric['min_limit'] = 6200.0
if test_case == '031901':
metric['min_limit'] = 7000.0
if test_case == '032001':
metric['min_limit'] = 7800.0
if test_case == '032101':
metric['min_limit'] = 8000.0
if test_case == '032201':
metric['min_limit'] = 9000.0
if test_case == '032301':
metric['min_limit'] = 10000.0
if test_case == '032501':
metric['min_limit'] = 11000.0
if test_case == '032601':
metric['min_limit'] = 12000.0
if test_case == '032801':
metric['min_limit'] = 12500.0
if test_case == '035201':
metric['min_limit'] = 14668.8
if test_case == '036001':
metric['min_limit'] = 25363.2
for i in range(0, nb_run):
fname = 'log//'+test_case+'/run_'+str(i)+'/UE_exec_'+str(i)+'_.log'
args = {'metric' : metric,
'file' : fname }
cell_synch_status = analyser.check_cell_synchro(fname)
if cell_synch_status == 'CELL_SYNCH':
print '!!!!!!!!!!!!!! Cell synchronized !!!!!!!!!!!'
metric_checks_flag = 0
else :
print '!!!!!!!!!!!!!! Cell NOT NOT synchronized !!!!!!!!!!!'
# metric_extracted = analyser.do_extract_metrics(args)
# print "min = "+ str( metric_extracted['metric_min'] )
# print "min_index = "+ str( metric_extracted['metric_min_index'] )
# print "max = "+ str( metric_extracted['metric_max'] )
# print "max_index = "+ str( metric_extracted['metric_max_index'] )
# print "mean = "+ str( metric_extracted['metric_mean'] )
# print "median = "+ str( metric_extracted['metric_median'] )
# verdict = analyser.do_check_verdict(metric, metric_extracted)
# print verdict
# fname= 'report/2016-9-8_toto/'+test_case+'/UE_metric_UE_DLSCH_BITRATE_'+str(i)+'_.png'
# fname= 'report/UE_metric_UE_DLSCH_BITRATE_'+test_case+'_'+str(i)+'.png'
# print fname
# analyser.do_img_metrics(metric, metric_extracted, fname)
# fname = 'log//'+test_case+'/run_'+str(i)+'/UE_traffic_'+str(i)+'_.log'
# args = {'file' : fname }
# traffic_metrics = analyser.do_extract_traffic_metrics(args)
# fname= 'report/iperf_'+test_case+'_'+str(i)+'.png'
# print fname
# analyser.do_img_traffic(traffic_metrics, fname)
if __name__ == "__main__":
main(sys.argv)
#******************************************************************************
#
# \file lib_autotest_analyser.py
#
# \par Informations
# - \b Project : UED Autotest Framework
# - \b Software :
#
# \date 16 september 2016
#
# \version 0.1
#
# \brief library to extract metrics from autotest logs and assign a verdict
#
# \author Benoit ROBERT (benoit.robert@syrtem.com)
#
# \par Statement of Ownership
# COPYRIGHT (c) 2016 BY SYRTEM S.A.R.L
# This software is furnished under license and may be used and copied
# only in accordance with the terms of such license and with the inclusion
# of the above COPYRIGHT notice. This SOFTWARE or any other copies thereof
# may not be provided or otherwise made available to any other person.
# No title to and ownership of the SOFTWARE is hereby transferred.
#
# The information in this SOFTWARE is subject to change without notice
# and should not be constructed as a commitment by SYRTEM.
# SYRTEM assumes no responsibility for the use or reliability of its
# SOFTWARE on equipment or platform not explicitly validated by SYRTEM.
#
# *******************************************************************************
import re
from pylab import *
from matplotlib.font_manager import FontProperties
import os
from jinja2 import Environment, FileSystemLoader
PATH = os.path.dirname(os.path.abspath(__file__))
TEMPLATE_ENVIRONMENT = Environment(
autoescape=False,
loader=FileSystemLoader(os.path.join(PATH, 'templates')),
trim_blocks=False)
def render_template(template_filename, context):
return TEMPLATE_ENVIRONMENT.get_template(template_filename).render(context)
def init(args = None):
return
#
#
#
def do_extract_metrics(args):
# print ""
# print "do_extract_metrics ... "
fname = args['file']
metric = args['metric']
# print(fname)
# print 'metric id = ' + metric['id']
# print 'metric regex = ' + metric['regex']
count = 0
mmin = 0
mmin_index = 0
mmax = 0
mmax_index = 0
mean = 0
median = 0
output = np.fromregex(fname,metric['regex'], [('id', 'S20'), ('metric', np.float), ('frame', np.int)] )
# print 'T0T0 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
# print output
count = output['metric'].size
# print count
if count > 0:
mmin = np.amin(output['metric']);
mmin_index = np.argmin(output['metric']);
mmax = np.amax(output['metric']);
mmax_index = np.argmax(output['metric']);
mean = np.mean(output['metric']);
median = np.median(output['metric']);
# print ( ( (metric['min_limit'] > output['metric']).sum() / float(output['metric'].size) ) * 100 )
ret = { 'metric_count' : count,
'metric_buf' : output,
'metric_min' : mmin,
'metric_min_index' : mmin_index,
'metric_max' : mmax,
'metric_max_index' : mmax_index,
'metric_mean' : mean,
'metric_median' : median,
}
return(ret)
#
#
#
def do_check_verdict(metric_def, metric_data):
verdict = 'INCON'
pass_fail_stat = metric_def['pass_fail_stat']
if pass_fail_stat == 'max_value':
metric_stat = metric_data['metric_max']
elif pass_fail_stat == 'min_value':
metric_stat = metric_data['metric_min']
elif pass_fail_stat == 'mean_value':
metric_stat = metric_data['metric_mean']
elif pass_fail_stat == 'median_value':
metric_stat = metric_data['metric_median']
else :
print "do_check_verdict -> undef metric stat (pass_fail_stat in xml file)"
return verdict
if 'max_limit' in metric_def:
if metric_stat > metric_def['max_limit']:
verdict = 'FAIL'
else:
verdict = 'PASS'
if 'min_limit' in metric_def:
if metric_stat < metric_def['min_limit']:
verdict = 'FAIL'
else:
verdict = 'PASS'
return verdict
def do_print_metrics(metric_def, metric_data):
if metric_data['metric_count'] > 0 :
# output = np.array( metric_data['metric_buf'] , [('id', 'S20'), ('metric', np.float), ('frame', np.int)])
output = metric_data['metric_buf']
# print output
fontP = FontProperties()
fontP.set_size('small')
plt.scatter(output['frame'], output['metric'], color='b', alpha=0.33, s = 1 )
plt.plot([0, output['frame'][metric_data['metric_count']-1]],[ metric_def['min_limit'],metric_def['min_limit']], 'r-', lw=2) # Red straight line
plt.title('Physical throughput ')
plt.xlabel('frame')
plt.ylabel(metric_def['id'])
plt.legend(prop=fontP)
mng = plt.get_current_fig_manager()
plt.show()
def do_img_metrics(metric_def, metric_data, fname):
if metric_data['metric_count'] > 0 :
# output = np.array( metric_data['metric_buf'] , [('id', 'S20'), ('metric', np.float), ('frame', np.int)])
output = metric_data['metric_buf']
# print 'TITI !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
# print output
# print metric_def['min_limit']
# print metric_data['metric_count']
# print output['frame'][metric_data['metric_count']-1]
fontP = FontProperties()
fontP.set_size('small')
plt.figure()
# print output['frame'].size
# print output['metric'].size
plt.scatter(output['frame'], output['metric'], color='b', alpha=0.33, s = 1 , label=metric_def['id'])
plt.plot([0, output['frame'][metric_data['metric_count']-1]],[ metric_def['min_limit'],metric_def['min_limit']], 'r-', lw=2, label='min limit') # Red straight line
plt.title('Physical throughput ('+metric_def['unit_of_meas']+')')
plt.xlabel('frame')
plt.ylabel(metric_def['id'])
# Set graphic minimum Y axis
# -------------------------
if metric_data['metric_min'] == 0 :
plt.ylim(ymin=-metric_def['min_limit']/10)
else :
plt.ylim(ymin=0)
y_axis_max = 0
if metric_data['metric_max'] > metric_def['min_limit']:
y_axis_max =metric_data['metric_max']+metric_data['metric_max']/10
else:
y_axis_max =metric_def['min_limit']+metric_def['min_limit']/10
plt.ylim(ymax=y_axis_max)
lgd = plt.legend(prop=fontP, bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
mng = plt.get_current_fig_manager()
plt.savefig(fname, bbox_extra_artists=(lgd,), bbox_inches='tight')
plt.close()
# with open(fname, 'r') as f:
# for line in f:
# m = re.search(metric['regex'], line)
# if m :
# print m.group(1) + " -> "+m.group(2)
def do_extract_traffic_metrics(args):
print ""
print "do_extract_traffic_metrics ... "
fname = args['file']
# print(fname)
# print 'metric id = ' + metric['id']
#[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
#[ 3] 0.0- 1.0 sec 238 KBytes 1.95 Mbits/sec 0.980 ms 2/ 174 (1.1%)
# [ 3] 0.0- 1.0 sec 63.2 KBytes 517 Kbits/sec 0.146 ms 1/ 45 (2.2%)
# iperf_regex = '[\s*(\d+)]\s+\d+\.\d+-\s*(\d+\.\d+)\s+sec\s+(\d+).+(\d+\.\d+).+(\d+\.\d+).+(\d+)\/\s*(\d+)\s+\((\d+\.\d+)\%\)'
# ID 0.0 1.0 63.2 KByte 517 Kbits/s 0.146
iperf_regex = '\[\s*(\d+)\]\s+(\d+\.*\d*)-\s*(\d+\.*\d*)\s+sec\s+(\d+\.*\d*)\s+(\D+)\s+(\d+\.*\d*)\s+(\D+)\s+(\d+\.*\d*)\s+ms\s+(\d+)\/\s*(\d+)\s+\((\d+\.*\d*)\%\)'
# print 'iperf regex = ' + iperf_regex
count = 0
bw_min = 0
bw_max = 0
bw_mean = 0
bw_median = 0
jitter_min = 0
jitter_max = 0
jitter_mean = 0
jitter_median = 0
rl_min = 0
rl_max = 0
rl_mean = 0
rl_median = 0
interval_stop_max = 0
output = np.fromregex(fname,iperf_regex, [('id', np.int) , ('interval_start', np.float), ('interval_stop', np.float), ('transfer', np.float), ('transfer_uom', 'S20') ,('bandwidth', np.float), ('bandwidth_uom', 'S20') ,('jitter', np.float), ('lost', np.int) , ('total', np.int), ('rate_lost', np.float) ] )
count = output['id'].size -1
# remove last line that is an iperf result resume
if count > 0:
output= np.delete(output, (count), axis=0 )
# print output
bw_min = np.amin(output['bandwidth']);
bw_max = np.amax(output['bandwidth']);
bw_mean = np.mean(output['bandwidth']);
bw_median = np.median(output['bandwidth']);
jitter_min = np.amin(output['jitter']);
jitter_max = np.amax(output['jitter']);
jitter_mean = np.mean(output['jitter']);
jitter_median = np.median(output['jitter']);
rl_min = np.amin(output['rate_lost']);
rl_max = np.amax(output['rate_lost']);
rl_mean = np.mean(output['rate_lost']);
rl_median = np.median(output['rate_lost']);
interval_stop_max = np.amax(output['interval_stop']);
else :
count = 0
ret = { 'traffic_count' : count,
'traffic_buf' : output,
'bw_min' : bw_min,
'bw_max' : bw_max,
'bw_mean' : bw_mean,
'bw_median' : bw_median,
'jitter_min' : jitter_min,
'jitter_max' : jitter_max,
'jitter_mean' : jitter_mean,
'jitter_median' : jitter_median,
'rl_min' : rl_min,
'rl_max' : rl_max,
'rl_mean' : rl_mean,
'rl_median' : rl_median,
'interval_stop_max' : interval_stop_max
}
return(ret)
def do_img_traffic(traffic_data, fname):
if traffic_data['traffic_count'] > 0 :
output = traffic_data['traffic_buf']
fontP = FontProperties()
fontP.set_size('small')
fig = plt.figure(1)
ax1= plt.subplot(311)
plt.plot(output['interval_stop'], output['bandwidth'], color='b' )
ax1.set_title('Bandwidth (Mbits/s)')
ax1.set_ylim(ymin=-1)
ax1.set_xlim(xmax=np.amax(output['interval_stop']))
text='min: '+str(traffic_data['bw_min'])+'\nmax: '+str(traffic_data['bw_max'])+'\nmean: '+str(traffic_data['bw_mean'])+'\nmedian: '+str(traffic_data['bw_median'])
ax1.text( np.amax(output['interval_stop'])+10,0,text)
ax2=plt.subplot(312)
plt.plot(output['interval_stop'], output['jitter'], color='b' )
ax2.set_title('Jitter (ms)')
ax2.set_xlim(xmax=np.amax(output['interval_stop']))
ax2.set_ylim(ymin=-1)
text='min: '+str(traffic_data['jitter_min'])+'\nmax: '+str(traffic_data['jitter_max'])+'\nmean: '+str(traffic_data['jitter_mean'])+'\nmedian: '+str(traffic_data['jitter_median'])
ax2.text( np.amax(output['interval_stop'])+10,0,text)
ax3=plt.subplot(313)
plt.plot(output['interval_stop'], output['rate_lost'], color='b')
ax3.set_title('Loss rate %')
ax3.set_xlim(xmax=np.amax(output['interval_stop']))
ax3.set_ylim(ymin=-1)
text='min: '+str(traffic_data['rl_min'])+'\nmax: '+str(traffic_data['rl_max'])+'\nmean: '+str(traffic_data['rl_mean'])+'\nmedian: '+str(traffic_data['rl_median'])
ax3.text( np.amax(output['interval_stop'])+10,0,text)
# plt.title('Physical throughput ('+metric_def['unit_of_meas']+')')
plt.xlabel('time (s)')
# plt.ylabel(metric_def['id'])
# Set graphic minimum Y axis
# -------------------------
# if traffic_data['bw_min'] == 0 :
# plt.ylim(ymin=-metric_def['min_limit']/10)
# else :
# plt.ylim(ymin=0)
# y_axis_max = 0
# if traffic_data['metric_max'] > metric_def['min_limit']:
# y_axis_max =traffic_data['metric_max']+traffic_data['metric_max']/10
# else:
# y_axis_max =metric_def['min_limit']+metric_def['min_limit']/10
#
# plt.ylim(ymax=y_axis_max)
plt.tight_layout()
lgd = plt.legend(prop=fontP, bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
mng = plt.get_current_fig_manager()
plt.savefig(fname, bbox_inches='tight')
plt.close()
def create_report_html(context):
fname = context['report_path']+"/index.html"
#
with open(fname, 'w') as f:
html = render_template('index.html', context)
f.write(html)
def create_test_report_detailed_html(context, fname ):
with open(fname, 'w') as f:
html = render_template('testcase_report.html', context)
f.write(html)
def check_cell_synchro(fname):
with open(fname, 'r') as f:
for line in f:
m = re.search('AUTOTEST Cell Sync \:', line)
if m :
print line
return 'CELL_SYNCH'
return 'CELL_NOT_SYNCH'
def check_exec_seg_fault(fname):
with open(fname, 'r') as f:
for line in f:
m = re.search('Segmentation fault', line)
if m :
print line
return 'SEG_FAULT'
return 'NO_SEG_FAULT'
...@@ -223,13 +223,15 @@ check_install_additional_tools (){ ...@@ -223,13 +223,15 @@ check_install_additional_tools (){
android-tools-adb \ android-tools-adb \
wvdial \ wvdial \
python-numpy \ python-numpy \
sshpass \ sshpass \
nscd \ nscd \
bc \ bc \
ntp ntp \
python-scipy \
python-matplotlib
$SUDO pip install paramiko $SUDO pip install paramiko
$SUDO pip install pyroute2 $SUDO pip install pyroute2 colorama
$SUDO rm -fr /opt/ssh $SUDO rm -fr /opt/ssh
$SUDO GIT_SSL_NO_VERIFY=true git clone https://gitlab.eurecom.fr/oai/ssh.git /opt/ssh $SUDO GIT_SSL_NO_VERIFY=true git clone https://gitlab.eurecom.fr/oai/ssh.git /opt/ssh
......
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