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):
def kill(self, user, pw):
try:
if user == 'root' :
os.system('pkill oaisim')
os.system('pkill oaisim oaisim_nos1')
os.system('pkill cc1')
time.sleep(1)
os.system('pkill oaisim')
os.system('pkill oaisim oaisim_nos1')
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')
time.sleep(1)
os.system('echo '+pw+' | sudo -S pkill oaisim')
os.system('echo '+pw+' | sudo -S pkill oaisim oaisim_nos1')
except Error, val:
print "Error:", val
......
......@@ -211,48 +211,99 @@ class oaiThread (threading.Thread):
print "result = " + result
print "Exiting " + self.name
#This class runs test cases with class oaisim_noS1, compilatation
class testCaseThread_generic(threading.thread):
def __init__(self, threadID, name, oai, machine, logdirOAI5GRepo, oai5GRepoDirRemote, testcasename,oldprogramList, CleanupAluLteBox, username, password, timeout):
#This class runs test cases with class execution, compilatation
class testCaseThread_generic (threading.Thread):
def __init__(self, threadID, name, machine, logdirOAI5GRepo, testcasename,oldprogramList, CleanupAluLteBox, password, timeout):
threading.Thread.__init__(self)
self.threaID = threadID
self.name = name
self.oai = oai
self.testcasename = testcasename
self.timeout = timeout
self.machine = machine
self.oai5GRepoDirRemote = oai5GRepoDirRemote
self.logdirOAI5GRepo = logdirOAI5GRepo
self.username = username
self.password = password
self.oldprogramList = oldprogramList
self.CleanupAluLteBox = CleanupAluLteBox
self.password=password
def run(self):
try:
mypassword=''
#addsudo = 'echo \'' + mypassword + '\' | sudo -S -E '
addpass = 'echo \'' + mypassword + '\' | '
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)
logdir_local_testcase = logdirOAI5GRepo+'/cmake_targets/autotests/log/'+ testcasename
logdir_local_base = logdirOAI5GRepo+'/cmake_targets/autotests/log/'
logdir_remote_testcase = oai5GRepoDirRemote + '/cmake_targets/autotests/log' + self.testcasename
logdir_local = os.environ.get('OPENAIR_DIR')
logdir_local_testcase = logdir_local +'/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.mkdir (logdir_testcase)
cmd = "( cd " + self.oai5GRepoDirRemote + " \n "
cmd = "( cd " + self.logdirOAI5GRepo + " \n "
cmd = cmd + "source oaienv \n"
cmd = cmd + "python run_test_case_generic -d " + self.oai5GRepoDirRemote + " -g " + "\"" + self.testcasename + "\""
cmd = cmd + " ) "
cmd = cmd + "$OPENAIR_DIR/cmake_targets/autotests/run_exec_autotets.bash --run-group \"" + "self.testcasename +\" "
cmd = cmd + " ) >& " + logfile_task_testcasename_out + " ; " + " mv " + logfile_task_testcasename_out + logdir_remote_testcase
#Now we copy all the remote
ssh = SSHSession(self.machine , username=username, key_file=None, passsword=password)
write_file(logfile_task_testcasename, cmd, mode="w")
#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)
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=""):
cmd = 'echo \'' + password + '\' | sudo -S -E bash -c \' ' + 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
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
......@@ -603,6 +654,7 @@ def search_test_case_group(testcasename, testcasegroup):
#thread1 = myThread(1, "Thread-1", 1)
threadListGeneric=[]
debug = 0
pw =''
i = 0
......@@ -714,6 +766,7 @@ GitOAI5GRepoBranch = xmlRoot.findtext('GitOAI5GRepoBranch',default='')
GitOpenaircnRepoBranch = xmlRoot.findtext('GitOpenair-cnRepoBranch',default='')
CleanUpOldProgs = xmlRoot.findtext('CleanUpOldProgs',default='')
CleanUpAluLteBox = xmlRoot.findtext('CleanUpAluLteBox',default='')
Timeout_execution = int (xmlRoot.findtext('Timeout_execution'))
print "MachineList = " + MachineList
print "GitOpenair-cnRepo = " + GitOpenaircnRepo
......@@ -725,7 +778,7 @@ cmd = "git show-ref --heads -s "+ GitOAI5GRepoBranch
GitOAI5GHeadVersion = subprocess.check_output ([cmd], shell=True)
print "GitOAI5GHeadVersion = " + GitOAI5GHeadVersion
print "CleanUpOldProgs = " + CleanUpOldProgs
print "Timeout_execution = " + str(Timeout_execution)
MachineList = MachineList.split()
......@@ -897,6 +950,7 @@ for index in oai_list:
sys.exit(1)
#Now we wait for all the threads to complete
index = 0
for t in threads_init_setup:
......@@ -922,7 +976,7 @@ for t in threads_init_setup:
#Now we process all the test cases
threadListGeneric=[]
testcaseList=xmlRoot.findall('testCase')
#print testcaseList
for testcase in testcaseList:
......@@ -939,19 +993,17 @@ for testcase in testcaseList:
index_EPCMachine = MachineList.index(EPCMachine)
print "testcasename = " + testcasename + " class = " + testcaseclass
handle_testcaseclass_softmodem (testcase, CleanUpOldProgs, oai_list, logdirOAI5GRepo, logdirOpenaircnRepo, MachineList, pw, CleanUpAluLteBox )
elif testcaseclass == 'compilation' :
continue
handle_testcaseclass_compilation (testcase)
elif testcaseclass == 'execution' :
continue
handle_testcaseclass_oaisim (testcase)
elif (testcaseclass == 'compilation'):
handle_testcaseclass_generic (testcasename, threadListGeneric, oldprogramList, logdirOAI5GRepo, MachineList, pw, CleanupAluLteBox,Timeout_execution)
elif (testcaseclass == 'execution'):
handle_testcaseclass_generic (testcasename, threadListGeneric, oldprogramList, logdirOAI5GRepo, MachineList, pw, CleanupAluLteBox,Timeout_execution)
else :
print "Unknown test case class: " + testcaseclass
sys.exit()
print "Exiting the test cases execution now..."
sys.exit()
......
......@@ -8,7 +8,7 @@
<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>
<CleanUpAluLteBox>/opt/ltebox/tools/stop_ltebox</CleanUpAluLteBox>
<Timeout_execution>1800</Timeout_execution>
<testCase id="010101" >
<class>compilation</class>
<desc>Build oaisim.Rel8</desc>
......@@ -26,7 +26,7 @@
<search_expr_true></search_expr_true>
<search_expr_false></search_expr_false>
<tags>oaisim.Rel8</tags>
<nruns>2</nruns>
<nruns>1</nruns>
</testCase>
<testCase id="010102" >
......@@ -928,7 +928,6 @@
<eNB>calisson</eNB>
<UE>stevens</UE>
<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>
<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\"
......@@ -1000,7 +999,6 @@
<eNB>calisson</eNB>
<UE>stevens</UE>
<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>
<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\"
......@@ -1079,7 +1077,6 @@
<eNB>calisson</eNB>
<UE>stevens</UE>
<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>
<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\"
......
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