Commit 2a9a9159 authored by Rohit Gupta's avatar Rohit Gupta

updates for parallel execution to test case framework

parent 34b61a1a
...@@ -164,15 +164,15 @@ class openair(core): ...@@ -164,15 +164,15 @@ class openair(core):
def kill(self, user, pw): def kill(self, user, pw):
try: try:
if user == 'root' : if user == 'root' :
os.system('pkill oaisim') os.system('pkill oaisim oaisim_nos1')
os.system('pkill cc1') os.system('pkill cc1')
time.sleep(1) time.sleep(1)
os.system('pkill oaisim') os.system('pkill oaisim oaisim_nos1')
else : else :
os.system('echo '+pw+' | sudo -S pkill oaisim') os.system('echo '+pw+' | sudo -S pkill oaisim oaisim_nos1')
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') os.system('echo '+pw+' | sudo -S pkill oaisim oaisim_nos1')
except Error, val: except Error, val:
print "Error:", val print "Error:", val
......
...@@ -211,48 +211,99 @@ class oaiThread (threading.Thread): ...@@ -211,48 +211,99 @@ class oaiThread (threading.Thread):
print "result = " + result print "result = " + result
print "Exiting " + self.name print "Exiting " + self.name
#This class runs test cases with class oaisim_noS1, 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, oai, machine, logdirOAI5GRepo, oai5GRepoDirRemote, testcasename,oldprogramList, CleanupAluLteBox, username, 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.threaID = threadID
self.name = name self.name = name
self.oai = oai
self.testcasename = testcasename self.testcasename = testcasename
self.timeout = timeout self.timeout = timeout
self.machine = machine self.machine = machine
self.oai5GRepoDirRemote = oai5GRepoDirRemote
self.logdirOAI5GRepo = logdirOAI5GRepo self.logdirOAI5GRepo = logdirOAI5GRepo
self.username = username self.oldprogramList = oldprogramList
self.password = password self.CleanupAluLteBox = CleanupAluLteBox
self.password=password
def run(self): def run(self):
try: try:
mypassword='' mypassword=''
#addsudo = 'echo \'' + mypassword + '\' | sudo -S -E ' #addsudo = 'echo \'' + mypassword + '\' | sudo -S -E '
addpass = 'echo \'' + mypassword + '\' | ' addpass = 'echo \'' + mypassword + '\' | '
user = getpass.getuser() user = getpass.getuser()
print "Starting test case : " + self.testcasename + " On machine " + machineName print "Starting test case : " + self.testcasename + " On machine " + self.machine
oai = openair('localdomain',machine)
oai.connect(user, self.password)
cleanOldPrograms(oai, oldprogramList, CleanUpAluLteBox) cleanOldPrograms(oai, oldprogramList, CleanUpAluLteBox)
logdir_local_testcase = logdirOAI5GRepo+'/cmake_targets/autotests/log/'+ testcasename logdir_local = os.environ.get('OPENAIR_DIR')
logdir_local_base = logdirOAI5GRepo+'/cmake_targets/autotests/log/' logdir_local_testcase = logdir_local +'/cmake_targets/autotests/log/'+ self.testcasename
logdir_remote_testcase = oai5GRepoDirRemote + '/cmake_targets/autotests/log' + self.testcasename logdir_local_base = logdir_local +'/cmake_targets/autotests/log/'
logdir_remote_testcase = self.logdirOAI5GRepo + '/cmake_targets/autotests/log' + self.testcasename
logdir_remote = self.logdirOAI5GRepo + '/cmake_targets/autotests/log'
logfile_task_testcasename = logdir_local_testcase + '/test_task' + '_' + testcasename + '_.log'
logfile_task_testcasename_out = logdir_remote + '/test_task_out' + '_' + str(run) + '_.log'
os.removedirs(logdir_testcase) os.removedirs(logdir_testcase)
os.mkdir (logdir_testcase) os.mkdir (logdir_testcase)
cmd = "( cd " + self.oai5GRepoDirRemote + " \n " cmd = "( cd " + self.logdirOAI5GRepo + " \n "
cmd = cmd + "source oaienv \n" cmd = cmd + "source oaienv \n"
cmd = cmd + "python run_test_case_generic -d " + self.oai5GRepoDirRemote + " -g " + "\"" + self.testcasename + "\"" cmd = cmd + "$OPENAIR_DIR/cmake_targets/autotests/run_exec_autotets.bash --run-group \"" + "self.testcasename +\" "
cmd = cmd + " ) " cmd = cmd + " ) >& " + logfile_task_testcasename_out + " ; " + " mv " + logfile_task_testcasename_out + logdir_remote_testcase
#Now we copy all the remote write_file(logfile_task_testcasename, cmd, mode="w")
ssh = SSHSession(self.machine , username=username, key_file=None, passsword=password) #Now we copy all the remote files
ssh = SSHSession(self.machine , username=user, key_file=None, password=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 " + machineName
cleanOldPrograms(oai, oldprogramList, CleanUpAluLteBox)
oai.kill()
oai.disconnect()
except Exception, e:
error=''
error = error + ' In 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 + traceback.format_exc()
def addsudo (cmd, password=""): def addsudo (cmd, password=""):
cmd = 'echo \'' + password + '\' | sudo -S -E bash -c \' ' + cmd + '\' ' cmd = 'echo \'' + password + '\' | sudo -S -E bash -c \' ' + cmd + '\' '
return cmd return cmd
def handle_testcaseclass_generic (testcasename, threadListGeneric, oldprogramList, logdirOAI5GRepo, MachineList, password, CleanupAluLteBox,timeout):
try:
mypassword=password
MachineListFree=[]
while MachineListFree.__len__() == 0 :
MachineListBusy=[]
#first we need to find the list of free machines that we could run our test case
if threadListGeneric.__len__() ==0 :
#This means no thread is started yet
MachineListFree = MachineList
else :
for param in threadListGeneric :
thread_id = param["thread_id"]
machine = param["Machine"]
testcasename = param["testcasename"]
thread_id.join(1)
if thread_id.isAlive == True:
MachineListBusy.append(machine)
else :
threadListGeneric.remove(param)
#Now we check if there is at least one free machine
MachineListFree = MachineList
for machine in MachineListBusy:
MachineListFree.remove(machine)
machine = MachineListFree[0]
thread = testCaseThread_generic(1,"Generic Thread", machine, logdirOAI5GRepo, testcasename, oldprogramList, CleanupAluLteBox, password, timeout)
param={"thread_id":thread, "Machine":machine, "testcasename":testcasename}
thread.start()
threadListGeneric.append(param)
return threadListGeneric
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 logdirOAI5GRepo = ' + logdirOAI5GRepo + '\n MachineList = ' + MachineList + '\n timeout = ' + timeout + '\n'
error = error + traceback.format_exc()
#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, oai_list, 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
...@@ -603,6 +654,7 @@ def search_test_case_group(testcasename, testcasegroup): ...@@ -603,6 +654,7 @@ 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
...@@ -714,6 +766,7 @@ GitOAI5GRepoBranch = xmlRoot.findtext('GitOAI5GRepoBranch',default='') ...@@ -714,6 +766,7 @@ GitOAI5GRepoBranch = xmlRoot.findtext('GitOAI5GRepoBranch',default='')
GitOpenaircnRepoBranch = xmlRoot.findtext('GitOpenair-cnRepoBranch',default='') 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'))
print "MachineList = " + MachineList print "MachineList = " + MachineList
print "GitOpenair-cnRepo = " + GitOpenaircnRepo print "GitOpenair-cnRepo = " + GitOpenaircnRepo
...@@ -725,7 +778,7 @@ cmd = "git show-ref --heads -s "+ GitOAI5GRepoBranch ...@@ -725,7 +778,7 @@ cmd = "git show-ref --heads -s "+ GitOAI5GRepoBranch
GitOAI5GHeadVersion = subprocess.check_output ([cmd], shell=True) GitOAI5GHeadVersion = subprocess.check_output ([cmd], shell=True)
print "GitOAI5GHeadVersion = " + GitOAI5GHeadVersion print "GitOAI5GHeadVersion = " + GitOAI5GHeadVersion
print "CleanUpOldProgs = " + CleanUpOldProgs print "CleanUpOldProgs = " + CleanUpOldProgs
print "Timeout_execution = " + str(Timeout_execution)
MachineList = MachineList.split() MachineList = MachineList.split()
...@@ -897,6 +950,7 @@ for index in oai_list: ...@@ -897,6 +950,7 @@ for index in oai_list:
sys.exit(1) 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
for t in threads_init_setup: for t in threads_init_setup:
...@@ -922,7 +976,7 @@ for t in threads_init_setup: ...@@ -922,7 +976,7 @@ for t in threads_init_setup:
#Now we process all the test cases #Now we process all the test cases
threadListGeneric=[]
testcaseList=xmlRoot.findall('testCase') testcaseList=xmlRoot.findall('testCase')
#print testcaseList #print testcaseList
for testcase in testcaseList: for testcase in testcaseList:
...@@ -939,19 +993,17 @@ for testcase in testcaseList: ...@@ -939,19 +993,17 @@ for testcase in testcaseList:
index_EPCMachine = MachineList.index(EPCMachine) index_EPCMachine = MachineList.index(EPCMachine)
print "testcasename = " + testcasename + " class = " + testcaseclass print "testcasename = " + testcasename + " class = " + testcaseclass
handle_testcaseclass_softmodem (testcase, CleanUpOldProgs, oai_list, logdirOAI5GRepo, logdirOpenaircnRepo, MachineList, pw, CleanUpAluLteBox ) handle_testcaseclass_softmodem (testcase, CleanUpOldProgs, oai_list, logdirOAI5GRepo, logdirOpenaircnRepo, MachineList, pw, CleanUpAluLteBox )
elif (testcaseclass == 'compilation'):
elif testcaseclass == 'compilation' : handle_testcaseclass_generic (testcasename, threadListGeneric, oldprogramList, logdirOAI5GRepo, MachineList, pw, CleanupAluLteBox,Timeout_execution)
continue elif (testcaseclass == 'execution'):
handle_testcaseclass_compilation (testcase) handle_testcaseclass_generic (testcasename, threadListGeneric, oldprogramList, logdirOAI5GRepo, MachineList, pw, CleanupAluLteBox,Timeout_execution)
elif testcaseclass == 'execution' :
continue
handle_testcaseclass_oaisim (testcase)
else : else :
print "Unknown test case class: " + testcaseclass print "Unknown test case class: " + testcaseclass
sys.exit() sys.exit()
print "Exiting the test cases execution now..." print "Exiting the test cases execution now..."
sys.exit() sys.exit()
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<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* </CleanUpOldProgs>
<CleanUpAluLteBox>/opt/ltebox/tools/stop_ltebox</CleanUpAluLteBox> <CleanUpAluLteBox>/opt/ltebox/tools/stop_ltebox</CleanUpAluLteBox>
<Timeout_execution>1800</Timeout_execution>
<testCase id="010101" > <testCase id="010101" >
<class>compilation</class> <class>compilation</class>
<desc>Build oaisim.Rel8</desc> <desc>Build oaisim.Rel8</desc>
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<search_expr_true></search_expr_true> <search_expr_true></search_expr_true>
<search_expr_false></search_expr_false> <search_expr_false></search_expr_false>
<tags>oaisim.Rel8</tags> <tags>oaisim.Rel8</tags>
<nruns>2</nruns> <nruns>1</nruns>
</testCase> </testCase>
<testCase id="010102" > <testCase id="010102" >
...@@ -928,7 +928,6 @@ ...@@ -928,7 +928,6 @@
<eNB>calisson</eNB> <eNB>calisson</eNB>
<UE>stevens</UE> <UE>stevens</UE>
<EPC>amerique</EPC> <EPC>amerique</EPC>
<cleanupScript>oaisim* oaisim_nos1* lte-softmodem* lte-softmodem-nos1* mme_gw* run_epc* run_hss* iperf* ltebox*</cleanupScript>
<TimeOut_cmd>60</TimeOut_cmd> <TimeOut_cmd>60</TimeOut_cmd>
<eNB_working_dir>/tmp</eNB_working_dir> <eNB_working_dir>/tmp</eNB_working_dir>
<eNB_config_file>targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.usrpb210.epc.local.conf tracking_area_code \"1\" <eNB_config_file>targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.usrpb210.epc.local.conf tracking_area_code \"1\"
...@@ -1000,7 +999,6 @@ ...@@ -1000,7 +999,6 @@
<eNB>calisson</eNB> <eNB>calisson</eNB>
<UE>stevens</UE> <UE>stevens</UE>
<EPC>nano</EPC> <EPC>nano</EPC>
<cleanupScript>oaisim* oaisim_nos1* lte-softmodem* lte-softmodem-nos1* mme_gw* run_epc* run_hss* iperf* ltebox*</cleanupScript>
<TimeOut_cmd>60</TimeOut_cmd> <TimeOut_cmd>60</TimeOut_cmd>
<eNB_working_dir>/tmp</eNB_working_dir> <eNB_working_dir>/tmp</eNB_working_dir>
<eNB_config_file>targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.usrpb210.epc.local.conf tracking_area_code \"1\" <eNB_config_file>targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.usrpb210.epc.local.conf tracking_area_code \"1\"
...@@ -1079,7 +1077,6 @@ ...@@ -1079,7 +1077,6 @@
<eNB>calisson</eNB> <eNB>calisson</eNB>
<UE>stevens</UE> <UE>stevens</UE>
<EPC>calisson</EPC> <EPC>calisson</EPC>
<cleanupScript>oaisim* oaisim_nos1* lte-softmodem* lte-softmodem-nos1* mme_gw* run_epc* run_hss* iperf* ltebox*</cleanupScript>
<TimeOut_cmd>60</TimeOut_cmd> <TimeOut_cmd>60</TimeOut_cmd>
<eNB_working_dir>/tmp</eNB_working_dir> <eNB_working_dir>/tmp</eNB_working_dir>
<eNB_config_file>targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.usrpb210.epc.local.conf tracking_area_code \"1\" <eNB_config_file>targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.usrpb210.epc.local.conf tracking_area_code \"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