Commit 0aeb77ce authored by Rohit Gupta's avatar Rohit Gupta

updates to test framework + bugfixes

parent 6e1e41db
...@@ -41,6 +41,8 @@ import os ...@@ -41,6 +41,8 @@ import os
import array import array
import shutil import shutil
import subprocess import subprocess
import sys
import traceback
# import call # import call
from core import * from core import *
...@@ -102,8 +104,12 @@ class openair(core): ...@@ -102,8 +104,12 @@ class openair(core):
self.oai.prompt() self.oai.prompt()
print self.oai.before print self.oai.before
except Error, val : except Exception, e:
print "Error: can't connect to"+username+"@"+self.address error=''
error = error + ' In function: ' + sys._getframe().f_code.co_name + ': *** Caught exception: ' + str(e.__class__) + " : " + str( e)
error = error + traceback.format_exc()
print error
sys.exit(1)
def connect2(self, username, password, prompt='$'): def connect2(self, username, password, prompt='$'):
self.prompt1 = prompt self.prompt1 = prompt
...@@ -133,9 +139,12 @@ class openair(core): ...@@ -133,9 +139,12 @@ class openair(core):
sys.exit(1) sys.exit(1)
return 'Ok' return 'Ok'
except Exception, val: except Exception, e:
time.sleep(5) error=''
print "Error:", val error = error + ' In function: ' + sys._getframe().f_code.co_name + ': *** Caught exception: ' + str(e.__class__) + " : " + str( e)
error = error + traceback.format_exc()
print error
sys.exit(1)
def connect_localshell(self, prompt='$'): def connect_localshell(self, prompt='$'):
self.prompt1 = prompt self.prompt1 = prompt
...@@ -152,9 +161,12 @@ class openair(core): ...@@ -152,9 +161,12 @@ class openair(core):
else : else :
sys.exit(1) sys.exit(1)
except Exception, val: except Exception, e:
time.sleep(5) error=''
print "Error:", val error = error + ' In function: ' + sys._getframe().f_code.co_name + ': *** Caught exception: ' + str(e.__class__) + " : " + str( e)
error = error + traceback.format_exc()
print error
sys.exit(1)
def disconnect(self): def disconnect(self):
print 'disconnecting the ssh connection to ' + self.address + '\n' print 'disconnecting the ssh connection to ' + self.address + '\n'
...@@ -173,8 +185,12 @@ class openair(core): ...@@ -173,8 +185,12 @@ class openair(core):
os.system('echo '+pw+' | sudo -S pkill cc1') os.system('echo '+pw+' | sudo -S pkill cc1')
time.sleep(1) time.sleep(1)
os.system('echo '+pw+' | sudo -S pkill oaisim oaisim_nos1') os.system('echo '+pw+' | sudo -S pkill oaisim oaisim_nos1')
except Error, val: except Exception, e:
print "Error:", val error=''
error = error + ' In function: ' + sys._getframe().f_code.co_name + ': *** Caught exception: ' + str(e.__class__) + " : " + str( e)
error = error + traceback.format_exc()
print error
sys.exit(1)
def rm_driver(self,oai,user, pw): def rm_driver(self,oai,user, pw):
try: try:
...@@ -184,8 +200,12 @@ class openair(core): ...@@ -184,8 +200,12 @@ class openair(core):
else : else :
oai.send_nowait('echo '+pw+ ' | sudo -S rmmod nasmesh;') oai.send_nowait('echo '+pw+ ' | sudo -S rmmod nasmesh;')
#os.system('echo '+pw+ ' | sudo -S rmmod nasmesh;') #os.system('echo '+pw+ ' | sudo -S rmmod nasmesh;')
except Error, val: except Exception, e:
print "Error removing oai network driver module:", val error=''
error = error + ' In function: ' + sys._getframe().f_code.co_name + ': *** Caught exception: ' + str(e.__class__) + " : " + str( e)
error = error + traceback.format_exc()
print error
sys.exit(1)
def driver(self,oai,user,pw): def driver(self,oai,user,pw):
#pwd = oai.send_recv('pwd') #pwd = oai.send_recv('pwd')
...@@ -197,8 +217,12 @@ class openair(core): ...@@ -197,8 +217,12 @@ class openair(core):
else : else :
oai.send('echo '+pw+ ' | sudo -S insmod ./nasmesh.ko;') oai.send('echo '+pw+ ' | sudo -S insmod ./nasmesh.ko;')
except Error, val: except Exception, e:
print "Error inserting oai network driver module:", val error=''
error = error + ' In function: ' + sys._getframe().f_code.co_name + ': *** Caught exception: ' + str(e.__class__) + " : " + str( e)
error = error + traceback.format_exc()
print error
sys.exit(1)
def cleandir (self, logdir,debug) : def cleandir (self, logdir,debug) :
...@@ -209,8 +233,12 @@ class openair(core): ...@@ -209,8 +233,12 @@ class openair(core):
print 'filepath is ' + filepath print 'filepath is ' + filepath
try: try:
shutil.rmtree(filepath) shutil.rmtree(filepath)
except OSError: except Exception, e:
os.remove(filepath) error=''
error = error + ' In function: ' + sys._getframe().f_code.co_name + ': *** Caught exception: ' + str(e.__class__) + " : " + str( e)
error = error + traceback.format_exc()
print error
sys.exit(1)
#print 'Could not remove the filepath'+ filepath + ' with error ' + OSError #print 'Could not remove the filepath'+ filepath + ' with error ' + OSError
def create_dir(self,dirname,debug) : def create_dir(self,dirname,debug) :
......
...@@ -107,6 +107,7 @@ function test_compile() { ...@@ -107,6 +107,7 @@ function test_compile() {
#mkdir -p $build_dir #mkdir -p $build_dir
cd $log_dir cd $log_dir
{ {
uname -a
compile_log_dir=`eval echo \"$OPENAIR_DIR/cmake_targets/log/\"` compile_log_dir=`eval echo \"$OPENAIR_DIR/cmake_targets/log/\"`
echo "Removing compilation log files in $compile_log_dir" echo "Removing compilation log files in $compile_log_dir"
rm -frv $compile_log_dir rm -frv $compile_log_dir
...@@ -236,6 +237,7 @@ function test_compile_and_run() { ...@@ -236,6 +237,7 @@ function test_compile_and_run() {
cd $log_dir cd $log_dir
{ {
uname -a
#eval $pre_compile_prog #eval $pre_compile_prog
#cmake .. #cmake ..
#rm -fv $exec_file #rm -fv $exec_file
...@@ -272,7 +274,7 @@ function test_compile_and_run() { ...@@ -272,7 +274,7 @@ function test_compile_and_run() {
fi fi
echo "Executing $main_exec $main_exec_args_array_index " echo "Executing $main_exec $main_exec_args_array_index "
echo "Executing $main_exec $main_exec_args_array_index " >> $temp_exec_log echo "Executing $main_exec $main_exec_args_array_index " >> $temp_exec_log
{ eval "$main_exec $main_exec_args_array_index" ;} >> $temp_exec_log 2>&1 { uname -a ; eval "$main_exec $main_exec_args_array_index" ;} >> $temp_exec_log 2>&1
echo "</EXECUTION LOG Test Case = $test_case_name.${tags_array[$tags_array_index]}, Run = $run_index >" >> $temp_exec_log 2>&1 echo "</EXECUTION LOG Test Case = $test_case_name.${tags_array[$tags_array_index]}, Run = $run_index >" >> $temp_exec_log 2>&1
cat $temp_exec_log >> $log_file 2>&1 cat $temp_exec_log >> $log_file 2>&1
...@@ -504,6 +506,8 @@ for search_expr in "${test_case_array[@]}" ...@@ -504,6 +506,8 @@ for search_expr in "${test_case_array[@]}"
} }
uname -a
main "$@" main "$@"
xUnit_write "$results_file" xUnit_write "$results_file"
......
...@@ -61,7 +61,8 @@ from openair import * ...@@ -61,7 +61,8 @@ from openair import *
import paramiko import paramiko
import ssh import ssh
from ssh import SSHSession from ssh import SSHSession
import subprocess
import commands
def write_file(filename, string, mode="w"): def write_file(filename, string, mode="w"):
text_file = open(filename, mode) text_file = open(filename, mode)
...@@ -107,6 +108,7 @@ def sftp_module (username, password, hostname, ports, paramList,logfile): ...@@ -107,6 +108,7 @@ def sftp_module (username, password, hostname, ports, paramList,logfile):
error = error + ' In function: ' + sys._getframe().f_code.co_name + ': *** Caught exception: ' + str(e.__class__) + " : " + str( e) error = error + ' In function: ' + sys._getframe().f_code.co_name + ': *** Caught exception: ' + str(e.__class__) + " : " + str( e)
error = error + '\n username = ' + username + '\n hostname = ' + hostname + '\n localfile = ' + localD + '\n remotefile = ' + remoteD + '\n operation = ' + operation + '\nlogfile = ' + logfile + '\n ports = ' + str(ports) + '\n' error = error + '\n username = ' + username + '\n hostname = ' + hostname + '\n localfile = ' + localD + '\n remotefile = ' + remoteD + '\n operation = ' + operation + '\nlogfile = ' + logfile + '\n ports = ' + str(ports) + '\n'
error = error + traceback.format_exc() error = error + traceback.format_exc()
print error
sftp.close() sftp.close()
transport.close() transport.close()
...@@ -195,27 +197,38 @@ class myThread (threading.Thread): ...@@ -195,27 +197,38 @@ class myThread (threading.Thread):
class oaiThread (threading.Thread): class oaiThread (threading.Thread):
def __init__(self, threadID, name, oai, cmd, sudo, timeout): def __init__(self, threadID, threadname, machine, username, password, cmd, sudo, timeout):
threading.Thread.__init__(self) threading.Thread.__init__(self)
self.threadID = threadID self.threadID = threadID
self.name = name self.threadname = threadname
#self.counter = counter self.machine = machine
self.oai = oai self.username = username
self.password = password
self.cmd = cmd self.cmd = cmd
self.sudo = sudo self.sudo = sudo
self.timeout = timeout self.timeout = timeout
self.machineName = machineName
def run(self): def run(self):
print "Starting " + self.name try:
result = self.oai.send_recv(self.cmd, self.sudo, self.timeout) oai = openair('localdomain',self.machine)
print "result = " + result oai.connect(user, self.password)
print "Exiting " + self.name 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
oai.disconnect()
except Exception, e:
error=''
error = error + ' In class oaiThread, function: ' + sys._getframe().f_code.co_name + ': *** Caught exception: ' + str(e.__class__) + " : " + str( e)
error = error + '\n threadID = ' + str(self.threadID) + '\n threadname = ' + self.threadname + '\n timeout = ' + self.timeout + '\n machine = ' + self.machine + '\n cmd = ' + self.cmd + '\n timeout = ' + str(self.timeout) + '\n'
error = error + traceback.format_exc()
print error
#This class runs test cases with class execution, compilatation #This class runs test cases with class execution, compilatation
class testCaseThread_generic (threading.Thread): class testCaseThread_generic (threading.Thread):
def __init__(self, threadID, name, machine, logdirOAI5GRepo, testcasename,oldprogramList, CleanupAluLteBox, password, timeout): def __init__(self, threadID, name, machine, logdirOAI5GRepo, testcasename,oldprogramList, CleanupAluLteBox, password, timeout):
threading.Thread.__init__(self) threading.Thread.__init__(self)
self.threaID = threadID self.threadID = threadID
self.name = name self.name = name
self.testcasename = testcasename self.testcasename = testcasename
self.timeout = timeout self.timeout = timeout
...@@ -231,36 +244,51 @@ class testCaseThread_generic (threading.Thread): ...@@ -231,36 +244,51 @@ class testCaseThread_generic (threading.Thread):
addpass = 'echo \'' + mypassword + '\' | ' addpass = 'echo \'' + mypassword + '\' | '
user = getpass.getuser() user = getpass.getuser()
print "Starting test case : " + self.testcasename + " On machine " + self.machine print "Starting test case : " + self.testcasename + " On machine " + self.machine
oai = openair('localdomain',machine) oai = openair('localdomain',self.machine)
oai.connect(user, self.password) oai.connect(user, self.password)
cleanOldPrograms(oai, oldprogramList, CleanUpAluLteBox) cleanOldPrograms(oai, self.oldprogramList, self.CleanupAluLteBox)
logdir_local = os.environ.get('OPENAIR_DIR') logdir_local = os.environ.get('OPENAIR_DIR')
logdir_local_testcase = logdir_local +'/cmake_targets/autotests/log/'+ self.testcasename logdir_local_testcase = logdir_local +'/cmake_targets/autotests/log/'+ self.testcasename
logdir_local_base = logdir_local +'/cmake_targets/autotests/log/' logdir_local_base = logdir_local +'/cmake_targets/autotests/log/'
logdir_remote_testcase = self.logdirOAI5GRepo + '/cmake_targets/autotests/log' + self.testcasename logdir_remote_testcase = self.logdirOAI5GRepo + '/cmake_targets/autotests/log/' + self.testcasename
logdir_remote = self.logdirOAI5GRepo + '/cmake_targets/autotests/log' logdir_remote = self.logdirOAI5GRepo + '/cmake_targets/autotests/log/'
logfile_task_testcasename = logdir_local_testcase + '/test_task' + '_' + testcasename + '_.log' logfile_task_testcasename = logdir_local_testcase + '/test_task' + '_' + self.testcasename + '_.log'
logfile_task_testcasename_out = logdir_remote + '/test_task_out' + '_' + str(run) + '_.log' logfile_task_testcasename_out = logdir_remote + '/test_task_out' + '_' + self.testcasename + '_.log'
os.removedirs(logdir_testcase) #print "logdir_local_testcase = " + logdir_local_testcase
os.mkdir (logdir_testcase) #print "logdir_remote_testcase = " + logdir_remote_testcase
cmd = "( cd " + self.logdirOAI5GRepo + " \n " #if os.path.exists(logdir_local_testcase) == True :
# os.removedirs(logdir_local_testcase)
#os.mkdir(logdir_local_testcase)
os.system("rm -fr " + logdir_local_testcase )
os.system("mkdir -p " + logdir_local_testcase)
cmd = "mkdir -p " + logdir_remote_testcase
res = oai.send_recv(cmd, False, self.timeout)
print "res = " + res
cmd = "( cd " + self.logdirOAI5GRepo + " \n "
cmd = cmd + "source oaienv \n" cmd = cmd + "source oaienv \n"
cmd = cmd + "$OPENAIR_DIR/cmake_targets/autotests/run_exec_autotets.bash --run-group \"" + "self.testcasename +\" " cmd = cmd + "$OPENAIR_DIR/cmake_targets/autotests/run_exec_autotests.bash --run-group \"" + self.testcasename + "\" -p \'\'"
cmd = cmd + " ) >& " + logfile_task_testcasename_out + " ; " + " mv " + logfile_task_testcasename_out + logdir_remote_testcase cmd = cmd + " ) >& " + logfile_task_testcasename_out + " ; " + "mkdir -p " + logdir_remote_testcase + "; mv " + logfile_task_testcasename_out + " " +logdir_remote_testcase
#print "cmd = " + cmd
res = oai.send_recv(cmd, False, self.timeout)
#print "res = " + res
print "ThreadID = " + str(self.threadID) + "ThreadName: " + self.name + " testcasename: " + self.testcasename + "Execution Result = " + res
write_file(logfile_task_testcasename, cmd, mode="w") write_file(logfile_task_testcasename, cmd, mode="w")
#Now we copy all the remote files #Now we copy all the remote files
ssh = SSHSession(self.machine , username=user, key_file=None, password=password) ssh = SSHSession(self.machine , username=user, key_file=None, password=self.password)
ssh.get_all(logdir_remote_testcase , logdir_local_base) ssh.get_all(logdir_remote_testcase , logdir_local_base)
print "Finishing test case : " + self.testcasename + " On machine " + machineName print "Finishing test case : " + self.testcasename + " On machine " + self.machine
cleanOldPrograms(oai, oldprogramList, CleanUpAluLteBox) cleanOldPrograms(oai, self.oldprogramList, self.CleanupAluLteBox)
oai.kill() #oai.kill(user,mypassword)
oai.disconnect() oai.disconnect()
except Exception, e: except Exception, e:
error='' error=''
error = error + ' In function: ' + sys._getframe().f_code.co_name + ': *** Caught exception: ' + str(e.__class__) + " : " + str( e) error = error + ' In Class = testCaseThread_generic, function: ' + sys._getframe().f_code.co_name + ': *** Caught exception: ' + str(e.__class__) + " : " + str( e)
error = error + '\n threadID = ' + self.threaID + '\n testcasename = ' + self.testcasename + '\n timeout = ' + self.timeout + '\n machine = ' + self.machine + '\n logdirOAI5GRepo = ' + self.logdirOAI5GRepo + '\n' error = error + '\n threadID = ' + str(self.threadID) + '\n threadName = ' + self.name + '\n testcasename = ' + self.testcasename + '\n machine = ' + self.machine + '\n logdirOAI5GRepo = ' + self.logdirOAI5GRepo + '\n' + '\n timeout = ' + str(timeout)
error = error + traceback.format_exc() error = error + traceback.format_exc()
print error
sys.exit()
def addsudo (cmd, password=""): def addsudo (cmd, password=""):
...@@ -276,36 +304,59 @@ def handle_testcaseclass_generic (testcasename, threadListGeneric, oldprogramLis ...@@ -276,36 +304,59 @@ def handle_testcaseclass_generic (testcasename, threadListGeneric, oldprogramLis
#first we need to find the list of free machines that we could run our test case #first we need to find the list of free machines that we could run our test case
if threadListGeneric.__len__() ==0 : if threadListGeneric.__len__() ==0 :
#This means no thread is started yet #This means no thread is started yet
MachineListFree = MachineList MachineListFree = MachineList[:]
else : else :
for param in threadListGeneric : for param in threadListGeneric :
thread_id = param["thread_id"] thread_id = param["thread_id"]
machine = param["Machine"] machine = param["Machine"]
testcasename = param["testcasename"] testcasenameold = param["testcasename"]
thread_id.join(1) thread_id.join(1)
if thread_id.isAlive == True: if thread_id.isAlive() == True:
MachineListBusy.append(machine) print "thread_id is alive: testcasename: " + testcasenameold
if machine not in MachineListBusy:
MachineListBusy.append(machine)
else : else :
threadListGeneric.remove(param) threadListGeneric.remove(param)
#Now we check if there is at least one free machine #Now we check if there is at least one free machine
MachineListFree = MachineList MachineListFree = MachineList[:]
for machine in MachineListBusy: for machine in MachineListBusy:
MachineListFree.remove(machine) if machine in MachineListFree:
MachineListFree.remove(machine)
#print "MachineListFree = " + ','.join(MachineListFree)
#print "MachineListBusy = " + ','.join(MachineListBusy)
#print "MachineList = " + ','.join(MachineList)
machine = MachineListFree[0] machine = MachineListFree[0]
thread = testCaseThread_generic(1,"Generic Thread", machine, logdirOAI5GRepo, testcasename, oldprogramList, CleanupAluLteBox, password, timeout) thread = testCaseThread_generic(1,"Generic Thread_"+testcasename+"_"+machine+_, machine, logdirOAI5GRepo, testcasename, oldprogramList, CleanupAluLteBox, password, timeout)
param={"thread_id":thread, "Machine":machine, "testcasename":testcasename} param={"thread_id":thread, "Machine":machine, "testcasename":testcasename}
thread.start() thread.start()
threadListGeneric.append(param) threadListGeneric.append(param)
return threadListGeneric return threadListGeneric
except Exception, e: except Exception, e:
error='' error=''
error = error + ' In function: ' + sys._getframe().f_code.co_name + ': *** Caught exception: ' + str(e.__class__) + " : " + str( e) error = error + ' In function: ' + sys._getframe().f_code.co_name + ': *** Caught exception: ' + str(e.__class__) + " : " + str( e)
error = error + '\n testcasename = ' + testcasename + '\n logdirOAI5GRepo = ' + logdirOAI5GRepo + '\n MachineList = ' + MachineList + '\n timeout = ' + timeout + '\n' error = error + '\n testcasename = ' + testcasename + '\n logdirOAI5GRepo = ' + logdirOAI5GRepo + '\n MachineList = ' + ','.join(MachineList) + '\n timeout = ' + str(timeout) + '\n'
error = error + traceback.format_exc() error = error + traceback.format_exc()
print error
sys.exit(1)
#Blocking wait for all threads related to generic testcase execution, class (compilation and execution)
def wait_testcaseclass_generic_threads(threadListGeneric, timeout = 1):
for param in threadListGeneric:
thread_id = param["thread_id"]
machine = param["Machine"]
testcasenameold = param["testcasename"]
thread_id.join(timeout)
if thread_id.isAlive() == True:
print "thread_id on machine: " + machine + " is still alive: testcasename: " + testcasenameold
print " Exiting now..."
sys.exit(1)
else:
print "thread_id on machine: " + machine + " is stopped: testcasename: " + testcasenameold
threadListGeneric.remove(param)
return threadListGeneric
#Function to handle test case class : lte-softmodem #Function to handle test case class : lte-softmodem
def handle_testcaseclass_softmodem (testcase, oldprogramList, oai_list, logdirOAI5GRepo , logdirOpenaircnRepo, MachineList, password, CleanUpAluLteBox): def handle_testcaseclass_softmodem (testcase, oldprogramList, logdirOAI5GRepo , logdirOpenaircnRepo, MachineList, password, CleanUpAluLteBox):
#We ignore the password sent to this function for secuirity reasons for password present in log files #We ignore the password sent to this function for secuirity reasons for password present in log files
#It is recommended to add a line in /etc/sudoers that looks something like below. The line below will run sudo without password prompt #It is recommended to add a line in /etc/sudoers that looks something like below. The line below will run sudo without password prompt
# your_user_name ALL=(ALL:ALL) NOPASSWD: ALL # your_user_name ALL=(ALL:ALL) NOPASSWD: ALL
...@@ -365,15 +416,13 @@ def handle_testcaseclass_softmodem (testcase, oldprogramList, oai_list, logdirOA ...@@ -365,15 +416,13 @@ def handle_testcaseclass_softmodem (testcase, oldprogramList, oai_list, logdirOA
index_eNBMachine = MachineList.index(eNBMachine) index_eNBMachine = MachineList.index(eNBMachine)
index_UEMachine = MachineList.index(UEMachine) index_UEMachine = MachineList.index(UEMachine)
index_EPCMachine = MachineList.index(EPCMachine) index_EPCMachine = MachineList.index(EPCMachine)
oai_eNB = oai_list[index_eNBMachine] oai_eNB = openair('localdomain', eNBMachine)
oai_UE = oai_list[index_UEMachine] oai_eNB.connect(user, password)
oai_UE = openair('localdomain', UEMachine)
#We need to create two ssh sessions to avoid race conditions oai_UE.connect(user, password)
if index_eNBMachine == index_EPCMachine: oai_EPC = openair('localdomain', EPCMachine)
oai_EPC = openair('localdomain', EPCMachine) oai_EPC.connect(user, password)
oai_EPC.connect(user,password)
else:
oai_EPC = oai_list[index_EPCMachine]
cleanOldPrograms(oai_eNB, oldprogramList, CleanUpAluLteBox) cleanOldPrograms(oai_eNB, oldprogramList, CleanUpAluLteBox)
cleanOldPrograms(oai_UE, oldprogramList, CleanUpAluLteBox) cleanOldPrograms(oai_UE, oldprogramList, CleanUpAluLteBox)
cleanOldPrograms(oai_EPC, oldprogramList, CleanUpAluLteBox) cleanOldPrograms(oai_EPC, oldprogramList, CleanUpAluLteBox)
...@@ -515,9 +564,9 @@ def handle_testcaseclass_softmodem (testcase, oldprogramList, oai_list, logdirOA ...@@ -515,9 +564,9 @@ def handle_testcaseclass_softmodem (testcase, oldprogramList, oai_list, logdirOA
task_EPC = task_EPC + ' ) > ' + logfile_task_EPC_out + ' 2>&1 ' task_EPC = task_EPC + ' ) > ' + logfile_task_EPC_out + ' 2>&1 '
write_file(logfile_task_EPC, task_EPC, mode="w") write_file(logfile_task_EPC, task_EPC, mode="w")
thread_EPC = oaiThread(1, "EPC_thread", oai_EPC , 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", oai_eNB , task_eNB, False, timeout_thread) thread_eNB = oaiThread(2, "eNB_thread", eNBMachine, user, password , task_eNB, False, timeout_thread)
thread_UE = oaiThread(3, "UE_thread", oai_UE , task_UE, False, timeout_thread) thread_UE = oaiThread(3, "UE_thread", UEMachine, user, password , task_UE, False, timeout_thread)
threads=[] threads=[]
threads.append(thread_eNB) threads.append(thread_eNB)
...@@ -631,9 +680,12 @@ def handle_testcaseclass_softmodem (testcase, oldprogramList, oai_list, logdirOA ...@@ -631,9 +680,12 @@ def handle_testcaseclass_softmodem (testcase, oldprogramList, oai_list, logdirOA
remotefile = logdir_EPC + '/EPC_task_out' + '_' + str(run) + '_.log' remotefile = logdir_EPC + '/EPC_task_out' + '_' + str(run) + '_.log'
paramList.append ( {"operation":'get', "localfile":localfile, "remotefile":remotefile} ) paramList.append ( {"operation":'get', "localfile":localfile, "remotefile":remotefile} )
sftp_module (user, password, EPCMachine, ports, paramList, sftp_log) sftp_module (user, password, EPCMachine, ports, paramList, sftp_log)
oai_eNB.disconnect()
oai_UE.disconnect()
oai_EPC.disconnect()
#We need to close the new ssh session that was created #We need to close the new ssh session that was created
if index_eNBMachine == index_EPCMachine: #if index_eNBMachine == index_EPCMachine:
oai_EPC.disconnect() # oai_EPC.disconnect()
#This function searches if test case is present in list of test cases that need to be executed by user #This function searches if test case is present in list of test cases that need to be executed by user
def search_test_case_group(testcasename, testcasegroup): def search_test_case_group(testcasename, testcasegroup):
...@@ -654,7 +706,6 @@ def search_test_case_group(testcasename, testcasegroup): ...@@ -654,7 +706,6 @@ def search_test_case_group(testcasename, testcasegroup):
#thread1 = myThread(1, "Thread-1", 1) #thread1 = myThread(1, "Thread-1", 1)
threadListGeneric=[]
debug = 0 debug = 0
pw ='' pw =''
i = 0 i = 0
...@@ -677,8 +728,8 @@ if openairdir_local is None: ...@@ -677,8 +728,8 @@ if openairdir_local is None:
sys.exit() sys.exit()
locallogdir = openairdir_local + '/cmake_targets/autotests/log/' locallogdir = openairdir_local + '/cmake_targets/autotests/log/'
#Remove the contents of local log directory #Remove the contents of local log directory
os.system(' rm -fr ' + locallogdir + '; mkdir -p ' + locallogdir ) #os.system(' rm -fr ' + locallogdir + '; mkdir -p ' + locallogdir )
flag_remove_logdir=False
i=1 i=1
while i < len (sys.argv): while i < len (sys.argv):
arg=sys.argv[i] arg=sys.argv[i]
...@@ -688,7 +739,9 @@ while i < len (sys.argv): ...@@ -688,7 +739,9 @@ while i < len (sys.argv):
debug = 2 debug = 2
elif arg == '-p' : elif arg == '-p' :
prompt2 = sys.argv[i+1] prompt2 = sys.argv[i+1]
i = i +1 i = i +1
elif arg == '-r':
flag_remove_logdir=True
elif arg == '-w' : elif arg == '-w' :
pw = sys.argv[i+1] pw = sys.argv[i+1]
i = i +1 i = i +1
...@@ -708,6 +761,7 @@ while i < len (sys.argv): ...@@ -708,6 +761,7 @@ while i < len (sys.argv):
print "-d: low debug level" print "-d: low debug level"
print "-dd: high debug level" print "-dd: high debug level"
print "-p: set the prompt" print "-p: set the prompt"
print "-r: Remove the log directory in autotests/"
print "-w: set the password for ssh to localhost" print "-w: set the password for ssh to localhost"
print "-l: use local shell instead of ssh connection" print "-l: use local shell instead of ssh connection"
print "-t: set the time out in second for commands" print "-t: set the time out in second for commands"
...@@ -735,6 +789,12 @@ except KeyError: ...@@ -735,6 +789,12 @@ except KeyError:
print "Please set the environment variable OPENAIR_TARGETS in the .bashrc" print "Please set the environment variable OPENAIR_TARGETS in the .bashrc"
sys.exit(1) sys.exit(1)
if flag_remove_logdir == True:
print "Removing directory: " + locallogdir
os.system(' rm -fr ' + locallogdir + '; mkdir -p ' + locallogdir )
paramiko_logfile = os.path.expandvars('$OPENAIR_DIR/cmake_targets/autotests/log/paramiko.log') paramiko_logfile = os.path.expandvars('$OPENAIR_DIR/cmake_targets/autotests/log/paramiko.log')
res=os.system(' echo > ' + paramiko_logfile) res=os.system(' echo > ' + paramiko_logfile)
paramiko.util.log_to_file(paramiko_logfile) paramiko.util.log_to_file(paramiko_logfile)
...@@ -767,7 +827,7 @@ GitOpenaircnRepoBranch = xmlRoot.findtext('GitOpenair-cnRepoBranch',default='') ...@@ -767,7 +827,7 @@ GitOpenaircnRepoBranch = xmlRoot.findtext('GitOpenair-cnRepoBranch',default='')
CleanUpOldProgs = xmlRoot.findtext('CleanUpOldProgs',default='') CleanUpOldProgs = xmlRoot.findtext('CleanUpOldProgs',default='')
CleanUpAluLteBox = xmlRoot.findtext('CleanUpAluLteBox',default='') CleanUpAluLteBox = xmlRoot.findtext('CleanUpAluLteBox',default='')
Timeout_execution = int (xmlRoot.findtext('Timeout_execution')) Timeout_execution = int (xmlRoot.findtext('Timeout_execution'))
MachineListGeneric = xmlRoot.findtext('MachineListGeneric',default='')
print "MachineList = " + MachineList print "MachineList = " + MachineList
print "GitOpenair-cnRepo = " + GitOpenaircnRepo print "GitOpenair-cnRepo = " + GitOpenaircnRepo
print "GitOAI5GRepo = " + GitOAI5GRepo print "GitOAI5GRepo = " + GitOAI5GRepo
...@@ -781,6 +841,7 @@ print "CleanUpOldProgs = " + CleanUpOldProgs ...@@ -781,6 +841,7 @@ print "CleanUpOldProgs = " + CleanUpOldProgs
print "Timeout_execution = " + str(Timeout_execution) print "Timeout_execution = " + str(Timeout_execution)
MachineList = MachineList.split() MachineList = MachineList.split()
MachineListGeneric = MachineListGeneric.split()
index=0 index=0
for machine in MachineList: for machine in MachineList:
...@@ -909,7 +970,7 @@ for index in oai_list: ...@@ -909,7 +970,7 @@ for index in oai_list:
#cmd = cmd + 'echo \' ' + cmd + '\' > ' + setup_script + ' 2>&1 \n ' #cmd = cmd + 'echo \' ' + cmd + '\' > ' + setup_script + ' 2>&1 \n '
#result = oai_list[index].send_recv(cmd, False, 300 ) #result = oai_list[index].send_recv(cmd, False, 300 )
write_file(setup_script, cmd, mode="w") write_file(setup_script, cmd, mode="w")
tempThread = oaiThread(index, 'thread_'+str(index), oai_list[index] , cmd, False, 300) tempThread = oaiThread(index, 'thread_setup_'+str(index)+'_' + MachineList[index] , MachineList[index] , user, pw, cmd, False, 300)
threads_init_setup.append(tempThread ) threads_init_setup.append(tempThread )
tempThread.start() tempThread.start()
...@@ -944,12 +1005,13 @@ for index in oai_list: ...@@ -944,12 +1005,13 @@ for index in oai_list:
#print '\nCleaning Older running programs : ' + CleanUpOldProgs #print '\nCleaning Older running programs : ' + CleanUpOldProgs
#cleanOldPrograms(oai_list[index], CleanUpOldProgs) #cleanOldPrograms(oai_list[index], CleanUpOldProgs)
except Exception, e:
except : print 'There is error in one of the commands to setup the machine '+ MachineList[index]
print 'There is error in one of the commands to setup the machine '+ MachineList[index] error=''
sys.exit(1) error = error + ' In function: ' + sys._getframe().f_code.co_name + ': *** Caught exception: ' + str(e.__class__) + " : " + str( e)
error = error + traceback.format_exc()
print error
sys.exit(1)
#Now we wait for all the threads to complete #Now we wait for all the threads to complete
index = 0 index = 0
...@@ -975,38 +1037,62 @@ for t in threads_init_setup: ...@@ -975,38 +1037,62 @@ for t in threads_init_setup:
index = index+1 index = index+1
#Now we process all the test cases #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*')
if (out != '') :
print "There is error in setup of machines"
print "status = " + str(status) + "\n out = " + out
print sys.exit(1)
threadListGeneric=[]
threadListGlobal=[]
testcaseList=xmlRoot.findall('testCase') testcaseList=xmlRoot.findall('testCase')
#print testcaseList #print testcaseList
for testcase in testcaseList: for testcase in testcaseList:
testcasename = testcase.get('id') try:
testcaseclass = testcase.findtext('class',default='') testcasename = testcase.get('id')
desc = testcase.findtext('desc',default='') testcaseclass = testcase.findtext('class',default='')
if search_test_case_group(testcasename, testcasegroup) == True: desc = testcase.findtext('desc',default='')
if testcaseclass == 'lte-softmodem' : #print "Machine list top level = " + ','.join(MachineList)
eNBMachine = testcase.findtext('eNB',default='') if search_test_case_group(testcasename, testcasegroup) == True:
UEMachine = testcase.findtext('UE',default='') if testcaseclass == 'lte-softmodem' :
EPCMachine = testcase.findtext('EPC',default='') eNBMachine = testcase.findtext('eNB',default='')
index_eNBMachine = MachineList.index(eNBMachine) UEMachine = testcase.findtext('UE',default='')
index_UEMachine = MachineList.index(UEMachine) EPCMachine = testcase.findtext('EPC',default='')
index_EPCMachine = MachineList.index(EPCMachine) #index_eNBMachine = MachineList.index(eNBMachine)
print "testcasename = " + testcasename + " class = " + testcaseclass #index_UEMachine = MachineList.index(UEMachine)
handle_testcaseclass_softmodem (testcase, CleanUpOldProgs, oai_list, logdirOAI5GRepo, logdirOpenaircnRepo, MachineList, pw, CleanUpAluLteBox ) #index_EPCMachine = MachineList.index(EPCMachine)
elif (testcaseclass == 'compilation'): if (eNBMachine not in MachineList)|(UEMachine not in MachineList)|(UEMachine not in MachineList):
handle_testcaseclass_generic (testcasename, threadListGeneric, oldprogramList, logdirOAI5GRepo, MachineList, pw, CleanupAluLteBox,Timeout_execution) print "One of the machines is not in the machine list"
elif (testcaseclass == 'execution'): print "eNBMachine : " + eNBMachine + "UEMachine : " + UEMachine + "EPCMachine : " + EPCMachine + "MachineList : " + ','.join(MachineList)
handle_testcaseclass_generic (testcasename, threadListGeneric, oldprogramList, logdirOAI5GRepo, MachineList, pw, CleanupAluLteBox,Timeout_execution) print "testcasename = " + testcasename + " class = " + testcaseclass
else : threadListGlobal = wait_testcaseclass_generic_threads(threadListGlobal, Timeout_execution)
print "Unknown test case class: " + testcaseclass handle_testcaseclass_softmodem (testcase, CleanUpOldProgs, logdirOAI5GRepo, logdirOpenaircnRepo, MachineList, pw, CleanUpAluLteBox )
sys.exit() elif (testcaseclass == 'compilation'):
threadListGlobal = handle_testcaseclass_generic (testcasename, threadListGlobal, CleanUpOldProgs, logdirOAI5GRepo, MachineListGeneric, pw, CleanUpAluLteBox,Timeout_execution)
elif (testcaseclass == 'execution'):
threadListGlobal = handle_testcaseclass_generic (testcasename, threadListGlobal, CleanUpOldProgs, logdirOAI5GRepo, MachineListGeneric, pw, CleanUpAluLteBox,Timeout_execution)
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
sys.exit(1)
print "Exiting the test cases execution now..." print "Exiting the test cases execution now..."
for t in threadListGlobal:
t.join
sys.exit() sys.exit()
#+ "class = "+ classx #+ "class = "+ classx
......
<testCaseList> <testCaseList>
<MachineList>amerique stevens calisson nano</MachineList> <MachineList>stevens calisson mozart nano amerique</MachineList>
<NFSResultsShare>/mnt/sradio/TEST_RESULTS</NFSResultsShare> <NFSResultsShare>/mnt/sradio/TEST_RESULTS</NFSResultsShare>
<GitOAI5GRepo>https://gitlab.eurecom.fr/oai/openairinterface5g.git</GitOAI5GRepo> <GitOAI5GRepo>https://gitlab.eurecom.fr/oai/openairinterface5g.git</GitOAI5GRepo>
<GitOpenair-cnRepo>https://gitlab.eurecom.fr/oai/openair-cn.git</GitOpenair-cnRepo> <GitOpenair-cnRepo>https://gitlab.eurecom.fr/oai/openair-cn.git</GitOpenair-cnRepo>
<GitOAI5GRepoBranch>feature-34-test_framework</GitOAI5GRepoBranch> <GitOAI5GRepoBranch>feature-34-test_framework</GitOAI5GRepoBranch>
<GitOpenair-cnRepoBranch>feature-17-test_framework</GitOpenair-cnRepoBranch> <GitOpenair-cnRepoBranch>feature-17-test_framework</GitOpenair-cnRepoBranch>
<CleanUpOldProgs>oaisim* oaisim_nos1* lte-softmodem* lte-softmodem-nos1* mme_gw* run_epc* run_hss* iperf* hss hss_sim configure_cots_bandrich_ue* wvdial* </CleanUpOldProgs> <CleanUpOldProgs>oaisim* oaisim_nos1* lte-softmodem* lte-softmodem-nos1* mme_gw* run_epc* run_hss* iperf* hss hss_sim configure_cots_bandrich_ue* wvdial* run_exec_autotests*</CleanUpOldProgs>
<CleanUpAluLteBox>/opt/ltebox/tools/stop_ltebox</CleanUpAluLteBox> <CleanUpAluLteBox>/opt/ltebox/tools/stop_ltebox</CleanUpAluLteBox>
<Timeout_execution>1800</Timeout_execution> <Timeout_execution>1800</Timeout_execution>
<MachineListGeneric>calisson stevens mozart nano amerique</MachineListGeneric>
<testCase id="010101" > <testCase id="010101" >
<class>compilation</class> <class>compilation</class>
<desc>Build oaisim.Rel8</desc> <desc>Build oaisim.Rel8</desc>
......
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