Commit 0b1050c1 authored by ROBERT Benoit's avatar ROBERT Benoit

Add following functionnalities to OAI UE autotest framework

- add progess bar report
- reduce ssh max_tries to 10
- cleanOldPrograms -> change kill cmd line to be able to run autotest on same machine than lte-softmodem (thanks Rohit & Gabriel)
- Cleanning output prints
- add --skip-machine-preparation on cmd line
- add --skip-sanity-check on cmd line
- add HTML REPORT (no-S1 only)
- add XML detailled report (no-S1 only)
parent 9648d1f2
......@@ -235,6 +235,7 @@ add_boolean_option(DEBUG_OMG False "???")
add_boolean_option(XFORMS False "This adds the possibility to see the signal oscilloscope")
add_boolean_option(PRINT_STATS False "This adds the possibility to see the status")
add_boolean_option(T_TRACER False "Activate the T tracer, a debugging/monitoring framework" )
add_boolean_option(UE_AUTOTEST_TRACE False "Activate UE autotest specific logs")
add_boolean_option(DEBUG_CONSOLE False "makes debugging easier, disables stdout/stderr buffering")
......
......@@ -75,7 +75,7 @@ class openair(core):
return (stdout, stderr)
def connect(self, username, password, prompt='PEXPECT_OAI'):
max_retries=100
max_retries=10
i=0
while i <= max_retries:
self.prompt1 = prompt
......@@ -97,9 +97,9 @@ class openair(core):
# need to look for twice the string of the prompt
self.oai.prompt()
self.oai.prompt()
self.oai.sendline('uptime')
self.oai.prompt()
print self.oai.before
# self.oai.sendline('uptime')
# self.oai.prompt()
# print self.oai.before
break
except Exception, e:
error=''
......@@ -171,7 +171,7 @@ class openair(core):
sys.exit(1)
def disconnect(self):
print 'disconnecting the ssh connection to ' + self.address + '\n'
# print 'disconnecting the ssh connection to ' + self.address + '\n'
self.oai.send('exit')
# self.cancel()
......
diff --git a/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c b/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c
index d2c7ac6..0853373 100644
--- a/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c
+++ b/openair1/PHY/CODING/3gpplte_turbo_decoder_sse_8bit.c
@@ -493,7 +493,7 @@ void compute_beta8(llr_t* alpha,llr_t* beta,llr_t *m_11,llr_t* m_10,unsigned sho
#endif
- if (frame_length > 6143) {
+ if (frame_length > 6144) {
LOG_E(PHY,"compute_beta: frame_length %d\n",frame_length);
return;
}
@@ -979,6 +979,11 @@ unsigned char phy_threegpplte_turbo_decoder8(short *y,
} else
n2 = n;
+ if(n2<256)
+ {
+ printf("phy_threegpplte_turbo_decoder8 : frame length < 256\n");
+ return 255;
+ }
for (iind=0; iind < 188 && f1f2mat[iind].nb_bits != n; iind++);
diff --git a/openair1/PHY/LTE_TRANSPORT/initial_sync.c b/openair1/PHY/LTE_TRANSPORT/initial_sync.c
index 71372d9..763397b 100644
index 661fe96..782305d 100644
--- a/openair1/PHY/LTE_TRANSPORT/initial_sync.c
+++ b/openair1/PHY/LTE_TRANSPORT/initial_sync.c
@@ -477,6 +477,13 @@ int initial_sync(PHY_VARS_UE *ue, runmode_t mode)
@@ -469,6 +469,15 @@ int initial_sync(PHY_VARS_UE *ue, runmode_t mode)
//#endif
if (ue->UE_scan_carrier == 0) {
+
+ /* SYRTEM */
+ printf("AUTOTEST Cell Sync : frame = %d, rx_offset %d, freq_offset %d \n",
+ #if UE_AUTOTEST_TRACE
+ LOG_I(PHY,"[UE %d] AUTOTEST Cell Sync : frame = %d, rx_offset %d, freq_offset %d \n",
+ ue->Mod_id,
+ ue->proc.proc_rxtx[0].frame_rx,
+ ue->rx_offset,
+ ue->common_vars.freq_offset );
+ #endif
+
if (ue->mac_enabled==1) {
LOG_I(PHY,"[UE%d] Sending synch status to higher layers\n",ue->Mod_id);
......
diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c
index 96645f8..a7f1dfb 100644
--- a/targets/RT/USER/lte-softmodem.c
+++ b/targets/RT/USER/lte-softmodem.c
@@ -1602,6 +1602,11 @@ int main( int argc, char **argv )
PHY_vars_eNB_g[0][CC_id] = init_lte_eNB(frame_parms[CC_id],0,frame_parms[CC_id]->Nid_cell,abstraction_flag);
PHY_vars_eNB_g[0][CC_id]->CC_id = CC_id;
+ PHY_vars_eNB_g[0][CC_id]->ue_dl_rb_alloc=0x1fff;
+ PHY_vars_eNB_g[0][CC_id]->target_ue_dl_mcs=target_dl_mcs;
+ PHY_vars_eNB_g[0][CC_id]->ue_ul_nb_rb=6;
+ PHY_vars_eNB_g[0][CC_id]->target_ue_ul_mcs=target_ul_mcs;
+
if (phy_test==1) PHY_vars_eNB_g[0][CC_id]->mac_enabled = 0;
else PHY_vars_eNB_g[0][CC_id]->mac_enabled = 1;
......@@ -20,10 +20,14 @@
# * contact@openairinterface.org
# */
# \author Rohit Gupta
# \author Rohit Gupta - Benoit ROBERT (benoit.robert@syrtem.com)
# \version 0.1
# @ingroup _test
# \Changelog
# 2016-11-18 :
# - Add progess bar during test execution update_progress()
import tempfile
import threading
import sys
......@@ -37,6 +41,8 @@ import math #from time import clock
import xml.etree.ElementTree as ET
import re
#from dict2xml import dict2xml as xmlify
from colorama import Fore, Back, Style
import numpy as np
......@@ -57,6 +63,36 @@ import ssh
from ssh import SSHSession
import argparse
# update_progress() : Displays or updates a console progress bar
## Accepts a float between 0 and 1. Any int will be converted to a float.
## A value under 0 represents a 'halt'.
## A value at 1 or bigger represents 100%
def update_progress(progress, prefix_string):
barLength = 20 # Modify this to change the length of the progress bar
status = ""
#print "progress = "+ str(progress)
if isinstance(progress, int):
progress = float(progress)
if not isinstance(progress, float):
progress = 0
status = "error: progress var must be float\r\n"
if progress < 0:
progress = 0
status = "Halt...\r\n"
if progress >= 1:
progress = 1
status = "Done...\r\n"
block = int(round(barLength*progress))
text = "\r"+prefix_string+" [{0}] {1}% {2}".format( "="*block + " "*(barLength-block), progress*100, status)
sys.stdout.write(text)
sys.stdout.flush()
def exit_prog(exit_val):
print(Style.RESET_ALL),
sys.exit(exit_val)
# \brief write a string to a file
# \param filename name of file
# \param string string to write
......@@ -271,7 +307,7 @@ def update_config_file(oai, config_string, logdirRepo, python_script):
# \param logdir_local_base local directory
# \param operation operation to perform (get_all, put_all) transfers recursively for directories
def SSHSessionWrapper(machine, username, key_file, password, logdir_remote, logdir_local_base, operation):
max_tries = 100
max_tries = 10
i=0
while i <= max_tries:
i = i +1
......@@ -306,30 +342,50 @@ def SSHSessionWrapper(machine, username, key_file, password, logdir_remote, logd
# \param CleanUpAluLteBox program to terminate AlU Bell Labs LTE Box
# \param ExmimoRfStop String to stop EXMIMO card (specified in test_case_list.xml)
def cleanOldPrograms(oai, programList, CleanUpAluLteBox, ExmimoRfStop, logdir, logdirOAI5GRepo):
cmd = 'sudo -E killall -s INT -q -r ' + programList + ' ; sleep 5 ; sudo -E killall -9 -q -r ' + programList
cmd = 'killall -9 ' + programList
result = oai.send(cmd, True)
print "Killing old programs..." + result
# print "\t\t > "+cmd
# print "\t\t < "+result
# print "Killing old programs on ..." + result
programArray = programList.split()
programListJoin = '|'.join(programArray)
cmd = " ( date ;echo \"Starting cleaning old programs.. \" ; dmesg|tail ; echo \"Current disk space.. \" ; df -h )>& " + logdir + "/oai_test_setup_cleanup.log.`hostname` 2>&1 ; sync"
result=oai.send_recv(cmd)
# print "\t\t > "+cmd
# print "\t\t < "+result
cmd = cleanupOldProgramsScript + ' ' + '\''+programListJoin+'\''
#result = oai.send_recv(cmd)
#print result
result = oai.send_expect_false(cmd, 'Match found', False)
print "Looking for old programs..." + result
# print "\t\t > "+cmd
# print "\t\t < "+result
# print "Looking for old programs..." + result
res=oai.send_recv(CleanUpAluLteBox, True)
# print "\t\t > "+CleanUpAluLteBox
# print "\t\t < "+res
cmd= " echo \"Starting EXmimoRF Stop... \" >> " + logdir + "/oai_test_setup_cleanup.log.`hostname` 2>&1 ; sync ";
oai.send_recv(cmd)
result = oai.send_recv(cmd)
# print "\t\t > "+cmd
# print "\t\t < "+result
cmd = "( " + "cd " + logdirOAI5GRepo + " ; source oaienv ; " + ExmimoRfStop + " ) >> " + logdir + "/oai_test_setup_cleanup.log.`hostname` 2>&1 ; sync "
print "cleanoldprograms cmd = " + cmd
# print "cleanoldprograms cmd = " + cmd
res=oai.send_recv(cmd, False, timeout=600)
# print "\t\t > "+cmd
# print "\t\t < "+res
cmd= " echo \"Stopping EXmimoRF Stop... \" >> " + logdir + "/oai_test_setup_cleanup.log.`hostname` 2>&1 ; sync ";
oai.send_recv(cmd)
result = oai.send_recv(cmd)
# print "\t\t > "+cmd
# print "\t\t < "+result
#res = oai.send_recv(ExmimoRfStop, False)
cmd = " ( date ;echo \"Finished cleaning old programs.. \" ; dmesg | tail)>> $HOME/.oai_test_setup_cleanup.log.`hostname` 2>&1 ; sync"
res=oai.send_recv(cmd)
# print "\t\t > "+cmd
# print "\t\t < "+res
# \brief Class thread to launch a generic command on remote machine
# \param threadID number of thread (for book keeping)
......@@ -355,10 +411,10 @@ class oaiThread (threading.Thread):
try:
oai = openair('localdomain',self.machine)
oai.connect(self.username, self.password)
print "Starting " + self.threadname + " on machine " + self.machine
# print "Starting " + self.threadname + " on machine " + self.machine
result = oai.send_recv(self.cmd, self.sudo, self.timeout)
print "result = " + result
print "Exiting " + self.threadname
#print "result = " + result
#print "Exiting " + self.threadname
oai.disconnect()
except Exception, e:
error=''
......@@ -1262,6 +1318,8 @@ def handle_testcaseclass_softmodem_noS1 (testcase, oldprogramList, logdirOAI5GRe
if testcase_verdict != 'PASS': # if something went wrong to not run test cases
max_ntries=0
indent="\t\t"
runs_results = []
nb_runs = 0
nb_run_pass = 0
......@@ -1281,9 +1339,11 @@ def handle_testcaseclass_softmodem_noS1 (testcase, oldprogramList, logdirOAI5GRe
#
# RUN initialization
# ----------------------------------------------------
print (Fore.WHITE + indent + "> RUN_"+str(run).zfill(2)+" : " ),
sys.stdout.flush()
prefix_string = Fore.WHITE + indent + "> RUN_"+str(run).zfill(2)+" :"
# print (Fore.WHITE + indent + "> RUN_"+str(run).zfill(2)+" : " ),
# sys.stdout.flush()
run_start_time=datetime.datetime.now()
......@@ -1399,9 +1459,35 @@ def handle_testcaseclass_softmodem_noS1 (testcase, oldprogramList, logdirOAI5GRe
threads.append(thread_UE)
thread_eNB.start()
thread_UE.start()
run_work_inprogress_flag = True
progress_step = timeout_thread/20
progress_count = 0
while (run_work_inprogress_flag):
update_progress(float(progress_count)/float(timeout_thread),prefix_string)
time.sleep(progress_step)
progress_count += progress_step
# sys.stdout.write ('#')
# sys.stdout.flush()
run_work_inprogress_flag = False
for t in threads:
if t.isAlive():
run_work_inprogress_flag = True
update_progress(1,prefix_string)
for t in threads:
t.join()
#
#
#-----------------------------------------------------
......@@ -1415,10 +1501,12 @@ def handle_testcaseclass_softmodem_noS1 (testcase, oldprogramList, logdirOAI5GRe
fname = logdir_local_run+ '/UE_exec' + '_' + str(run) + '_.log'
cell_synch_status = analyser.check_cell_synchro(fname)
print (Fore.WHITE + indent + "> Check Cell synchro :"),
if cell_synch_status == 'CELL_SYNCH':
print '!!!!!!!!!!!!!! Cell synchronized !!!!!!!!!!!'
print ( Fore.GREEN + cell_synch_status)
else :
print '!!!!!!!!!!!!!! Cell NOT NOT synchronized !!!!!!!!!!!'
print ( Fore.RED + cell_synch_status)
metric_checks_flag = 0
ue_seg_fault_status = analyser.check_exec_seg_fault(fname)
......@@ -1437,6 +1525,9 @@ def handle_testcaseclass_softmodem_noS1 (testcase, oldprogramList, logdirOAI5GRe
# UE side metrics
metricList=testcase.findall('UE_metric')
for metric in metricList:
metric_verdict = 'PASS'
metric_def = {}
metric_def['id'] = metric.get('id')
metric_def['description'] = metric.get('description')
......@@ -1457,15 +1548,19 @@ def handle_testcaseclass_softmodem_noS1 (testcase, oldprogramList, logdirOAI5GRe
metric_extracted = analyser.do_extract_metrics(args)
print "\t > Metric "+metric_def['id']+" :"
print "\t\t> min = "+ str( metric_extracted['metric_min'] )
print "\t\t> min_index = "+ str( metric_extracted['metric_min_index'] )
print "\t\t> max = "+ str( metric_extracted['metric_max'] )
print "\t\t> max_index = "+ str( metric_extracted['metric_max_index'] )
print "\t\t> mean = "+ str( metric_extracted['metric_mean'] )
print "\t\t> median = "+ str( metric_extracted['metric_median'] )
print (Fore.WHITE + indent + "> Metric : "+metric_def['id']),
print ("(min="+str( metric_extracted['metric_min'])+", max="+str( metric_extracted['metric_max'])+", mean="+str( metric_extracted['metric_mean'])+", median="+str( metric_extracted['metric_median'])+")")
verdict = analyser.do_check_verdict(metric_def, metric_extracted)
# print "\t > Metric "+metric_def['id']+" :"
# print "\t\t> min = "+ str( metric_extracted['metric_min'] )
# print "\t\t> min_index = "+ str( metric_extracted['metric_min_index'] )
# print "\t\t> max = "+ str( metric_extracted['metric_max'] )
# print "\t\t> max_index = "+ str( metric_extracted['metric_max_index'] )
# print "\t\t> mean = "+ str( metric_extracted['metric_mean'] )
# print "\t\t> median = "+ str( metric_extracted['metric_median'] )
if metric_def['pass_fail_stat'] :
metric_verdict = analyser.do_check_verdict(metric_def, metric_extracted)
metric_fig = logdir_local_run+ '/UE_metric_'+ metric_def['id']+'_' + str(run) + '_.png'
analyser.do_img_metrics(metric_def, metric_extracted, metric_fig)
......@@ -1493,6 +1588,13 @@ def handle_testcaseclass_softmodem_noS1 (testcase, oldprogramList, logdirOAI5GRe
runs_metrics.append(run_metrics)
if metric_verdict != 'PASS':
verdict = metric_verdict
# End Metrics LOOP
# ---------------------
# Traffic analysis
if UE_traffic_exec != "":
......@@ -1578,6 +1680,8 @@ def handle_testcaseclass_softmodem_noS1 (testcase, oldprogramList, logdirOAI5GRe
# END RUN LOOP
#----------------------------------------------------
indent="\t"
# Test case duration
# ----------------------------------
testcase_time_stop = datetime.datetime.now()
......@@ -1617,11 +1721,9 @@ def handle_testcaseclass_softmodem_noS1 (testcase, oldprogramList, logdirOAI5GRe
else:
print (Fore.YELLOW+'INCONCLUSIVE')
duration= testcase_time_stop - testcase_time_start
xmlFile = logdir_local_testcase + '/test.' + testcasename + '.xml'
xml="\n<testcase classname=\'"+ testcaseclass + "\' name=\'" + testcasename + "."+tags + "\' Run_result=\'" + test_result_string + "\' time=\'" + str(duration) + " s \' RESULT=\'" + testcase_verdict + "\'></testcase> \n"
write_file(xmlFile, xml, mode="w")
print(Style.RESET_ALL)
duration= testcase_time_stop - testcase_time_start
test_result = dict(testcase_name=testcasename,
testcaseclass=testcaseclass,
......@@ -1640,7 +1742,17 @@ def handle_testcaseclass_softmodem_noS1 (testcase, oldprogramList, logdirOAI5GRe
testcase_eNBMachine =eNBMachine,
testcase_UEMachine =UEMachine,
runs_results = runs_results)
#test_results.append(test_result)
test_results.append(test_result)
xmlFile = logdir_local_testcase + '/test.' + testcasename + '.xml'
xml="\n<testcase classname=\'"+ testcaseclass + "\' name=\'" + testcasename + "."+tags + "\' Run_result=\'" + test_result_string + "\' time=\'" + str(duration) + " s \' RESULT=\'" + testcase_verdict + "\'></testcase> \n"
write_file(xmlFile, xml, mode="w")
# xmlFile_ng = logdir_local_testcase + '/test.' + testcasename + '_ng.xml'
# xml_ng = xmlify(test_result, wrap=testcasename, indent=" ")
# write_file(xmlFile_ng, xml_ng, mode="w")
return testcase_verdict
......@@ -1659,12 +1771,12 @@ def search_test_case_group(testcasename, testcasegroup, test_case_exclude):
if entry.find('+') >=0:
match = re.search(entry, testcasename)
if match:
print "\nSkipping test case as it is found in black list: " + testcasename
#print "\nSkipping test case as it is found in black list: " + testcasename
return False
else:
match = entry.find(testcasename)
if match >=0:
print "\nSkipping test case as it is found in black list: " + testcasename
#print "\nSkipping test case as it is found in black list: " + testcasename
return False
if testcasegroup == '':
return True
......@@ -1752,6 +1864,7 @@ if openairdir_local is None:
print "Environment variable OPENAIR_DIR not set correctly"
sys.exit()
locallogdir = openairdir_local + '/cmake_targets/autotests/log'
reportdir = openairdir_local + '/cmake_targets/autotests/report'
MachineList = ''
MachineListGeneric=''
MachineDescDic={}
......@@ -1760,12 +1873,19 @@ flag_start_testcase=False
nruns_lte_softmodem=''
flag_skip_git_head_check=False
flag_skip_oai_install=False
flag_skip_machine_preparation=False
flag_skip_sanity_check=False
flag_generate_html_report = False
Timeout_cmd=''
xmlInputFile=''
print "Number of arguments argc = " + str(len(sys.argv))
#print "Number of arguments argc = " + str(len(sys.argv))
#for index in range(1,len(sys.argv) ):
# print "argv_" + str(index) + " : " + sys.argv[index]
oai_list = []
i=1
while i < len (sys.argv):
arg=sys.argv[i]
......@@ -1825,9 +1945,15 @@ while i < len (sys.argv):
i = i +1
elif arg == '--skip-oai-install':
flag_skip_oai_install=True
elif arg == '--skip-machine-preparation':
flag_skip_machine_preparation=True
elif arg == '--skip-sanity-check':
flag_skip_sanity_check=True
elif arg == '--test-suite' :
xmlInputFile = sys.argv[i+1]
i = i +1
elif arg == '--generate-html-report':
flag_generate_html_report=True
elif arg == '-h' :
print "-s: This flag *MUST* be set to start the test cases"
print "-r: Remove the log directory in autotests"
......@@ -1845,90 +1971,65 @@ while i < len (sys.argv):
print "--skip-git-head-check: skip checking of GitHead remote/local branch (only for debugging)"
print "--timeout_cmd: Override the default parameter (timeout_cmd) in test_case_list.xml. This parameter is in seconds and should be > 120"
print "--skip-oai-install: Skips the openairinterface5g installer"
print "--skip-machine-preparation: skipp the whole system preparation -> direct to test cases"
print "--skip-sanity-check: skipp the machine sanity checks"
print "--test-suite: Select a XML test-suite file"
print "--generate-html-report: Generate an HTML report of the test campaign (supported only for noS1 testsuite !!)"
sys.exit()
else :
print "Unrecongnized Option: <" + arg + ">. Use -h to see valid options"
sys.exit()
i= i + 1
try:
os.environ["OPENAIR1_DIR"]
except KeyError:
print "Please set the environment variable OPENAIR1_DIR in the .bashrc"
sys.exit(1)
try:
os.environ["OPENAIR2_DIR"]
except KeyError:
print "Please set the environment variable OPENAIR2_DIR in the .bashrc"
sys.exit(1)
try:
os.environ["OPENAIR_TARGETS"]
except KeyError:
print "Please set the environment variable OPENAIR_TARGETS in the .bashrc"
sys.exit(1)
print "Killing zombie ssh sessions from earlier sessions..."
cmd='ps aux |grep \"/usr/bin/ssh -q -l guptar\"| awk \'{print $2}\' | sudo xargs kill -9 '
os.system(cmd)
logdir = '/tmp/' + 'OAITestFrameWork-' + user + '/'
logdirOAI5GRepo = logdir + 'openairinterface5g/'
logdirOpenaircnRepo = logdir + 'openair-cn/'
patchdir = logdirOAI5GRepo + 'cmake_targets/autotests/patches/'
NFSResultsDir = '/mnt/sradio'
cleanupOldProgramsScript = '$OPENAIR_DIR/cmake_targets/autotests/tools/remove_old_programs.bash'
try:
analyser = __import__("lib_autotest_analyser")
except ImportError as err:
print('Import error: ' + str(err))
exit(0)
#Now we parse the xml file for basic configuration
if xmlInputFile == '':
xmlInputFile=os.environ.get('OPENAIR_DIR')+"/cmake_targets/autotests/test_case_list.xml"
xmlTree = ET.parse(xmlInputFile)
xmlRoot = xmlTree.getroot()
#
# Read test session configuration
# ---------------------------------------------------------------------------------
print (Fore.YELLOW + '\nStep 0.1 - Read test session configuration')
print (Fore.YELLOW + '-------------------------------------------------')
if flag_start_testcase == False:
print "You need to start the testcase by passing option -s. Use -h to see all options. Aborting now..."
sys.exit(1)
test_session_start_time = datetime.datetime.now()
print (Fore.WHITE + ' - start time : '+ str(test_session_start_time))
# get the oai object
host = os.uname()[1]
#oai = openair('localdomain','calisson')
oai_list = []
print (Fore.WHITE + ' - MTC host : '+host)
#start_time = time.time() # datetime.datetime.now()
if user=='':
user = getpass.getuser()
print (Fore.WHITE + ' - user : '+user)
if pw=='':
pw = getpass.getpass()
print (Fore.WHITE + ' - password : '+pw)
print "Killing zombie ssh sessions from earlier sessions..."
cmd='ps aux |grep \"/usr/bin/ssh -q -l guptar\"|tr -s \" \" :|cut -f 2 -d :|xargs kill -9 '
cmd = cmd + '; ps aux |grep \"/usr/bin/ssh -q -l ' + user + '\"|tr -s \" \" :|cut -f 2 -d :|xargs kill -9 '
os.system(cmd)
print (Fore.WHITE + ' - cmd line flags : ')
print (Fore.WHITE + ' + -s : '+str(flag_start_testcase))
print (Fore.WHITE + ' + -r : '+str(flag_remove_logdir))
print (Fore.WHITE + ' + -c : '+str(cleanUpRemoteMachines))
print (Fore.WHITE + ' + --skip-git-head-check : '+str(flag_skip_git_head_check))
print (Fore.WHITE + ' + --skip-oai-install : '+str(flag_skip_oai_install))
print (Fore.WHITE + ' + --skip-machine-preparation : '+str(flag_skip_machine_preparation))
print (Fore.WHITE + ' + --skip-sanity-check : '+str(flag_skip_sanity_check))
print "host = " + host
print "user = " + user
if xmlInputFile == '':
xmlInputFile=os.environ.get('OPENAIR_DIR')+"/cmake_targets/autotests/test_case_list.xml"
NFSResultsDir = '/mnt/sradio'
cleanupOldProgramsScript = '$OPENAIR_DIR/cmake_targets/autotests/tools/remove_old_programs.bash'
logdir = '/tmp/' + 'OAITestFrameWork-' + user + '/'
logdirOAI5GRepo = logdir + 'openairinterface5g/'
logdirOpenaircnRepo = logdir + 'openair-cn/'
patchdir = logdirOAI5GRepo + 'cmake_targets/autotests/patches/'
if flag_remove_logdir == True:
print "Removing directory: " + locallogdir
os.system(' rm -fr ' + locallogdir + '; mkdir -p ' + locallogdir )
else:
os.system('mkdir -p ' + locallogdir)
paramiko_logfile = os.path.expandvars('$OPENAIR_DIR/cmake_targets/autotests/log/paramiko.log')
res=os.system(' echo > ' + paramiko_logfile)
paramiko.util.log_to_file(paramiko_logfile)
#pw=getpass.getpass()
#Now we parse the xml file for basic configuration
xmlTree = ET.parse(xmlInputFile)
xmlRoot = xmlTree.getroot()
print (Fore.WHITE + ' - Test setup basic config : (* -> overwrite by cmd line parameter)')
print (Fore.WHITE + ' + test setup config file : '+str(xmlInputFile))
print (Fore.WHITE + ' + remote setup dir : '+str(logdir))
print (Fore.WHITE + ' + remote OAI5G repo : '+str(logdirOAI5GRepo))
print (Fore.WHITE + ' + remote OpenAirCN repo : '+str(logdirOpenaircnRepo))
if MachineList =='':
......@@ -1941,6 +2042,8 @@ if GitOAI5GRepo == '':
if GitOAI5GRepoBranch == '':
GitOAI5GRepoBranch = xmlRoot.findtext('GitOAI5GRepoBranch',default='')
if GitOAI5GHeadVersion == '':
GitOAI5GHeadVersion = xmlRoot.findtext('GitOAI5GHeadVersion',default='')
GitOpenaircnRepoBranch = xmlRoot.findtext('GitOpenair-cnRepoBranch',default='')
CleanUpOldProgs = xmlRoot.findtext('CleanUpOldProgs',default='')
......@@ -1953,25 +2056,27 @@ ExmimoRfStop = xmlRoot.findtext('ExmimoRfStop',default='')
if nruns_lte_softmodem == '':
nruns_lte_softmodem = xmlRoot.findtext('nruns_lte-softmodem',default='')
OAI5GpatchFileList=xmlRoot.findall('OAI5GPatchFile')
print (Fore.WHITE + ' + MachineList : '+ MachineList)
print (Fore.WHITE + ' + GitOpenair-cnRepo : '+ GitOpenaircnRepo)
print (Fore.WHITE + ' + GitOAI5GRepo : '+ GitOAI5GRepo)
print (Fore.WHITE + ' + GitOAI5GBranch : '+ GitOAI5GRepoBranch)
print (Fore.WHITE + ' + GitOpenaircnRepoBranch : '+ GitOpenaircnRepoBranch)
print (Fore.WHITE + ' + NFSResultsShare : '+ NFSResultsShare)
print (Fore.WHITE + ' + nruns_lte_softmodem : '+ nruns_lte_softmodem)
print (Fore.WHITE + ' + Timeout_cmd : '+ Timeout_cmd)
print "MachineList = " + MachineList
print "GitOpenair-cnRepo = " + GitOpenaircnRepo
print "GitOAI5GRepo = " + GitOAI5GRepo
print "GitOAI5GBranch = " + GitOAI5GRepoBranch
print "GitOpenaircnRepoBranch = " + GitOpenaircnRepoBranch
print "NFSResultsShare = " + NFSResultsShare
print "nruns_lte_softmodem = " + nruns_lte_softmodem
print "Timeout_cmd = " + Timeout_cmd
if GitOAI5GHeadVersion == '':
cmd = "git show-ref --heads -s "+ GitOAI5GRepoBranch
cmd = "git log --pretty=format:\'%H\' -n 1" # origin/"+ GitOAI5GRepoBranch
# cmd = "git show-ref --heads -s "+ GitOAI5GRepoBranch
GitOAI5GHeadVersion = subprocess.check_output ([cmd], shell=True)
GitOAI5GHeadVersion=GitOAI5GHeadVersion.replace("\n","")
print "GitOAI5GHeadVersion = " + GitOAI5GHeadVersion
print "CleanUpOldProgs = " + CleanUpOldProgs
print "Timeout_execution = " + str(Timeout_execution)
# Print commiter and date : git log -1 --pretty=format:"%an %ad"
print (Fore.WHITE + ' + GitOAI5GHeadVersion : '+ GitOAI5GHeadVersion)
#print "CleanUpOldProgs = " + CleanUpOldProgs
print (Fore.WHITE + ' + Timeout_execution (s) : '+ str(Timeout_execution))
if GitOAI5GHeadVersion == '':
print "Error getting the OAI5GBranch Head version...Exiting"
......@@ -1979,40 +2084,115 @@ if GitOAI5GHeadVersion == '':
NFSTestsResultsDir = NFSResultsShare + '/'+ GitOAI5GRepoBranch + '/' + GitOAI5GHeadVersion
print "NFSTestsResultsDir = " + NFSTestsResultsDir
#print "NFSTestsResultsDir = " + NFSTestsResultsDir
OAI5GpatchFileList=xmlRoot.findall('OAI5GPatchFile')
MachineList = MachineList.split()
MachineListGeneric = MachineListGeneric.split()
#index=0
MachineDescDic
#
# 'Check Mater Test Controller sanity (MTC)'
# ---------------------------------------------------------------------------------
print (Fore.YELLOW + '\nStep 0.2 - Check Mater Test Controller sanity (MTC)')
print (Fore.YELLOW + '-------------------------------------------------')
try:
print (Fore.WHITE + ' - check OpenAirInterface environment variable OPENAIR1_DIR... '),
os.environ["OPENAIR1_DIR"]
except KeyError:
print (Fore.RED + 'FAILED')
print "Please set the environment variable OPENAIR1_DIR in the .bashrc or run 'source oaienv' "
exit_prog(1)
print (Fore.GREEN + 'OK')
try:
print (Fore.WHITE + ' - check OpenAirInterface environment variable OPENAIR2_DIR... '),
os.environ["OPENAIR2_DIR"]
except KeyError:
print (Fore.RED + 'FAILED')
print "Please set the environment variable OPENAIR2_DIR in the .bashrc or run 'source oaienv' "
exit_prog(1)
print (Fore.GREEN + 'OK')
try:
os.environ["OPENAIR_TARGETS"]
except KeyError:
print "Please set the environment variable OPENAIR_TARGETS in the .bashrc or run 'source oaienv' "
sexit_prog(1)
print (Fore.WHITE + ' - kill zombie ssh sessions from earlier sessions... '),
cmd='ps aux |grep \"/usr/bin/ssh -q -l ' + user + '\"| tr -s \" \" :| cut -f 2 -d :| xargs kill -9 '
os.system(cmd)
print (Fore.GREEN + 'DONE')
if flag_start_testcase == False:
print "You need to start the testcase by passing option -s. Use -h to see all options. Aborting now..."
exit_prog(1)
#print "Killing zombie ssh sessions from earlier sessions..."
#cmd='ps aux |grep \"/usr/bin/ssh -q -l guptar\"|tr -s \" \" :|cut -f 2 -d :|xargs kill -9 '
#cmd = cmd + '; ps aux |grep \"/usr/bin/ssh -q -l ' + user + '\"| tr -s \" \" :| cut -f 2 -d :| xargs kill -9 '
#os.system(cmd)
#print cmd
try:
analyser = __import__("lib_autotest_analyser")
except ImportError as err:
print('Import error: ' + str(err))
exit(0)
if flag_remove_logdir == True:
print "Removing directory: " + locallogdir
os.system(' rm -fr ' + locallogdir + '; mkdir -p ' + locallogdir )
if not os.path.exists(locallogdir):
os.system('mkdir -p ' + locallogdir )
paramiko_logfile = os.path.expandvars('$OPENAIR_DIR/cmake_targets/autotests/log/paramiko.log')
res=os.system(' echo > ' + paramiko_logfile)
paramiko.util.log_to_file(paramiko_logfile)
#
# 'REMOTE MACHINE SANITY CHEKS'
# ---------------------------------------------------------------------------------
print (Fore.YELLOW + '\nStep 0.3 - REMOTE MACHINE SANITY CHEKS')
print (Fore.YELLOW + '-------------------------------------------------')
for machine in MachineList:
oai_list.append( openair('localdomain',machine))
MachineDescDic[machine]={}
#index = index + 1
print "\nTesting the sanity of machines used for testing..."
if localshell == 0:
if not flag_skip_sanity_check:
if localshell == 0:
try:
index=0
for machine in MachineList:
print '\n******* Note that the user <'+user+'> should be a sudoer *******\n'
print '******* Connecting to the machine <'+machine+'> to perform the test *******\n'
if not pw :
print "username: " + user
#pw = getpass.getpass()
#print "password: " + pw
else :
print "username: " + user
#print "password: " + pw
# issues in ubuntu 12.04
print (Fore.WHITE + " - Check sanity for remote machine "+machine)
oai_list[index].connect(user,pw)
print '\nChecking for sudo permissions on machine <'+machine+'>...'
print (Fore.WHITE + " > Checking for sudo permissions for user "+user+ " : "),
result = oai_list[index].send_expect_false('sudo -S -v','may not run sudo',True)
print "Sudo permissions..." + result
if (result == 'OK'):
print (Fore.GREEN + result )
else:
print (Fore.RED + result )
print '\nCleaning Older running programs : ' + CleanUpOldProgs
print (Fore.WHITE + " > Cleaning Older running programs : "),
cleanOldPrograms(oai_list[index], CleanUpOldProgs, CleanUpAluLteBox, ExmimoRfStop, '$HOME', '/tmp')
print (Fore.WHITE + " Done")
#result = oai_list[index].send('mount ' + NFSResultsDir, True)
#print "Mounting NFS Share " + NFSResultsDir + "..." + result
......@@ -2032,14 +2212,22 @@ if localshell == 0:
except :
print 'Fail to connect to the machine: '+ machine
sys.exit(1)
else:
else:
pw = ''
oai_list[0].connect_localshell()
else:
print (Fore.RED + " Skipping Machine sanity check...")
#
# 'REMOTE MACHINE TEST SETUP CONFIGURATION'
# ---------------------------------------------------------------------------------
print (Fore.YELLOW + '\nStep 0.4 - REMOTE MACHINE PREPARATION')
print (Fore.YELLOW + '-------------------------------------------------')
#We now prepare the machines for testing
index=0
threads_init_setup=[]
for oai in oai_list:
if not flag_skip_machine_preparation:
index=0
threads_init_setup=[]
for oai in oai_list:
try:
print "setting up machine: " + MachineList[index]
#print oai_list[oai].send_recv('echo \''+pw+'\' |sudo -S -v')
......@@ -2048,6 +2236,7 @@ for oai in oai_list:
#cleanUpPrograms(oai_list[oai]
cmd = 'sudo -S -E rm -fr ' + logdir + ' ; mkdir -p ' + logdir
result = oai.send_recv(cmd)
print cmd
setuplogfile = logdir + '/setup_log_' + MachineList[index] + '_.txt'
setup_script = locallogdir + '/setup_script_' + MachineList[index] + '_.txt'
......@@ -2061,7 +2250,6 @@ for oai in oai_list:
sftp_log = os.path.expandvars(locallogdir + '/sftp_module.log')
sftp_module (user, pw, MachineList[index], port, paramList, sftp_log)
cmd = ' ( \n'
#cmd = cmd + 'rm -fR ' + logdir + '\n'
#cmd = cmd + 'mkdir -p ' + logdir + '\n'
......@@ -2072,7 +2260,8 @@ for oai in oai_list:
cmd = cmd + logdir + '/git-retry.sh clone '+ GitOpenaircnRepo + ' \n'
cmd = cmd + 'cd ' + logdirOAI5GRepo + '\n'
cmd = cmd + 'git checkout ' + GitOAI5GRepoBranch + '\n'
#cmd = cmd + 'git checkout ' + GitOAI5GHeadVersion + '\n'
if GitOAI5GHeadVersion :
cmd = cmd + 'git checkout ' + GitOAI5GHeadVersion + '\n'
cmd = cmd + 'git_head=`git ls-remote |grep \'' + GitOAI5GRepoBranch + '\'` \n'
cmd = cmd + 'git_head=($git_head) \n'
cmd = cmd + 'git_head=${git_head[0]} \n'
......@@ -2115,29 +2304,29 @@ for oai in oai_list:
print error
sys.exit(1)
#Now we wait for all the threads to complete
index = 0
for t in threads_init_setup:
#Now we wait for all the threads to complete
index = 0
for t in threads_init_setup:
t.join()
setuplogfile = logdir + '/setup_log_' + MachineList[index] + '_.txt'
setup_script = locallogdir + '/setup_script_' + MachineList[index] + '_.txt'
localfile = locallogdir + '/setup_log_' + MachineList[index] + '_.txt'
remotefile = logdir + '/setup_log_' + MachineList[index] + '_.txt'
port = 22
paramList=[]
sftp_log = os.path.expandvars(locallogdir + '/sftp_module.log')
#Now we copy patch files and apply them
print "Installating patch files on machine " + MachineList[index]
print( Fore.WHITE + " - Installating patch files on machine " + MachineList[index])
for patchFile in OAI5GpatchFileList:
localfile = os.path.expandvars('$OPENAIR_DIR/cmake_targets/autotests/patches/')+patchFile.get('name')
remotefile = logdirOAI5GRepo + '/cmake_targets/autotests/patches/'+patchFile.get('name')
if patchFile.get('machine') == MachineList[index] or patchFile.get('machine') == None:
if os.path.isfile(localfile):
print "\t> PATCH FILE :"+localfile
print( Fore.WHITE + "\t> PATCH FILE :"+localfile)
paramList=[]
paramList.append ( {"operation":'put', "localfile":localfile, "remotefile":remotefile} )
sftp_module (user, pw, MachineList[index], port, paramList, sftp_log)
cmd = ' cd ' + logdirOAI5GRepo + ' ;git apply cmake_targets/autotests/patches/'+patchFile.get('name')
res = oai_list[index].send_recv(cmd)
#print res
paramList=[]
......@@ -2152,10 +2341,12 @@ for t in threads_init_setup:
#Now we copy test_case_list.xml on the remote machines
localfile = os.path.expandvars('$OPENAIR_DIR/cmake_targets/autotests/test_case_list.xml')
remotefile = logdirOAI5GRepo + '/cmake_targets/autotests/test_case_list.xml'
paramList.append ( {"operation":'put', "localfile":localfile, "remotefile":remotefile} )
sftp_log = os.path.expandvars(locallogdir + '/sftp_module.log')
# paramList.append ( {"operation":'put', "localfile":localfile, "remotefile":remotefile} )
# sftp_module (user, pw, MachineList[index], port, paramList, sftp_log)
sftp_module (user, pw, MachineList[index], port, paramList, sftp_log)
cmd = ' cd ' + logdirOAI5GRepo + ' ; source oaienv ; env|grep OPENAIR \n'
res = oai_list[index].send_recv(cmd)
index = index +1
......@@ -2163,30 +2354,131 @@ for t in threads_init_setup:
print "Setup log file <" + localfile + "> missing for machine <" + MachineList[index] + ">. Please check the setup log files. Exiting now"
sys.exit(1)
#Now we process all the test cases
#Now we check if there was error in setup files
#Now we process all the test cases
#Now we check if there was error in setup files
status, out = commands.getstatusoutput('grep ' + ' -il \'error\' ' + locallogdir + '/setup_log*')
if (out != '') :
status, out = commands.getstatusoutput('grep ' + ' -il \'error\' ' + locallogdir + '/setup_log*')
if (out != '') :
print "There is error in setup of machines"
print "status = " + str(status) + "\n Check files for error = " + out
print "Exiting now..."
sys.exit(1)
cleanOldProgramsAllMachines(oai_list, CleanUpOldProgs, CleanUpAluLteBox, ExmimoRfStop, '$HOME' , logdirOAI5GRepo)
if cleanUpRemoteMachines == True:
cleanOldProgramsAllMachines(oai_list, CleanUpOldProgs, CleanUpAluLteBox, ExmimoRfStop, '$HOME' , logdirOAI5GRepo)
if cleanUpRemoteMachines == True:
print "Error while cleaning Remote machines"
print "Exiting now..."
sys.exit(0)
threadListGlobal=[]
else:
print (Fore.RED + " Skipping Machine preparation...")
# **************************************************************************
# **************************************************************************
# STEP 2 - TEST SELECTION AND PARAMETRIZATION
# **************************************************************************
# **************************************************************************
print (Fore.YELLOW + '\nStep 2 - TEST SELECTION')
print (Fore.YELLOW + '-------------------------------------------------')
print (Fore.WHITE + " Parsing test case list for test selection...")
print (Fore.WHITE + " - TestCaseExclusionList : "+TestCaseExclusionList)
print (Fore.WHITE + " - testcasegroup : "+testcasegroup)
testcaseList=xmlRoot.findall('testCase')
#print testcaseList
nb_total_testcases = 0
nb_total_testcases_softmodem = 0
nb_total_testcases_softmodem_noS1 = 0
nb_total_testcases_compilation = 0
nb_total_testcases_execution = 0
nb_run_testcases = 0
nb_run_testcases_softmodem = 0
nb_run_testcases_softmodem_noS1 = 0
nb_run_testcases_compilation = 0
nb_run_testcases_execution = 0
for testcase in testcaseList:
try:
testcasename = testcase.get('id')
testcaseclass = testcase.findtext('class',default='')
desc = testcase.findtext('desc',default='')
nb_total_testcases+=1
run_flag = search_test_case_group(testcasename, testcasegroup, TestCaseExclusionList)
if (run_flag):
nb_run_testcases+=1
if testcaseclass == 'lte-softmodem' :
nb_total_testcases_softmodem+=1
if (run_flag): nb_run_testcases_softmodem+=1
elif testcaseclass == 'lte-softmodem-noS1':
nb_total_testcases_softmodem_noS1+=1
if (run_flag): nb_run_testcases_softmodem_noS1+=1
elif testcaseclass == 'compilation':
nb_total_testcases_compilation+=1
if (run_flag): nb_run_testcases_compilation+=1
elif testcaseclass == 'execution':
nb_total_testcases_execution+=1
if (run_flag): nb_run_testcases_execution+=1
else :
print "Unknown test case class: " + testcaseclass
sys.exit()
except Exception, e:
error=''
error = error + ' In function: ' + sys._getframe().f_code.co_name + ': *** Caught exception: ' + str(e.__class__) + " : " + str( e)
error = error + '\n testcasename = ' + testcasename + '\n testcaseclass = ' + testcaseclass + '\n desc = ' + 'desc' + '\n'
error = error + traceback.format_exc()
print error
print "Continuing to next test case..."
print (Fore.WHITE + " Parsing done...")
print (Fore.WHITE + " - Total number of test cases : "+str(nb_total_testcases))
print (Fore.WHITE + " - Total number class softmodem : "+str(nb_total_testcases_softmodem))
print (Fore.WHITE + " - Total number class softmodem-noS1 : "+str(nb_total_testcases_softmodem_noS1))
print (Fore.WHITE + " - Total number class compilation : "+str(nb_total_testcases_compilation))
print (Fore.WHITE + " - Total number class execution : "+str(nb_total_testcases_execution))
print
print (Fore.WHITE + " - Selected number of test cases : "+str(nb_run_testcases))
print (Fore.WHITE + " - Selected class softmodem : "+str(nb_run_testcases_softmodem))
print (Fore.WHITE + " - Selected class softmodem_noS1 : "+str(nb_run_testcases_softmodem_noS1))
print (Fore.WHITE + " - Selected class compilation : "+str(nb_run_testcases_compilation))
print (Fore.WHITE + " - Selected class execution : "+str(nb_run_testcases_execution))
# **************************************************************************
# **************************************************************************
# STEP 3 - TEST CAMPAIGNS
# **************************************************************************
# **************************************************************************
test_results = []
print (Fore.YELLOW + '\nStep 3 - TEST CAMPAIGNS')
print (Fore.YELLOW + '-------------------------------------------------')
print (Fore.WHITE + " Start test campaign...")
threadListGlobal=[]
run_count = 0
for testcase in testcaseList:
try:
testcasename = testcase.get('id')
testcaseclass = testcase.findtext('class',default='')
desc = testcase.findtext('desc',default='')
#print "Machine list top level = " + ','.join(MachineList)
if search_test_case_group(testcasename, testcasegroup, TestCaseExclusionList) == True:
run_count+=1
print (Fore.WHITE + " ("+str(run_count).zfill(3)+"/"+str(nb_run_testcases).zfill(3)+") - test case "+testcasename+" : "),
if testcaseclass == 'lte-softmodem' :
eNBMachine = testcase.findtext('eNB',default='')
UEMachine = testcase.findtext('UE',default='')
......@@ -2258,6 +2550,22 @@ for param in threadListGlobal:
thread_id = param["thread_id"]
thread_id.join()
# **************************************************************************
# **************************************************************************
# STEP 4 - TEST REPORT PRODUCTION
# **************************************************************************
# **************************************************************************
test_session_stop_time = datetime.datetime.now()
print (Fore.YELLOW + '\nStep 4 - TEST REPORT PRODUCTION')
print (Fore.YELLOW + '-------------------------------------------------')
# XML test report
# --------------------------------------------------------------------
print "Creating xml file for overall results..."
cmd = "cat $OPENAIR_DIR/cmake_targets/autotests/log/*/*.xml > $OPENAIR_DIR/cmake_targets/autotests/log/results_autotests.xml "
res=os.system(cmd)
......@@ -2276,4 +2584,43 @@ res = oai_localhost.send_recv(cmd)
oai_localhost.disconnect()
# HTML test report
# --------------------------------------------------------------------
if flag_generate_html_report:
print "Creating html test report..."
report_dir = reportdir + '/'+ test_session_start_time.strftime("%Y-%m-%d_%H-%M")+"_"+host
cmd = 'mkdir -p ' + report_dir
result = os.system(cmd)
cmd = 'cp -r '+locallogdir+' '+report_dir
result = os.system(cmd)
context = {
'report_path' : report_dir,
'test_session_start_time' : test_session_start_time,
'test_session_stop_time' : test_session_stop_time,
'test_session_duration' : test_session_stop_time-test_session_start_time,
'mtc_host' : host,
'user' : user,
'password' : pw,
'test_results' : test_results,
}
for test_result in test_results:
cmd = 'mkdir -p ' + report_dir + '/'+ test_result['testcase_name']
result = os.system(cmd)
report_file = report_dir + '/'+ test_result['testcase_name'] + '/'+ test_result['testcase_name']+ '_report.html'
analyser.create_test_report_detailed_html(test_result, report_file )
# print test_result
analyser.create_report_html(context)
sys.exit()
#! /usr/bin/python
#******************************************************************************
# OpenAirInterface
# Copyright(c) 1999 - 2014 Eurecom
# OpenAirInterface is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# OpenAirInterface is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with OpenAirInterface.The full GNU General Public License is
# included in this distribution in the file called "COPYING". If not,
# see <http://www.gnu.org/licenses/>.
# Contact Information
# OpenAirInterface Admin: openair_admin@eurecom.fr
# OpenAirInterface Tech : openair_tech@eurecom.fr
# OpenAirInterface Dev : openair4g-devel@lists.eurecom.fr
# Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
# *******************************************************************************/
# \author Rohit Gupta
#/*
# * 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.0 (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
# */
# \author Rohit Gupta - Benoit ROBERT (benoit.robert@syrtem.com)
# \version 0.1
# @ingroup _test
#******************************************************************************
#
# \file run_lte-softmodem-nos1_tests.py
#
# \par Informations
# - \b Project : UED Autotest Framework
# - \b Software :
#
# \date 16 september 2016
#
# \version 0.1
#
# \brief master test script to run test class 'handle_testcaseclass_softmodem_noS1'
# This script is largely inspired by 'run_exec_lte-softmodem_tests.py', and
# reused parts of it.
#
# \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.
#
# *******************************************************************************
# \Changelog
# 2016-11-18 :
# - Add progess bar during test execution update_progress()
import tempfile
import threading
......@@ -79,6 +41,8 @@ import math #from time import clock
import xml.etree.ElementTree as ET
import re
#from dict2xml import dict2xml as xmlify
from colorama import Fore, Back, Style
import numpy as np
......@@ -100,6 +64,31 @@ from ssh import SSHSession
import argparse
# update_progress() : Displays or updates a console progress bar
## Accepts a float between 0 and 1. Any int will be converted to a float.
## A value under 0 represents a 'halt'.
## A value at 1 or bigger represents 100%
def update_progress(progress, prefix_string):
barLength = 20 # Modify this to change the length of the progress bar
status = ""
#print "progress = "+ str(progress)
if isinstance(progress, int):
progress = float(progress)
if not isinstance(progress, float):
progress = 0
status = "error: progress var must be float\r\n"
if progress < 0:
progress = 0
status = "Halt...\r\n"
if progress >= 1:
progress = 1
status = "Done...\r\n"
block = int(round(barLength*progress))
text = "\r"+prefix_string+" [{0}] {1}% {2}".format( "="*block + " "*(barLength-block), progress*100, status)
sys.stdout.write(text)
sys.stdout.flush()
def exit_prog(exit_val):
print(Style.RESET_ALL),
sys.exit(exit_val)
......@@ -318,7 +307,7 @@ def update_config_file(oai, config_string, logdirRepo, python_script):
# \param logdir_local_base local directory
# \param operation operation to perform (get_all, put_all) transfers recursively for directories
def SSHSessionWrapper(machine, username, key_file, password, logdir_remote, logdir_local_base, operation):
max_tries = 100
max_tries = 10
i=0
while i <= max_tries:
i = i +1
......@@ -648,7 +637,7 @@ def handle_testcaseclass_softmodem (testcase, oldprogramList, logdirOAI5GRepo ,
RRH_pre_exec_args = testcase.findtext('RRH_pre_exec_args',default='')
RRH_main_exec = testcase.findtext('RRH_main_exec',default='')
RRH_main_exec_args = testcase.findtext('RRH_main_exec_args',default='')
RRH_terminate_missing_procs = testcase.findtext('RRH_terminate_missing_procs',default='True')
RRH_terminate_missing_procs = testcase.findtext('RRH_terminate_missing_procs',default='False')
eNBMachine = testcase.findtext('eNB',default='')
......@@ -661,7 +650,7 @@ def handle_testcaseclass_softmodem (testcase, oldprogramList, logdirOAI5GRepo ,
eNB_main_exec_args = testcase.findtext('eNB_main_exec_args',default='')
eNB_traffic_exec = testcase.findtext('eNB_traffic_exec',default='')
eNB_traffic_exec_args = testcase.findtext('eNB_traffic_exec_args',default='')
eNB_terminate_missing_procs = testcase.findtext('eNB_terminate_missing_procs',default='True')
eNB_terminate_missing_procs = testcase.findtext('eNB_terminate_missing_procs',default='False')
eNB_search_expr_true = testcase.findtext('eNB_search_expr_true','')
if re.compile('\w+').match(eNB_search_expr_true) != None:
eNB_search_expr_true = eNB_search_expr_true + ' duration=' + str(timeout_cmd-90) + 's'
......@@ -676,7 +665,7 @@ def handle_testcaseclass_softmodem (testcase, oldprogramList, logdirOAI5GRepo ,
UE_main_exec_args = testcase.findtext('UE_main_exec_args',default='')
UE_traffic_exec = testcase.findtext('UE_traffic_exec',default='')
UE_traffic_exec_args = testcase.findtext('UE_traffic_exec_args',default='')
UE_terminate_missing_procs = testcase.findtext('UE_terminate_missing_procs',default='True')
UE_terminate_missing_procs = testcase.findtext('UE_terminate_missing_procs',default='False')
UE_search_expr_true = testcase.findtext('UE_search_expr_true','')
UE_stop_script = testcase.findtext('UE_stop_script','')
if re.compile('\w+').match(UE_search_expr_true) != None:
......@@ -697,25 +686,23 @@ def handle_testcaseclass_softmodem (testcase, oldprogramList, logdirOAI5GRepo ,
HSS_main_exec_args = testcase.findtext('HSS_main_exec_args',default='')
EPC_traffic_exec = testcase.findtext('EPC_traffic_exec',default='')
EPC_traffic_exec_args = testcase.findtext('EPC_traffic_exec_args',default='')
EPC_terminate_missing_procs = testcase.findtext('EPC_terminate_missing_procs',default='True')
EPC_terminate_missing_procs = testcase.findtext('EPC_terminate_missing_procs',default='False')
EPC_search_expr_true = testcase.findtext('EPC_search_expr_true','')
if re.compile('\w+').match(EPC_search_expr_true) != None:
EPC_search_expr_true = EPC_search_expr_true + ' duration=' + str(timeout_cmd-90) + 's'
index_eNBMachine = MachineList.index(eNBMachine)
index_UEMachine = MachineList.index(UEMachine)
# index_EPCMachine = MachineList.index(EPCMachine)
index_EPCMachine = MachineList.index(EPCMachine)
cmd = 'cd ' + logdirOAI5GRepo + '; source oaienv ; env|grep OPENAIR'
oai_eNB = openair('localdomain', eNBMachine)
oai_eNB.connect(user, password)
res= oai_eNB.send_recv(cmd)
oai_UE = openair('localdomain', UEMachine)
oai_UE.connect(user, password)
# print cmd
res = oai_UE.send_recv(cmd)
# print res
# oai_EPC = openair('localdomain', EPCMfachine)
# oai_EPC.connect(user, password)
res = oai_eNB.send_recv(cmd)
oai_EPC = openair('localdomain', EPCMachine)
oai_EPC.connect(user, password)
res = oai_eNB.send_recv(cmd)
if RRHMachine != '':
cmd = 'cd ' + logdirOAI5GRepo + '; source oaienv ; env|grep OPENAIR'
......@@ -735,9 +722,7 @@ def handle_testcaseclass_softmodem (testcase, oldprogramList, logdirOAI5GRepo ,
#cmd = 'mkdir -p ' + logdir_eNB
#result = oai_eNB.send_recv(cmd)
#cmd = 'mkdir -p ' + logdir_UE
#print cmd
#result = oai_UE.send_recv(cmd)
#print result
#cmd = 'mkdir -p ' + logdir_EPC
#result = oai_EPC.send_recv(cmd)
......@@ -764,11 +749,9 @@ def handle_testcaseclass_softmodem (testcase, oldprogramList, logdirOAI5GRepo ,
cmd = 'rm -fr ' + logdir_eNB + ' ; mkdir -p ' + logdir_eNB
result = oai_eNB.send_recv(cmd)
cmd = 'rm -fr ' + logdir_UE + ' ; mkdir -p ' + logdir_UE
# print cmd
result = oai_UE.send_recv(cmd)
# print result
cmd = 'rm -fr ' + logdir_EPC + '; mkdir -p ' + logdir_EPC
# result = oai_EPC.send_recv(cmd)
result = oai_EPC.send_recv(cmd)
cmd = ' rm -fr ' + logdir_local_testcase + ' ; mkdir -p ' + logdir_local_testcase
result = os.system(cmd)
......@@ -919,17 +902,17 @@ def handle_testcaseclass_softmodem (testcase, oldprogramList, logdirOAI5GRepo ,
logfile_task_EPC_compile = logdir_local_testcase + '/EPC_task_compile' + '_' + str(run) + '_.log'
logfile_local_traffic_EPC_out = logdir_local_testcase + '/EPC_traffic' + '_' + str(run) + '_.log'
# task_EPC_compile = ' ( uname -a ; date \n'
# task_EPC_compile = task_EPC_compile + 'array_exec_pid=()' + '\n'
# task_EPC_compile = task_EPC_compile + 'cd ' + logdirOpenaircnRepo + ' ; source oaienv \n'
# task_EPC_compile = task_EPC_compile + update_config_file(oai_EPC, EPC_config_file, logdirOpenaircnRepo, logdirOpenaircnRepo+'/TEST/autotests/tools/search_repl.py') + '\n'
# task_EPC_compile = task_EPC_compile + 'source BUILD/TOOLS/build_helper \n'
# if EPC_compile_prog != "":
# task_EPC_compile = task_EPC_compile + '(' + EPC_compile_prog + ' ' + EPC_compile_prog_args + ' ) > ' + logfile_compile_EPC + ' 2>&1 \n'
# if HSS_compile_prog != "":
# task_EPC_compile = task_EPC_compile + '(' + HSS_compile_prog + ' ' + HSS_compile_prog_args + ' ) > ' + logfile_compile_HSS + ' 2>&1 \n'
# task_EPC_compile = task_EPC_compile + ' ) > ' + logfile_task_EPC_compile_out + ' 2>&1 '
# write_file(logfile_task_EPC_compile, task_EPC_compile, mode="w")
task_EPC_compile = ' ( uname -a ; date \n'
task_EPC_compile = task_EPC_compile + 'array_exec_pid=()' + '\n'
task_EPC_compile = task_EPC_compile + 'cd ' + logdirOpenaircnRepo + ' ; source oaienv \n'
task_EPC_compile = task_EPC_compile + update_config_file(oai_EPC, EPC_config_file, logdirOpenaircnRepo, logdirOpenaircnRepo+'/TEST/autotests/tools/search_repl.py') + '\n'
task_EPC_compile = task_EPC_compile + 'source BUILD/TOOLS/build_helper \n'
if EPC_compile_prog != "":
task_EPC_compile = task_EPC_compile + '(' + EPC_compile_prog + ' ' + EPC_compile_prog_args + ' ) > ' + logfile_compile_EPC + ' 2>&1 \n'
if HSS_compile_prog != "":
task_EPC_compile = task_EPC_compile + '(' + HSS_compile_prog + ' ' + HSS_compile_prog_args + ' ) > ' + logfile_compile_HSS + ' 2>&1 \n'
task_EPC_compile = task_EPC_compile + ' ) > ' + logfile_task_EPC_compile_out + ' 2>&1 '
write_file(logfile_task_EPC_compile, task_EPC_compile, mode="w")
task_EPC = ' ( uname -a ; date \n'
task_EPC = task_EPC + ' export OPENAIRCN_TESTDIR=' + logdir_EPC + '\n'
......@@ -960,8 +943,9 @@ def handle_testcaseclass_softmodem (testcase, oldprogramList, logdirOAI5GRepo ,
task_EPC = task_EPC + ' ) > ' + logfile_task_EPC_out + ' 2>&1 '
write_file(logfile_task_EPC, task_EPC, mode="w")
#first we compile all the programs
# thread_EPC = oaiThread(1, "EPC_thread", EPCMachine, user, password , task_EPC_compile, False, timeout_thread)
#first we compile all the programs but only for run_0
if run == 0:
thread_EPC = oaiThread(1, "EPC_thread", EPCMachine, user, password , task_EPC_compile, False, timeout_thread)
thread_eNB = oaiThread(2, "eNB_thread", eNBMachine, user, password , task_eNB_compile, False, timeout_thread)
thread_UE = oaiThread(3, "UE_thread", UEMachine, user, password , task_UE_compile, False, timeout_thread)
if RRHMachine != '':
......@@ -969,13 +953,13 @@ def handle_testcaseclass_softmodem (testcase, oldprogramList, logdirOAI5GRepo ,
threads=[]
threads.append(thread_eNB)
threads.append(thread_UE)
# threads.append(thread_EPC)
threads.append(thread_EPC)
if RRHMachine != '':
threads.append(thread_RRH)
# Start new Threads
thread_eNB.start()
thread_UE.start()
# thread_EPC.start()
thread_EPC.start()
if RRHMachine != '':
thread_RRH.start()
#Wait for all the compile threads to complete
......@@ -983,7 +967,7 @@ def handle_testcaseclass_softmodem (testcase, oldprogramList, logdirOAI5GRepo ,
t.join()
#Now we execute all the threads
# thread_EPC = oaiThread(1, "EPC_thread", EPCMachine, user, password , task_EPC, False, timeout_thread)
thread_EPC = oaiThread(1, "EPC_thread", EPCMachine, user, password , task_EPC, False, timeout_thread)
thread_eNB = oaiThread(2, "eNB_thread", eNBMachine, user, password , task_eNB, False, timeout_thread)
thread_UE = oaiThread(3, "UE_thread", UEMachine, user, password , task_UE, False, timeout_thread)
if RRHMachine != '':
......@@ -991,14 +975,14 @@ def handle_testcaseclass_softmodem (testcase, oldprogramList, logdirOAI5GRepo ,
threads=[]
threads.append(thread_eNB)
threads.append(thread_UE)
# threads.append(thread_EPC)
threads.append(thread_EPC)
if RRHMachine != '':
threads.append(thread_RRH)
# Start new Threads
thread_eNB.start()
thread_UE.start()
# thread_EPC.start()
thread_EPC.start()
if RRHMachine != '':
thread_RRH.start()
#Wait for all the compile threads to complete
......@@ -1008,8 +992,7 @@ def handle_testcaseclass_softmodem (testcase, oldprogramList, logdirOAI5GRepo ,
if RRHMachine != '':
cleanOldProgramsAllMachines([oai_eNB, oai_UE, oai_EPC, oai_RRH] , oldprogramList, CleanUpAluLteBox, ExmimoRfStop, [logdir_eNB, logdir_UE, logdir_EPC, logdir_RRH], logdirOAI5GRepo)
else:
cleanOldProgramsAllMachines([oai_eNB, oai_UE] , oldprogramList, CleanUpAluLteBox, ExmimoRfStop, [logdir_eNB, logdir_UE, logdir_EPC], logdirOAI5GRepo)
# cleanOldProgramsAllMachines([oai_eNB, oai_UE, oai_EPC] , oldprogramList, CleanUpAluLteBox, ExmimoRfStop, [logdir_eNB, logdir_UE, logdir_EPC], logdirOAI5GRepo)
cleanOldProgramsAllMachines([oai_eNB, oai_UE, oai_EPC] , oldprogramList, CleanUpAluLteBox, ExmimoRfStop, [logdir_eNB, logdir_UE, logdir_EPC], logdirOAI5GRepo)
logfile_UE_stop_script_out = logdir_UE + '/UE_stop_script_out' + '_' + str(run) + '_.log'
logfile_UE_stop_script = logdir_local_testcase + '/UE_stop_script' + '_' + str(run) + '_.log'
......@@ -1020,32 +1003,30 @@ def handle_testcaseclass_softmodem (testcase, oldprogramList, logdirOAI5GRepo ,
cmd = cmd + UE_stop_script + '\n'
cmd = cmd + ') > ' + logfile_UE_stop_script_out + ' 2>&1 '
write_file(logfile_UE_stop_script , cmd, mode="w")
# thread_UE = oaiThread(4, "UE_thread", UEMachine, user, password , cmd, False, timeout_thread)
# thread_UE.start()
# thread_UE.join()
thread_UE = oaiThread(4, "UE_thread", UEMachine, user, password , cmd, False, timeout_thread)
thread_UE.start()
thread_UE.join()
#Now we change the permissions of the logfiles to avoid some of them being with root permissions
cmd = 'sudo -E chown -R ' + user + ' ' + logdir_eNB
res= oai_eNB.send_recv(cmd)
# print "Changing permissions of logdir <" + logdir_eNB + "> in eNB machine..." + res
print "Changing permissions of logdir <" + logdir_eNB + "> in eNB machine..." + res
cmd = 'sudo -E chown -R ' + user + ' ' + logdir_UE
# print cmd
res= oai_UE.send_recv(cmd)
# print res
# print "Changing permissions of logdir <" + logdir_UE + "> in UE machine..." + res
print "Changing permissions of logdir <" + logdir_UE + "> in UE machine..." + res
cmd = 'sudo -E chown -R ' + user + ' ' + logdir_EPC
# res= oai_EPC.send_recv(cmd)
# print "Changing permissions of logdir <" + logdir_EPC + "> in EPC machine..." + res
res= oai_EPC.send_recv(cmd)
print "Changing permissions of logdir <" + logdir_EPC + "> in EPC machine..." + res
if RRHMachine != '':
cmd = 'sudo -E chown -R ' + user + ' ' + logdir_RRH
res= oai_RRH.send_recv(cmd)
# print "Changing permissions of logdir <" + logdir_RRH + "> in RRH machine..." + res
print "Changing permissions of logdir <" + logdir_RRH + "> in RRH machine..." + res
print "Copying files from EPCMachine : " + EPCMachine + "logdir_EPC = " + logdir_EPC
# SSHSessionWrapper(EPCMachine, user, None, password, logdir_EPC, logdir_local + '/cmake_targets/autotests/log/'+ testcasename, "get_all")
SSHSessionWrapper(EPCMachine, user, None, password, logdir_EPC, logdir_local + '/cmake_targets/autotests/log/'+ testcasename, "get_all")
print "Copying files from eNBMachine " + eNBMachine + "logdir_eNB = " + logdir_eNB
SSHSessionWrapper(eNBMachine, user, None, password, logdir_eNB, logdir_local + '/cmake_targets/autotests/log/'+ testcasename, "get_all")
......@@ -1089,6 +1070,13 @@ def handle_testcaseclass_softmodem (testcase, oldprogramList, logdirOAI5GRepo ,
run_result=0
run_result_string = ' RUN_'+str(run) + ' = FAIL(Thread_Busy)'
#If there is Segmentation fault, we mark the test case as failure as most likely eNB crashed
cmd = "grep -ilr \"segmentation fault\" " + logdir_local_testcase + " | cat "
cmd_out = subprocess.check_output ([cmd], shell=True)
if len(cmd_out) !=0:
run_result=0
run_result_string = ' RUN_'+str(run) + ' = FAIL(SEGFAULT)'
run_result_string = run_result_string + tput_run_string
test_result=test_result & run_result
......@@ -1096,7 +1084,7 @@ def handle_testcaseclass_softmodem (testcase, oldprogramList, logdirOAI5GRepo ,
oai_eNB.disconnect()
oai_UE.disconnect()
# oai_EPC.disconnect()
oai_EPC.disconnect()
#We need to close the new ssh session that was created
#if index_eNBMachine == index_EPCMachine:
# oai_EPC.disconnect()
......@@ -1113,6 +1101,7 @@ def handle_testcaseclass_softmodem (testcase, oldprogramList, logdirOAI5GRepo ,
# \brief handler for executing test cases (lte-softmodem-noS1)
# \param testcase name of testcase
# \param oldprogramList list of programs which must be terminated before running a test case
......@@ -1329,6 +1318,8 @@ def handle_testcaseclass_softmodem_noS1 (testcase, oldprogramList, logdirOAI5GRe
if testcase_verdict != 'PASS': # if something went wrong to not run test cases
max_ntries=0
indent="\t\t"
runs_results = []
nb_runs = 0
nb_run_pass = 0
......@@ -1348,9 +1339,11 @@ def handle_testcaseclass_softmodem_noS1 (testcase, oldprogramList, logdirOAI5GRe
#
# RUN initialization
# ----------------------------------------------------
print (Fore.WHITE + indent + "> RUN_"+str(run).zfill(2)+" : " ),
sys.stdout.flush()
prefix_string = Fore.WHITE + indent + "> RUN_"+str(run).zfill(2)+" :"
# print (Fore.WHITE + indent + "> RUN_"+str(run).zfill(2)+" : " ),
# sys.stdout.flush()
run_start_time=datetime.datetime.now()
......@@ -1466,9 +1459,35 @@ def handle_testcaseclass_softmodem_noS1 (testcase, oldprogramList, logdirOAI5GRe
threads.append(thread_UE)
thread_eNB.start()
thread_UE.start()
run_work_inprogress_flag = True
progress_step = timeout_thread/20
progress_count = 0
while (run_work_inprogress_flag):
update_progress(float(progress_count)/float(timeout_thread),prefix_string)
time.sleep(progress_step)
progress_count += progress_step
# sys.stdout.write ('#')
# sys.stdout.flush()
run_work_inprogress_flag = False
for t in threads:
if t.isAlive():
run_work_inprogress_flag = True
update_progress(1,prefix_string)
for t in threads:
t.join()
#
#
#-----------------------------------------------------
......@@ -1482,10 +1501,12 @@ def handle_testcaseclass_softmodem_noS1 (testcase, oldprogramList, logdirOAI5GRe
fname = logdir_local_run+ '/UE_exec' + '_' + str(run) + '_.log'
cell_synch_status = analyser.check_cell_synchro(fname)
print (Fore.WHITE + indent + "> Check Cell synchro :"),
if cell_synch_status == 'CELL_SYNCH':
print '!!!!!!!!!!!!!! Cell synchronized !!!!!!!!!!!'
print ( Fore.GREEN + cell_synch_status)
else :
print '!!!!!!!!!!!!!! Cell NOT NOT synchronized !!!!!!!!!!!'
print ( Fore.RED + cell_synch_status)
metric_checks_flag = 0
ue_seg_fault_status = analyser.check_exec_seg_fault(fname)
......@@ -1504,6 +1525,9 @@ def handle_testcaseclass_softmodem_noS1 (testcase, oldprogramList, logdirOAI5GRe
# UE side metrics
metricList=testcase.findall('UE_metric')
for metric in metricList:
metric_verdict = 'PASS'
metric_def = {}
metric_def['id'] = metric.get('id')
metric_def['description'] = metric.get('description')
......@@ -1524,15 +1548,19 @@ def handle_testcaseclass_softmodem_noS1 (testcase, oldprogramList, logdirOAI5GRe
metric_extracted = analyser.do_extract_metrics(args)
print "\t > Metric "+metric_def['id']+" :"
print "\t\t> min = "+ str( metric_extracted['metric_min'] )
print "\t\t> min_index = "+ str( metric_extracted['metric_min_index'] )
print "\t\t> max = "+ str( metric_extracted['metric_max'] )
print "\t\t> max_index = "+ str( metric_extracted['metric_max_index'] )
print "\t\t> mean = "+ str( metric_extracted['metric_mean'] )
print "\t\t> median = "+ str( metric_extracted['metric_median'] )
print (Fore.WHITE + indent + "> Metric : "+metric_def['id']),
print ("(min="+str( metric_extracted['metric_min'])+", max="+str( metric_extracted['metric_max'])+", mean="+str( metric_extracted['metric_mean'])+", median="+str( metric_extracted['metric_median'])+")")
# print "\t > Metric "+metric_def['id']+" :"
# print "\t\t> min = "+ str( metric_extracted['metric_min'] )
# print "\t\t> min_index = "+ str( metric_extracted['metric_min_index'] )
# print "\t\t> max = "+ str( metric_extracted['metric_max'] )
# print "\t\t> max_index = "+ str( metric_extracted['metric_max_index'] )
# print "\t\t> mean = "+ str( metric_extracted['metric_mean'] )
# print "\t\t> median = "+ str( metric_extracted['metric_median'] )
verdict = analyser.do_check_verdict(metric_def, metric_extracted)
if metric_def['pass_fail_stat'] :
metric_verdict = analyser.do_check_verdict(metric_def, metric_extracted)
metric_fig = logdir_local_run+ '/UE_metric_'+ metric_def['id']+'_' + str(run) + '_.png'
analyser.do_img_metrics(metric_def, metric_extracted, metric_fig)
......@@ -1560,6 +1588,13 @@ def handle_testcaseclass_softmodem_noS1 (testcase, oldprogramList, logdirOAI5GRe
runs_metrics.append(run_metrics)
if metric_verdict != 'PASS':
verdict = metric_verdict
# End Metrics LOOP
# ---------------------
# Traffic analysis
if UE_traffic_exec != "":
......@@ -1645,6 +1680,8 @@ def handle_testcaseclass_softmodem_noS1 (testcase, oldprogramList, logdirOAI5GRe
# END RUN LOOP
#----------------------------------------------------
indent="\t"
# Test case duration
# ----------------------------------
testcase_time_stop = datetime.datetime.now()
......@@ -1684,11 +1721,9 @@ def handle_testcaseclass_softmodem_noS1 (testcase, oldprogramList, logdirOAI5GRe
else:
print (Fore.YELLOW+'INCONCLUSIVE')
duration= testcase_time_stop - testcase_time_start
xmlFile = logdir_local_testcase + '/test.' + testcasename + '.xml'
xml="\n<testcase classname=\'"+ testcaseclass + "\' name=\'" + testcasename + "."+tags + "\' Run_result=\'" + test_result_string + "\' time=\'" + str(duration) + " s \' RESULT=\'" + testcase_verdict + "\'></testcase> \n"
write_file(xmlFile, xml, mode="w")
print(Style.RESET_ALL)
duration= testcase_time_stop - testcase_time_start
test_result = dict(testcase_name=testcasename,
testcaseclass=testcaseclass,
......@@ -1709,158 +1744,17 @@ def handle_testcaseclass_softmodem_noS1 (testcase, oldprogramList, logdirOAI5GRe
runs_results = runs_results)
test_results.append(test_result)
return testcase_verdict
# mypassword=''
# #addsudo = 'echo \'' + mypassword + '\' | sudo -S -E '
# addpass = 'echo \'' + mypassword + '\' | '
# #user = getpass.getuser()
# eNB_traffic_exec = testcase.findtext('eNB_traffic_exec',default='')
# eNB_traffic_exec_args = testcase.findtext('eNB_traffic_exec_args',default='')
# eNB_terminate_missing_procs = testcase.findtext('eNB_terminate_missing_procs',default='True')
# eNB_search_expr_true = testcase.findtext('eNB_search_expr_true','')
# if re.compile('\w+').match(eNB_search_expr_true) != None:
# eNB_search_expr_true = eNB_search_expr_true + ' duration=' + str(timeout_cmd-90) + 's'
# UE_traffic_exec = testcase.findtext('UE_traffic_exec',default='')
# UE_traffic_exec_args = testcase.findtext('UE_traffic_exec_args',default='')
#
# UE_search_expr_true = testcase.findtext('UE_search_expr_true','')
# UE_stop_script = testcase.findtext('UE_stop_script','')
# if re.compile('\w+').match(UE_search_expr_true) != None:
# UE_search_expr_true = UE_search_expr_true + ' duration=' + str(timeout_cmd-90) + 's'
# #cleanOldPrograms(oai_eNB, oldprogramList, CleanUpAluLteBox, ExmimoRfStop)
# #cleanOldPrograms(oai_UE, oldprogramList, CleanUpAluLteBox, ExmimoRfStop)
# #cleanOldPrograms(oai_EPC, oldprogramList, CleanUpAluLteBox, ExmimoRfStop)
# logdir_local = os.environ.get('OPENAIR_DIR')
# if logdir_local is None:
# print "Environment variable OPENAIR_DIR not set correctly"
# sys.exit()
# print "Updating the config files for ENB/UE/EPC..."
# #updating the eNB/UE/EPC configuration file from the test case
# #update_config_file(oai_eNB, eNB_config_file, logdirOAI5GRepo)
# #update_config_file(oai_UE, UE_config_file, logdirOAI5GRepo)
# #update_config_file(oai_EPC, EPC_config_file, logdirOpenaircnRepo)
# test_result=1
# test_result_string=''
# start_time=time.time()
# for run in range(0,nruns):
# run_result=1
# run_result_string=''
# logdir_eNB = logdirOAI5GRepo+'/cmake_targets/autotests/log/'+ testcasename + '/run_' + str(run)
# logdir_UE = logdirOAI5GRepo+'/cmake_targets/autotests/log/'+ testcasename +
# logfile_traffic_eNB = logdir_eNB + '/eNB_traffic' + '_' + str(run) + '_.log'
# logfile_local_traffic_eNB_out = logdir_local_testcase + '/eNB_traffic' + '_' + str(run) + '_.log'
# logfile_tshark_eNB = logdir_eNB + '/eNB_tshark' + '_' + str(run) + '_.log'
# logfile_pcap_eNB = logdir_eNB + '/eNB_tshark' + '_' + str(run) + '_.pcap'
# logfile_pcap_zip_eNB = logdir_eNB + '/eNB_tshark' + '_' + str(run) + '_.pcap.zip'
# logfile_pcap_tmp_eNB = '/tmp/' + '/eNB_tshark' + '_' + str(run) + '_.pcap'
# task_eNB_compile = ' ( uname -a ; date \n'
# task_eNB_compile = task_eNB_compile + 'cd ' + logdirOAI5GRepo + ' ; source oaienv ; source cmake_targets/tools/build_helper \n'
# task_eNB_compile = task_eNB_compile + 'env |grep OPENAIR \n'
# task_eNB_compile = task_eNB_compile + update_config_file(oai_eNB, eNB_config_file, logdirOAI5GRepo, '$OPENAIR_DIR/cmake_targets/autotests/tools/search_repl.py') + '\n'
# if eNB_compile_prog != "":
# task_eNB_compile = task_eNB_compile + ' ( ' + eNB_compile_prog + ' '+ eNB_compile_prog_args + ' ) > ' + logfile_compile_eNB + ' 2>&1 \n'
# task_eNB_compile = task_eNB_compile + ' date ) > ' + logfile_task_eNB_compile_out + ' 2>&1 '
# write_file(logfile_task_eNB_compile, task_eNB_compile, mode="w")
# #task_eNB = 'echo \" ' + task_eNB + '\" > ' + logfile_script_eNB + ' 2>&1 ; ' + task_eNB
# logfile_compile_UE = logdir_UE + '/UE_compile' + '_' + str(run) + '_.log'
# logfile_exec_UE = logdir_UE + '/UE_exec' + '_' + str(run) + '_.log'
# #Now we execute all the threads
# #Now we get the log files from remote machines on the local machine
# cleanOldProgramsAllMachines([oai_eNB, oai_UE] , oldprogramList, CleanUpAluLteBox, ExmimoRfStop, [logdir_eNB, logdir_UE, logdir_EPC], logdirOAI5GRepo)
# logfile_UE_stop_script_out = logdir_UE + '/UE_stop_script_out' + '_' + str(run) + '_.log'
# logfile_UE_stop_script = logdir_local_testcase + '/UE_stop_script' + '_' + str(run) + '_.log'
# if UE_stop_script != "":
# cmd = ' ( uname -a ; date \n'
# cmd = cmd + 'cd ' + logdirOAI5GRepo + ' ; source oaienv ; source cmake_targets/tools/build_helper \n'
# cmd = cmd + 'env |grep OPENAIR \n' + 'array_exec_pid=() \n'
# cmd = cmd + UE_stop_script + '\n'
# cmd = cmd + ') > ' + logfile_UE_stop_script_out + ' 2>&1 '
# write_file(logfile_UE_stop_script , cmd, mode="w")
# # thread_UE = oaiThread(4, "UE_thread", UEMachine, user, password , cmd, False, timeout_thread)
# # thread_UE.start()
# # thread_UE.join()
# #Currently we only perform throughput tests
# tput_run_string=''
# result, tput_string = tput_test_search_expr(eNB_search_expr_true, logfile_local_traffic_eNB_out)
# tput_run_string = tput_run_string + tput_string
# run_result=run_result&result
# result, tput_string = tput_test_search_expr(EPC_search_expr_true, logfile_local_traffic_EPC_out)
# run_result=run_result&result
# tput_run_string = tput_run_string + tput_string
# result, tput_string = tput_test_search_expr(UE_search_expr_true, logfile_local_traffic_UE_out)
# run_result=run_result&result
# tput_run_string = tput_run_string + tput_string
# if run_result == 1:
# run_result_string = ' RUN_'+str(run) + ' = PASS'
# else:
# run_result_string = ' RUN_'+str(run) + ' = FAIL'
# #If there is assertion, we mark the test case as failure as most likely eNB crashed
# cmd = "grep -ilr \"assertion\" " + logdir_local_testcase + " | cat "
# cmd_out = subprocess.check_output ([cmd], shell=True)
# if len(cmd_out) !=0 :
# run_result=0
# run_result_string = ' RUN_'+str(run) + ' = FAIL(Assert)'
# #If there is thread busy error, we mark the test case as failure as most likely eNB crashed
# cmd = "grep -ilr \"thread busy\" " + logdir_local_testcase + " | cat "
# cmd_out = subprocess.check_output ([cmd], shell=True)
# if len(cmd_out) !=0:
# run_result=0
# run_result_string = ' RUN_'+str(run) + ' = FAIL(Thread_Busy)'
# run_result_string = run_result_string + tput_run_string
# test_result=test_result & run_result
# test_result_string=test_result_string + run_result_string
xmlFile = logdir_local_testcase + '/test.' + testcasename + '.xml'
xml="\n<testcase classname=\'"+ testcaseclass + "\' name=\'" + testcasename + "."+tags + "\' Run_result=\'" + test_result_string + "\' time=\'" + str(duration) + " s \' RESULT=\'" + testcase_verdict + "\'></testcase> \n"
write_file(xmlFile, xml, mode="w")
xmlFile_ng = logdir_local_testcase + '/test.' + testcasename + '_ng.xml'
xml_ng = xmlify(test_result, wrap=testcasename, indent=" ")
write_file(xmlFile_ng, xml_ng, mode="w")
return testcase_verdict
......@@ -1982,7 +1876,7 @@ flag_skip_oai_install=False
flag_skip_machine_preparation=False
flag_skip_sanity_check=False
Timeout_cmd=''
xmlInputFile=os.environ.get('OPENAIR_DIR')+"/cmake_targets/autotests/testsuite_ue_noS1.xml"
xmlInputFile=''
#print "Number of arguments argc = " + str(len(sys.argv))
#for index in range(1,len(sys.argv) ):
......@@ -2054,6 +1948,9 @@ while i < len (sys.argv):
flag_skip_machine_preparation=True
elif arg == '--skip-sanity-check':
flag_skip_sanity_check=True
elif arg == '--test-suite' :
xmlInputFile = sys.argv[i+1]
i = i +1
elif arg == '-h' :
print "-s: This flag *MUST* be set to start the test cases"
print "-r: Remove the log directory in autotests"
......@@ -2073,6 +1970,7 @@ while i < len (sys.argv):
print "--skip-oai-install: Skips the openairinterface5g installer"
print "--skip-machine-preparation: skipp the whole system preparation -> direct to test cases"
print "--skip-sanity-check: skipp the machine sanity checks"
print "--test-suite: Select a XML test-suite file"
sys.exit()
else :
print "Unrecongnized Option: <" + arg + ">. Use -h to see valid options"
......@@ -2163,7 +2061,7 @@ print (Fore.WHITE + ' + Timeout_cmd : '+ Timeout_cmd)
if GitOAI5GHeadVersion == '':
cmd = "git log --pretty=format:\'%H\' -n 1 origin/"+ GitOAI5GRepoBranch
cmd = "git log --pretty=format:\'%H\' -n 1" # origin/"+ GitOAI5GRepoBranch
# cmd = "git show-ref --heads -s "+ GitOAI5GRepoBranch
GitOAI5GHeadVersion = subprocess.check_output ([cmd], shell=True)
GitOAI5GHeadVersion=GitOAI5GHeadVersion.replace("\n","")
......@@ -2337,13 +2235,24 @@ if not flag_skip_machine_preparation:
setuplogfile = logdir + '/setup_log_' + MachineList[index] + '_.txt'
setup_script = locallogdir + '/setup_script_' + MachineList[index] + '_.txt'
#Sometimes git fails so the script below retries in that case
localfile = os.path.expandvars('$OPENAIR_DIR/cmake_targets/autotests/tools/git-retry.sh')
remotefile = logdir + '/git-retry.sh'
paramList=[]
port=22
paramList.append ( {"operation":'put', "localfile":localfile, "remotefile":remotefile} )
sftp_log = os.path.expandvars(locallogdir + '/sftp_module.log')
sftp_module (user, pw, MachineList[index], port, paramList, sftp_log)
cmd = ' ( \n'
#cmd = cmd + 'rm -fR ' + logdir + '\n'
#cmd = cmd + 'mkdir -p ' + logdir + '\n'
cmd = cmd + 'cd '+ logdir + '\n'
cmd = cmd + 'git config --global http.sslVerify false \n'
cmd = cmd + 'git clone '+ GitOAI5GRepo +' \n'
cmd = cmd + 'git clone '+ GitOpenaircnRepo + ' \n'
cmd = cmd + 'sudo apt-get install -y git \n'
cmd = cmd + 'chmod 700 ' + logdir + '/git-retry.sh \n'
cmd = cmd + logdir + '/git-retry.sh clone '+ GitOAI5GRepo +' \n'
cmd = cmd + logdir + '/git-retry.sh clone '+ GitOpenaircnRepo + ' \n'
cmd = cmd + 'cd ' + logdirOAI5GRepo + '\n'
cmd = cmd + 'git checkout ' + GitOAI5GRepoBranch + '\n'
if GitOAI5GHeadVersion :
......@@ -2399,9 +2308,8 @@ if not flag_skip_machine_preparation:
paramList=[]
sftp_log = os.path.expandvars(locallogdir + '/sftp_module.log')
#Now we copy patch files for u
#Now we copy patch files and apply them
print( Fore.WHITE + " - Installating patch files on machine " + MachineList[index])
#Now we copy patch files for u
for patchFile in OAI5GpatchFileList:
localfile = os.path.expandvars('$OPENAIR_DIR/cmake_targets/autotests/patches/')+patchFile.get('name')
remotefile = logdirOAI5GRepo + '/cmake_targets/autotests/patches/'+patchFile.get('name')
......@@ -2417,19 +2325,20 @@ if not flag_skip_machine_preparation:
paramList=[]
#Now we copy test_case_list.xml on the remote machines
localfile = os.path.expandvars('$OPENAIR_DIR/cmake_targets/autotests/test_case_list.xml')
remotefile = logdirOAI5GRepo + '/cmake_targets/autotests/test_case_list.xml'
# paramList.append ( {"operation":'put', "localfile":localfile, "remotefile":remotefile} )
# sftp_module (user, pw, MachineList[index], port, paramList, sftp_log)
setuplogfile = logdir + '/setup_log_' + MachineList[index] + '_.txt'
setup_script = locallogdir + '/setup_script_' + MachineList[index] + '_.txt'
localfile = locallogdir + '/setup_log_' + MachineList[index] + '_.txt'
remotefile = logdir + '/setup_log_' + MachineList[index] + '_.txt'
sftp_log = os.path.expandvars(locallogdir + '/sftp_module.log')
paramList.append ( {"operation":'get', "localfile":localfile, "remotefile":remotefile} )
#sftp_module (user, pw, MachineList[index], port, localfile, remotefile, sftp_log, "get")
#Now we copy test_case_list.xml on the remote machines
localfile = os.path.expandvars('$OPENAIR_DIR/cmake_targets/autotests/test_case_list.xml')
remotefile = logdirOAI5GRepo + '/cmake_targets/autotests/test_case_list.xml'
# paramList.append ( {"operation":'put', "localfile":localfile, "remotefile":remotefile} )
# sftp_module (user, pw, MachineList[index], port, paramList, sftp_log)
sftp_module (user, pw, MachineList[index], port, paramList, sftp_log)
......@@ -2456,6 +2365,7 @@ if not flag_skip_machine_preparation:
print "Exiting now..."
sys.exit(0)
else:
print (Fore.RED + " Skipping Machine preparation...")
......@@ -2558,21 +2468,65 @@ for testcase in testcaseList:
try:
testcasename = testcase.get('id')
testcaseclass = testcase.findtext('class',default='')
desc = testcase.findtext('desc',default='')
#print "Machine list top level = " + ','.join(MachineList)
if (search_test_case_group(testcasename, testcasegroup, TestCaseExclusionList)):
if search_test_case_group(testcasename, testcasegroup, TestCaseExclusionList) == True:
run_count+=1
print (Fore.WHITE + " ("+str(run_count).zfill(3)+"/"+str(nb_run_testcases).zfill(3)+") - test case "+testcasename+" : "),
if testcaseclass == 'lte-softmodem' :
print (Fore.RED + "skipped - lte-softmodem class not supported")
elif testcaseclass == 'lte-softmodem-noS1':
print
eNBMachine = testcase.findtext('eNB',default='')
UEMachine = testcase.findtext('UE',default='')
EPCMachine = testcase.findtext('EPC',default='')
#index_eNBMachine = MachineList.index(eNBMachine)
#index_UEMachine = MachineList.index(UEMachine)
#index_EPCMachine = MachineList.index(EPCMachine)
if (eNBMachine not in MachineList)|(UEMachine not in MachineList)|(UEMachine not in MachineList):
print "One of the machines is not in the machine list"
print "eNBMachine : " + eNBMachine + "UEMachine : " + UEMachine + "EPCMachine : " + EPCMachine + "MachineList : " + ','.join(MachineList)
print "testcasename = " + testcasename + " class = " + testcaseclass
threadListGlobal = wait_testcaseclass_generic_threads(threadListGlobal, Timeout_execution)
#cleanOldProgramsAllMachines(oai_list, CleanUpOldProgs, CleanUpAluLteBox, ExmimoRfStop)
handle_testcaseclass_softmodem (testcase, CleanUpOldProgs, logdirOAI5GRepo, logdirOpenaircnRepo, MachineList, user, pw, CleanUpAluLteBox, ExmimoRfStop, nruns_lte_softmodem, Timeout_cmd )
#The lines below are copied from below to trace the failure of some of the machines in test setup. These lines below need to be removed in long term
print "Creating xml file for overall results..."
cmd = "cat $OPENAIR_DIR/cmake_targets/autotests/log/*/*.xml > $OPENAIR_DIR/cmake_targets/autotests/log/results_autotests.xml "
res=os.system(cmd)
os.system('sync')
print "Now copying files to NFS Share"
oai_localhost = openair('localdomain','localhost')
oai_localhost.connect(user,pw)
cmd = ' mkdir -p ' + NFSTestsResultsDir
res = oai_localhost.send_recv(cmd)
print "Copying files from GilabCI Runner Machine : " + host + " .locallogdir = " + locallogdir + ", NFSTestsResultsDir = " + NFSTestsResultsDir
SSHSessionWrapper('localhost', user, None, pw , NFSTestsResultsDir , locallogdir, "put_all")
oai_localhost.disconnect()
elif testcaseclass == 'lte-softmodem-noS1' :
eNBMachine = testcase.findtext('eNB',default='')
UEMachine = testcase.findtext('UE',default='')
if (eNBMachine not in MachineList)|(UEMachine not in MachineList):
print "One of the machines is not in the machine list"
print "eNBMachine : " + eNBMachine + "UEMachine : " + UEMachine + "MachineList : " + ','.join(MachineList)
print "testcasename = " + testcasename + " class = " + testcaseclass
threadListGlobal = wait_testcaseclass_generic_threads(threadListGlobal, Timeout_execution)
handle_testcaseclass_softmodem_noS1 (testcase, CleanUpOldProgs, logdirOAI5GRepo, logdirOpenaircnRepo, MachineList, user, pw, CleanUpAluLteBox, ExmimoRfStop, nruns_lte_softmodem, Timeout_cmd )
elif testcaseclass == 'compilation':
print (Fore.RED + "skipped - compilation class not supported")
elif testcaseclass == 'execution':
print (Fore.RED + "skipped - execution class not supported")
#The lines below are copied from below to trace the failure of some of the machines in test setup. These lines below need to be removed in long term
print "Creating xml file for overall results..."
cmd = "cat $OPENAIR_DIR/cmake_targets/autotests/log/*/*.xml > $OPENAIR_DIR/cmake_targets/autotests/log/results_autotests.xml "
res=os.system(cmd)
os.system('sync')
elif (testcaseclass == 'compilation'):
threadListGlobal = handle_testcaseclass_generic (testcasename, threadListGlobal, CleanUpOldProgs, logdirOAI5GRepo, MachineListGeneric, user, pw, CleanUpAluLteBox,Timeout_execution, ExmimoRfStop)
elif (testcaseclass == 'execution'):
threadListGlobal = handle_testcaseclass_generic (testcasename, threadListGlobal, CleanUpOldProgs, logdirOAI5GRepo, MachineListGeneric, user, pw, CleanUpAluLteBox, Timeout_execution, ExmimoRfStop)
else :
print (Fore.RED + "Unknown test case class: " + testcaseclass)
print "Unknown test case class: " + testcaseclass
sys.exit()
except Exception, e:
......@@ -2582,8 +2536,14 @@ for testcase in testcaseList:
error = error + traceback.format_exc()
print error
print "Continuing to next test case..."
#sys.exit(1)
threadListGlobal=[]
print "Exiting the test cases execution now. Waiting for existing threads to complete..."
for param in threadListGlobal:
thread_id = param["thread_id"]
thread_id.join()
# **************************************************************************
......@@ -2633,153 +2593,3 @@ analyser.create_report_html(context)
exit_prog(0)
#print testcaseList
for testcase in testcaseList:
try:
testcasename = testcase.get('id')
testcaseclass = testcase.findtext('class',default='')
desc = testcase.findtext('desc',default='')
#print "Machine list top level = " + ','.join(MachineList)
if search_test_case_group(testcasename, testcasegroup, TestCaseExclusionList) == True:
if testcaseclass == 'lte-softmodem' :
eNBMachine = testcase.findtext('eNB',default='')
UEMachine = testcase.findtext('UE',default='')
EPCMachine = testcase.findtext('EPC',default='')
#index_eNBMachine = MachineList.index(eNBMachine)
#index_UEMachine = MachineList.index(UEMachine)
#index_EPCMachine = MachineList.index(EPCMachine)
if (eNBMachine not in MachineList)|(UEMachine not in MachineList)|(UEMachine not in MachineList):
print "One of the machines is not in the machine list"
print "eNBMachine : " + eNBMachine + "UEMachine : " + UEMachine + "EPCMachine : " + EPCMachine + "MachineList : " + ','.join(MachineList)
print "testcasename = " + testcasename + " class = " + testcaseclass
threadListGlobal = wait_testcaseclass_generic_threads(threadListGlobal, Timeout_execution)
#cleanOldProgramsAllMachines(oai_list, CleanUpOldProgs, CleanUpAluLteBox, ExmimoRfStop)
#handle_testcaseclass_softmodem (testcase, CleanUpOldProgs, logdirOAI5GRepo, logdirOpenaircnRepo, MachineList, user, pw, CleanUpAluLteBox, ExmimoRfStop, nruns_lte_softmodem, Timeout_cmd )
#The lines below are copied from below to trace the failure of some of the machines in test setup. These lines below need to be removed in long term
# print "Creating xml file for overall results..."
# cmd = "cat $OPENAIR_DIR/cmake_targets/autotests/log/*/*.xml > $OPENAIR_DIR/cmake_targets/autotests/log/results_autotests.xml "
# res=os.system(cmd)
# os.system('sync')
# print "Now copying files to NFS Share"
# oai_localhost = openair('localdomain','localhost')
# oai_localhost.connect(user,pw)
# cmd = ' mkdir -p ' + NFSTestsResultsDir
# print cmd
# res = oai_localhost.send_recv(cmd)
# print res
# print "Copying files from GilabCI Runner Machine : " + host + " .locallogdir = " + locallogdir + ", NFSTestsResultsDir = " + NFSTestsResultsDir
# SSHSessionWrapper('localhost', user, None, pw , NFSTestsResultsDir , locallogdir, "put_all")
# oai_localhost.disconnect()
elif (testcaseclass == 'compilation'):
threadListGlobal = handle_testcaseclass_generic (testcasename, threadListGlobal, CleanUpOldProgs, logdirOAI5GRepo, MachineListGeneric, user, pw, CleanUpAluLteBox,Timeout_execution, ExmimoRfStop)
elif (testcaseclass == 'execution'):
threadListGlobal = handle_testcaseclass_generic (testcasename, threadListGlobal, CleanUpOldProgs, logdirOAI5GRepo, MachineListGeneric, user, pw, CleanUpAluLteBox, Timeout_execution, ExmimoRfStop)
else :
print "Unknown test case class: " + testcaseclass
sys.exit()
except Exception, e:
error=''
error = error + ' In function: ' + sys._getframe().f_code.co_name + ': *** Caught exception: ' + str(e.__class__) + " : " + str( e)
error = error + '\n testcasename = ' + testcasename + '\n testcaseclass = ' + testcaseclass + '\n desc = ' + 'desc' + '\n'
error = error + traceback.format_exc()
print error
print "Continuing to next test case..."
#sys.exit(1)
print "Exiting the test cases execution now. Waiting for existing threads to complete..."
for param in threadListGlobal:
thread_id = param["thread_id"]
thread_id.join()
print "Creating xml file for overall results..."
cmd = "cat $OPENAIR_DIR/cmake_targets/autotests/log/*/*.xml > $OPENAIR_DIR/cmake_targets/autotests/log/results_autotests.xml "
res=os.system(cmd)
print "Now copying files to NFS Share"
oai_localhost = openair('localdomain','localhost')
oai_localhost.connect(user,pw)
cmd = 'mkdir -p ' + NFSTestsResultsDir
print cmd
res = oai_localhost.send_recv(cmd)
print res
print "Copying files from GilabCI Runner Machine : " + host + " .locallogdir = " + locallogdir + ", NFSTestsResultsDir = " + NFSTestsResultsDir
SSHSessionWrapper('localhost', user, None, pw , NFSTestsResultsDir , locallogdir, "put_all")
cmd = "cat " + NFSTestsResultsDir + "/log/*/*.xml > " + NFSTestsResultsDir + "/log/results_autotests.xml"
res = oai_localhost.send_recv(cmd)
oai_localhost.disconnect()
sys.exit()
run_count = 0
for testcase in testcaseList:
try:
testcasename = testcase.get('id')
testcaseclass = testcase.findtext('class',default='')
if (search_test_case_group(testcasename, testcasegroup, TestCaseExclusionList)):
run_count+=1
print (Fore.WHITE + " ("+str(run_count).zfill(3)+"/"+str(nb_run_testcases).zfill(3)+") - test case "+testcasename+" : "),
if testcaseclass == 'lte-softmodem' :
print (Fore.RED + "skipped - lte-softmodem class not supported")
elif testcaseclass == 'lte-softmodem-noS1':
print
testcase_verdict = 'PASS'
testcase_time_start = datetime.datetime.now()
testcase_name = testcase.get('id')
testcase_desc = testcase.findtext('desc',default='')
timeout_cmd = testcase.findtext('TimeOut_cmd',default='')
timeout_cmd = int(float(timeout_cmd))
timeout_thread = timeout_cmd + 300 #Timeout_thread is more than that of cmd to have room for compilation time, etc
if nruns_lte_softmodem == '':
nruns = testcase.findtext('nruns',default='')
else:
nruns = nruns_lte_softmodem
nruns = int(float(nruns))
tags = testcase.findtext('tags',default='')
testcase_time_stop = datetime.datetime.now()
test_result = dict(testcase_name=testcase_name,
testcaseclass=testcaseclass,
testcase_verdict = testcase_verdict,
testcase_time_start=testcase_time_start,
testcase_time_stop=testcase_time_stop,
tags=tags,
nruns=nruns,
testcase_timeout=timeout_cmd,
testcase_duration = testcase_time_stop-testcase_time_start,
testcase_eNBMachine ="TOTO",
testcase_UEMachine ="TITI")
test_results.append(test_result)
elif testcaseclass == 'compilation':
print (Fore.RED + "skipped - compilation class not supported")
elif testcaseclass == 'execution':
print (Fore.RED + "skipped - execution class not supported")
else :
print (Fore.RED + "Unknown test case class: " + testcaseclass)
sys.exit()
except Exception, e:
error=''
error = error + ' In function: ' + sys._getframe().f_code.co_name + ': *** Caught exception: ' + str(e.__class__) + " : " + str( e)
error = error + '\n testcasename = ' + testcasename + '\n testcaseclass = ' + testcaseclass + '\n desc = ' + 'desc' + '\n'
error = error + traceback.format_exc()
print error
print "Continuing to next test case..."
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -35,12 +35,15 @@ import getopt
import sys
from subprocess import call
import encoder
sys.path.append(os.path.expandvars('$OPENAIR_DIR/cmake_targets/autotests/tools/'))
#test_cases = ('030001', '030901', '031001', '031601', '031701', '031801', '031901', '032001', '032101', '032201', '032301', '032501', '032601', '032801')
test_cases = ('030030' , '030030' )
test_cases = ('032800' , '032730' )
nb_run = 3
nb_run = 2
def error_opt(msg):
print("Option error: " + msg)
......@@ -58,14 +61,27 @@ def main(args):
# 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
#AUTOTEST Metric : RRC Measurments RSRP[0]=-97.60 dBm/RE, RSSI=-72.83 dBm, RSRQ[0] 9.03 dB, N0 -125 dBm/RE, NF 7.2 dB (frame = 4490)
metric = {}
metric['id'] = 'UE_DLSCH_BITRATE'
metric['description'] = 'UE downlink physical throughput'
metric['regex'] = '(UE_DLSCH_BITRATE) =\s+(\d+\.\d+) kbps.+frame = (\d+)\)'
metric['id'] = 'UE_DL_RRC_MEAS'
metric['description'] = 'UE downlink RRC Measurments'
metric['nb_metric'] = 5
# metric['regex'] = 'AUTOTEST Metric : RRC Measurments (RSRP\[0\])=(-?\d+\.?\d*)\s+(.+),\s+(RSRQ\[0\])=(-?\d+\.?\d*)\s+(.+),,\s+(N0)=(-?\d+\.?\d*)\s+(.+),,\s+(NF)=(-?\d+\.?\d*)\s+(.+)\s+\(frame = (\d+)\) '
metric['regex'] = 'AUTOTEST Metric : RRC Measurments (RSRP\[0\])=(-?\d+\.?\d*)\s+(.+)\,\s+(RSSI)=(-?\d+\.?\d*)\s+(.+)\,\s+(RSRQ\[0\])=(-?\d+\.?\d*)\s+(.+)\,\s+(N0)=(-?\d+\.?\d*)\s+(.+)\,\s+(NF)=(-?\d+\.?\d*)\s+(.+)\s+\(frame = (\d+)\)'
metric['unit_of_meas'] = 'kbps'
metric['min_limit'] = 14668.8
#report_path = log_path+'/report/'
#os.system(' mkdir -p ' + report_path)
......@@ -74,58 +90,44 @@ def main(args):
#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
test_results = []
for test_case in test_cases:
for i in range(0, nb_run):
fname = 'log//'+test_case+'/run_'+str(i)+'/UE_exec_'+str(i)+'_.log'
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 !!!!!!!!!!!'
# 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 !!!!!!!!!!!'
# metrics_extracted = analyser.do_extract_metrics_new(args)
# de-xmlfy test report
xml_file = '..//log//'+test_case+'/test.'+test_case+'_ng.xml'
print xml_file
# test_result =
# test_results.append(test_result)
# xmlFile = logdir_local_testcase + '/test.' + testcasename + '.xml'
# xml="\n<testcase classname=\'"+ testcaseclass + "\' name=\'" + testcasename + "."+tags + "\' Run_result=\'" + test_result_string + "\' time=\'" + str(duration) + " s \' RESULT=\'" + testcase_verdict + "\'></testcase> \n"
# write_file(xmlFile, xml, mode="w")
# xmlFile_ng = logdir_local_testcase + '/test.' + testcasename + '_ng.xml'
# xml_ng = xmlify(test_result, wrap=testcasename, indent=" ")
# write_file(xmlFile_ng, xml_ng, mode="w")
# metric_extracted = analyser.do_extract_metrics(args)
# print "min = "+ str( metric_extracted['metric_min'] )
# print "min_index = "+ str( metric_extracted['metric_min_index'] )
......@@ -143,16 +145,27 @@ def main(args):
# print fname
# analyser.do_img_metrics(metric, metric_extracted, fname)
# fname = 'log//'+test_case+'/run_'+str(i)+'/UE_traffic_'+str(i)+'_.log'
# fname = 'log//'+test_case+'/run_'+str(i)+'/UE_traffic_'+str(i)+'_.log'
# args = {'file' : fname }
# args = {'file' : fname }
# traffic_metrics = analyser.do_extract_traffic_metrics(args)
# traffic_metrics = analyser.do_extract_traffic_metrics(args)
# fname= 'report/iperf_'+test_case+'_'+str(i)+'.png'
# fname= 'report/iperf_'+test_case+'_'+str(i)+'.png'
# print fname
# analyser.do_img_traffic(traffic_metrics, fname)
# print fname
# analyser.do_img_traffic(traffic_metrics, fname)
for test_result in test_results:
cmd = 'mkdir -p ' + report_dir + '/'+ test_result['testcase_name']
result = os.system(cmd)
report_file = report_dir + '/'+ test_result['testcase_name'] + '/'+ test_result['testcase_name']+ '_report.html'
analyser.create_test_report_detailed_html(test_result, report_file )
print test_result
......
......@@ -41,7 +41,7 @@ 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')),
loader=FileSystemLoader(os.path.join(PATH, '../templates')),
trim_blocks=False)
......@@ -103,6 +103,129 @@ def do_extract_metrics(args):
}
return(ret)
def do_extract_metrics_new(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
toto = [('id', 'S20'), ('metric', np.float), ('frame', np.int)]
print toto
np_format = []
for x in range(0, metric['nb_metric']):
np_format.append( ('id'+str(x), 'S20') )
np_format.append( ('metric'+str(x), np.float) )
np_format.append( ('uom'+str(x), 'S20') )
np_format.append( ('frame', np.int))
print np_format
output = np.fromregex(fname,metric['regex'], np_format)
print output
count = output['frame'].size
print count
if count > 0:
fontP = FontProperties()
fontP.set_size('small')
fig = plt.figure(1)
plt.figure(figsize=(10,10))
plot_xmax = np.amax(output['frame'])+np.amin(output['frame'])
for x in range(0, metric['nb_metric']):
metric_name = output['id'+str(x)][0]
metric_uom = output['uom'+str(x)][0]
mmin = np.amin(output['metric'+str(x)])
mmax = np.amax(output['metric'+str(x)])
mmean = np.mean(output['metric'+str(x)])
mmedian = np.median(output['metric'+str(x)])
plot_loc = 100*metric['nb_metric']+10+x+1
sbplt = plt.subplot(plot_loc)
sbplt.plot(output['frame'], output['metric'+str(x)], color='b' )
sbplt.set_title( metric_name+' ('+metric_uom+')')
if mmin < 0:
sbplot_ymin=mmin+mmin/10
else:
sbplot_ymin=0
sbplt.set_ylim(ymin=sbplot_ymin)
if mmax > 0:
sbplot_ymax=mmax+mmax/10
else:
sbplot_ymax=0
sbplt.set_ylim(ymax=sbplot_ymax)
sbplt.set_xlim(xmax=plot_xmax)
sbplt.set_xlim(xmin=0)
text='min: '+str(mmin)+'\nmax: '+str(mmax)+'\nmean: '+str(mmean)+'\nmedian: '+str(mmedian)
sbplt.text( plot_xmax+10,sbplot_ymin,text)
sbplt.set_xlabel('frame')
sbplt.set_ylabel(metric_name)
plt.tight_layout()
fname = "toto.png"
# 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()
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)
#
#
#
......@@ -182,24 +305,30 @@ def do_img_metrics(metric_def, metric_data, fname):
# print output['metric'].size
plt.scatter(output['frame'], output['metric'], color='b', alpha=0.33, s = 1 , label=metric_def['id'])
if 'min_limit' in metric_def:
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.title(metric_def['id'] +' ('+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)
if metric_data['metric_min'] < 0:
plt.ylim(ymin=metric_data['metric_min']+metric_data['metric_min']/10)
else :
plt.ylim(ymin=0)
y_axis_max = 0
if 'min_limit' in metric_def:
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
else:
y_axis_max =metric_data['metric_max']+metric_data['metric_max']/10
plt.ylim(ymax=y_axis_max)
......@@ -219,9 +348,6 @@ def do_img_metrics(metric_def, metric_data, fname):
def do_extract_traffic_metrics(args):
print ""
print "do_extract_traffic_metrics ... "
fname = args['file']
# print(fname)
......@@ -325,7 +451,8 @@ def do_img_traffic(traffic_data, fname):
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)
ax1.set_xlabel('time (s)')
ax1.set_ylabel(' ')
ax2=plt.subplot(312)
plt.plot(output['interval_stop'], output['jitter'], color='b' )
......@@ -334,6 +461,8 @@ def do_img_traffic(traffic_data, fname):
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)
ax2.set_xlabel('time (s)')
ax2.set_ylabel(' ')
ax3=plt.subplot(313)
plt.plot(output['interval_stop'], output['rate_lost'], color='b')
......@@ -342,10 +471,11 @@ def do_img_traffic(traffic_data, fname):
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)
ax3.set_xlabel('time (s)')
ax3.set_ylabel(' ')
# plt.title('Physical throughput ('+metric_def['unit_of_meas']+')')
plt.xlabel('time (s)')
# plt.xlabel('time (s)')
# plt.ylabel(metric_def['id'])
# Set graphic minimum Y axis
......@@ -365,7 +495,7 @@ def do_img_traffic(traffic_data, fname):
plt.tight_layout()
lgd = plt.legend(prop=fontP, bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
# 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()
......@@ -395,7 +525,7 @@ def check_cell_synchro(fname):
m = re.search('AUTOTEST Cell Sync \:', line)
if m :
print line
#print line
return 'CELL_SYNCH'
return 'CELL_NOT_SYNCH'
......@@ -407,7 +537,7 @@ def check_exec_seg_fault(fname):
for line in f:
m = re.search('Segmentation fault', line)
if m :
print line
#print line
return 'SEG_FAULT'
return 'NO_SEG_FAULT'
......
......@@ -53,6 +53,7 @@ BUILD_DOXYGEN=0
T_TRACER="False"
DISABLE_HARDWARE_DEPENDENCY="False"
CMAKE_BUILD_TYPE=""
UE_AUTOTEST_TRACE="False"
trap handle_ctrl_c INT
function print_help() {
......@@ -127,6 +128,8 @@ Options
Enables the T tracer.
--disable-hardware-dependency
Disable HW dependency during installation
--ue-autotest-trace
Enable specific traces for UE autotest framework
Usage (first build):
oaisim (eNB + UE): ./build_oai -I --oaisim -x --install-system-files
Eurecom EXMIMO + COTS UE : ./build_oai -I --eNB -x --install-system-files
......@@ -278,6 +281,10 @@ function main() {
echo_info "Disabling hardware dependency for compiling software"
DISABLE_HARDWARE_DEPENDENCY="True"
shift 1;;
--ue-autotest-trace)
UE_AUTOTEST_TRACE="True"
echo_info "Enabling autotest specific trace for UE"
shift 1;;
-h | --help)
print_help
exit 1;;
......@@ -447,6 +454,7 @@ function main() {
echo "set (DEADLINE_SCHEDULER \"${DEADLINE_SCHEDULER_FLAG_USER}\" )" >>$cmake_file
echo "set (CPU_AFFINITY \"${CPU_AFFINITY_FLAG_USER}\" )" >>$cmake_file
echo "set ( T_TRACER $T_TRACER )" >> $cmake_file
echo "set (UE_AUTOTEST_TRACE $UE_AUTOTEST_TRACE)" >> $cmake_file
echo 'include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt)' >> $cmake_file
cd $DIR/$lte_build_dir/build
cmake ..
......
......@@ -486,7 +486,7 @@ void compute_beta8(llr_t* alpha,llr_t* beta,llr_t *m_11,llr_t* m_10,unsigned sho
#endif
if (frame_length > 6143) {
if (frame_length > 6144) {
LOG_E(PHY,"compute_beta: frame_length %d\n",frame_length);
return;
}
......@@ -972,6 +972,11 @@ unsigned char phy_threegpplte_turbo_decoder8(short *y,
} else
n2 = n;
if(n2<256)
{
printf("phy_threegpplte_turbo_decoder8 : frame length < 256\n");
return 255;
}
for (iind=0; iind < 188 && f1f2mat[iind].nb_bits != n; iind++);
......
......@@ -469,6 +469,15 @@ int initial_sync(PHY_VARS_UE *ue, runmode_t mode)
//#endif
if (ue->UE_scan_carrier == 0) {
#if UE_AUTOTEST_TRACE
LOG_I(PHY,"[UE %d] AUTOTEST Cell Sync : frame = %d, rx_offset %d, freq_offset %d \n",
ue->Mod_id,
ue->proc.proc_rxtx[0].frame_rx,
ue->rx_offset,
ue->common_vars.freq_offset );
#endif
if (ue->mac_enabled==1) {
LOG_I(PHY,"[UE%d] Sending synch status to higher layers\n",ue->Mod_id);
//mac_resynch();
......
......@@ -2944,6 +2944,13 @@ int phy_procedures_UE_RX(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin
LOG_D(PHY,"[UE %d] Calculating bitrate Frame %d: total_TBS = %d, total_TBS_last = %d, bitrate %f kbits\n",
ue->Mod_id,frame_rx,ue->total_TBS[eNB_id],
ue->total_TBS_last[eNB_id],(float) ue->bitrate[eNB_id]/1000.0);
#if UE_AUTOTEST_TRACE
if ((frame_rx % 100 == 0)) {
LOG_I(PHY,"[UE %d] AUTOTEST Metric : UE_DLSCH_BITRATE = %5.2f kbps (frame = %d) \n", ue->Mod_id, (float) ue->bitrate[eNB_id]/1000.0, frame_rx);
}
#endif
}
......
......@@ -1601,6 +1601,11 @@ int main( int argc, char **argv )
PHY_vars_eNB_g[0][CC_id] = init_lte_eNB(frame_parms[CC_id],0,frame_parms[CC_id]->Nid_cell,abstraction_flag);
PHY_vars_eNB_g[0][CC_id]->CC_id = CC_id;
PHY_vars_eNB_g[0][CC_id]->ue_dl_rb_alloc=0x1fff;
PHY_vars_eNB_g[0][CC_id]->target_ue_dl_mcs=target_dl_mcs;
PHY_vars_eNB_g[0][CC_id]->ue_ul_nb_rb=6;
PHY_vars_eNB_g[0][CC_id]->target_ue_ul_mcs=target_ul_mcs;
if (phy_test==1) PHY_vars_eNB_g[0][CC_id]->mac_enabled = 0;
else PHY_vars_eNB_g[0][CC_id]->mac_enabled = 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