Commit fe17f01b authored by Rohit Gupta's avatar Rohit Gupta

bugfixes for intergration with GitLabCI

parent 15ee5719
...@@ -118,8 +118,7 @@ class core: ...@@ -118,8 +118,7 @@ class core:
rsp1 = self.prompt1 rsp1 = self.prompt1
rsp2 = self.prompt2 rsp2 = self.prompt2
if sudo == True: if sudo == True:
command = 'echo \'' + self.password + '\' | sudo -S -E ' + command command = 'echo \'' + '' + '\' | sudo -S -E bash -c \' ' + command + '\' '
self.wait_quiet() self.wait_quiet()
if self.send_cr: if self.send_cr:
log.stats['cmd'] += 1 log.stats['cmd'] += 1
...@@ -140,7 +139,7 @@ class core: ...@@ -140,7 +139,7 @@ class core:
rsp2 = self.prompt2 rsp2 = self.prompt2
self.wait_quiet() self.wait_quiet()
if sudo == True: if sudo == True:
command = 'echo \'' + self.password + '\' | sudo -S -E ' + command command = 'echo \'' + '' + '\' | sudo -S -E bash -c \' ' + command + '\' '
if self.send_cr: if self.send_cr:
log.stats['cmd'] += 1 log.stats['cmd'] += 1
self.oai.sendline(command) self.oai.sendline(command)
......
...@@ -112,6 +112,7 @@ class openair(core): ...@@ -112,6 +112,7 @@ class openair(core):
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 + 'address = "'+ self.address +' username = ' + username
error = error + traceback.format_exc() error = error + traceback.format_exc()
print error print error
print "Retrying again in 1 seconds" print "Retrying again in 1 seconds"
......
...@@ -262,7 +262,7 @@ def SSHSessionWrapper(machine, username, key_file, password, logdir_remote_testc ...@@ -262,7 +262,7 @@ def SSHSessionWrapper(machine, username, key_file, password, logdir_remote_testc
if operation == "get_all": if operation == "get_all":
ssh.get_all(logdir_remote_testcase , logdir_local_base) ssh.get_all(logdir_remote_testcase , logdir_local_base)
elif operation == "put_all": elif operation == "put_all":
ssh.put_all(logdir_remote_testcase , logdir_local_base) ssh.put_all(logdir_local_base, logdir_remote_testcase )
else: else:
print "Error: Uknown operation in SSHSessionWrapper. Exiting now..." print "Error: Uknown operation in SSHSessionWrapper. Exiting now..."
sys.exit(1) sys.exit(1)
...@@ -929,13 +929,16 @@ GitOAI5GRepoBranch='' ...@@ -929,13 +929,16 @@ GitOAI5GRepoBranch=''
GitOAI5GHeadVersion='' GitOAI5GHeadVersion=''
user='' user=''
pw='' pw=''
testcasegroup=''
NFSResultsShare='' NFSResultsShare=''
cleanUpRemoteMachines=False cleanUpRemoteMachines=False
openairdir_local = os.environ.get('OPENAIR_DIR') openairdir_local = os.environ.get('OPENAIR_DIR')
if openairdir_local is None: if openairdir_local is None:
print "Environment variable OPENAIR_DIR not set correctly" print "Environment variable OPENAIR_DIR not set correctly"
sys.exit() sys.exit()
locallogdir = openairdir_local + '/cmake_targets/autotests/log/' locallogdir = openairdir_local + '/cmake_targets/autotests/log'
MachineList = ''
MachinneListGeneric=''
#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 flag_remove_logdir=False
...@@ -987,6 +990,16 @@ while i < len (sys.argv): ...@@ -987,6 +990,16 @@ while i < len (sys.argv):
elif arg == '-n': elif arg == '-n':
NFSResultsShare = sys.argv[i+1] NFSResultsShare = sys.argv[i+1]
i = i +1 i = i +1
elif arg == '-MachineList':
MachineList = sys.argv[i+1]
MachineList = MachineList.replace("\"","")
MachineList = MachineList.replace("\'","")
i = i +1
elif arg == '-MachineListGeneric':
MachineListGeneric = sys.argv[i+1]
MachineListGeneric = MachineListGeneric.replace("\"","")
MachineListGeneric = MachineListGeneric.replace("\'","")
i = i +1
elif arg == '-h' : elif arg == '-h' :
print "-d: low debug level" print "-d: low debug level"
print "-dd: high debug level" print "-dd: high debug level"
...@@ -1001,6 +1014,8 @@ while i < len (sys.argv): ...@@ -1001,6 +1014,8 @@ while i < len (sys.argv):
print "-u: use the user name passed as argument" print "-u: use the user name passed as argument"
print "-p: use the password passed as an argument" print "-p: use the password passed as an argument"
print "-n: Set the NFS share passed as an argument" print "-n: Set the NFS share passed as an argument"
print "-MachineList : overrides the MachineList parameter in test_case_list.xml"
print "-MachineListGeneric : overrides the MachineListGeneric parameter in test_case_list.xml"
sys.exit() sys.exit()
else : else :
print "Unrecongnized Option: <" + arg + ">. Use -h to see valid options" print "Unrecongnized Option: <" + arg + ">. Use -h to see valid options"
...@@ -1042,7 +1057,6 @@ print "user = " + user ...@@ -1042,7 +1057,6 @@ print "user = " + user
xmlInputFile=os.environ.get('OPENAIR_DIR')+"/cmake_targets/autotests/test_case_list.xml" xmlInputFile=os.environ.get('OPENAIR_DIR')+"/cmake_targets/autotests/test_case_list.xml"
NFSResultsDir = '/mnt/sradio' NFSResultsDir = '/mnt/sradio'
cleanupOldProgramsScript = '$OPENAIR_DIR/cmake_targets/autotests/tools/remove_old_programs.bash' cleanupOldProgramsScript = '$OPENAIR_DIR/cmake_targets/autotests/tools/remove_old_programs.bash'
testcasegroup=''
logdir = '/tmp/' + 'OAITestFrameWork-' + user + '/' logdir = '/tmp/' + 'OAITestFrameWork-' + user + '/'
logdirOAI5GRepo = logdir + 'openairinterface5g/' logdirOAI5GRepo = logdir + 'openairinterface5g/'
logdirOpenaircnRepo = logdir + 'openair-cn/' logdirOpenaircnRepo = logdir + 'openair-cn/'
...@@ -1063,8 +1077,8 @@ xmlRoot = xmlTree.getroot() ...@@ -1063,8 +1077,8 @@ xmlRoot = xmlTree.getroot()
if MachineList =='':
MachineList = xmlRoot.findtext('MachineList',default='') MachineList = xmlRoot.findtext('MachineList',default='')
NFSResultsShare = xmlRoot.findtext('NFSResultsShare',default='') NFSResultsShare = xmlRoot.findtext('NFSResultsShare',default='')
GitOpenaircnRepo = xmlRoot.findtext('GitOpenair-cnRepo',default='') GitOpenaircnRepo = xmlRoot.findtext('GitOpenair-cnRepo',default='')
GitOAI5GRepo = xmlRoot.findtext('GitOAI5GRepo',default='') GitOAI5GRepo = xmlRoot.findtext('GitOAI5GRepo',default='')
...@@ -1076,7 +1090,8 @@ GitOpenaircnRepoBranch = xmlRoot.findtext('GitOpenair-cnRepoBranch',default='') ...@@ -1076,7 +1090,8 @@ 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='') if MachineListGeneric == '':
MachineListGeneric = xmlRoot.findtext('MachineListGeneric',default='')
TestCaseExclusionList = xmlRoot.findtext('TestCaseExclusionList',default='') TestCaseExclusionList = xmlRoot.findtext('TestCaseExclusionList',default='')
ExmimoRfStop = xmlRoot.findtext('ExmimoRfStop',default='') ExmimoRfStop = xmlRoot.findtext('ExmimoRfStop',default='')
...@@ -1100,7 +1115,7 @@ if GitOAI5GHeadVersion == '': ...@@ -1100,7 +1115,7 @@ if GitOAI5GHeadVersion == '':
print "Error getting the OAI5GBranch Head version...Exiting" print "Error getting the OAI5GBranch Head version...Exiting"
sys.exit() sys.exit()
NFSTestsResultsDir = NFSResultsShare + '/'+ GitOAI5GRepoBranch + '/' + GitOAI5GHeadVersion + '/' NFSTestsResultsDir = NFSResultsShare + '/'+ GitOAI5GRepoBranch + '/' + GitOAI5GHeadVersion
print "NFSTestsResultsDir = " + NFSTestsResultsDir print "NFSTestsResultsDir = " + NFSTestsResultsDir
...@@ -1338,7 +1353,6 @@ for testcase in testcaseList: ...@@ -1338,7 +1353,6 @@ for testcase in testcaseList:
desc = testcase.findtext('desc',default='') desc = testcase.findtext('desc',default='')
#print "Machine list top level = " + ','.join(MachineList) #print "Machine list top level = " + ','.join(MachineList)
if search_test_case_group(testcasename, testcasegroup, TestCaseExclusionList) == True: if search_test_case_group(testcasename, testcasegroup, TestCaseExclusionList) == True:
cleanOldProgramsAllMachines(oai_list, CleanUpOldProgs, CleanUpAluLteBox, ExmimoRfStop)
if testcaseclass == 'lte-softmodem' : if testcaseclass == 'lte-softmodem' :
eNBMachine = testcase.findtext('eNB',default='') eNBMachine = testcase.findtext('eNB',default='')
UEMachine = testcase.findtext('UE',default='') UEMachine = testcase.findtext('UE',default='')
...@@ -1351,11 +1365,12 @@ for testcase in testcaseList: ...@@ -1351,11 +1365,12 @@ for testcase in testcaseList:
print "eNBMachine : " + eNBMachine + "UEMachine : " + UEMachine + "EPCMachine : " + EPCMachine + "MachineList : " + ','.join(MachineList) print "eNBMachine : " + eNBMachine + "UEMachine : " + UEMachine + "EPCMachine : " + EPCMachine + "MachineList : " + ','.join(MachineList)
print "testcasename = " + testcasename + " class = " + testcaseclass print "testcasename = " + testcasename + " class = " + testcaseclass
threadListGlobal = wait_testcaseclass_generic_threads(threadListGlobal, Timeout_execution) 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 ) handle_testcaseclass_softmodem (testcase, CleanUpOldProgs, logdirOAI5GRepo, logdirOpenaircnRepo, MachineList, user, pw, CleanUpAluLteBox, ExmimoRfStop )
elif (testcaseclass == 'compilation'): elif (testcaseclass == 'compilation'):
threadListGlobal = handle_testcaseclass_generic (testcasename, threadListGlobal, CleanUpOldProgs, logdirOAI5GRepo, MachineListGeneric, user, pw, CleanUpAluLteBox,Timeout_execution, ExmimoRfStop) threadListGlobal = handle_testcaseclass_generic (testcasename, threadListGlobal, CleanUpOldProgs, logdirOAI5GRepo, MachineListGeneric, user, pw, CleanUpAluLteBox,Timeout_execution, ExmimoRfStop)
elif (testcaseclass == 'execution'): elif (testcaseclass == 'execution'):
threadListGlobal = handle_testcaseclass_generic (testcasename, threadListGlobal, CleanUpOldProgs, logdirOAI5GRepo, MachineListGeneric, user, pw, CleanUpAluLteBox,ExmimoRfStop) threadListGlobal = handle_testcaseclass_generic (testcasename, threadListGlobal, CleanUpOldProgs, logdirOAI5GRepo, MachineListGeneric, user, pw, CleanUpAluLteBox, Timeout_execution, ExmimoRfStop)
else : else :
print "Unknown test case class: " + testcaseclass print "Unknown test case class: " + testcaseclass
sys.exit() sys.exit()
...@@ -1370,13 +1385,15 @@ for testcase in testcaseList: ...@@ -1370,13 +1385,15 @@ for testcase in testcaseList:
#sys.exit(1) #sys.exit(1)
print "Exiting the test cases execution now..." print "Exiting the test cases execution now. Waiting for existing threads to complete..."
for t in threadListGlobal: for param in threadListGlobal:
t.join 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 " cmd = "cat $OPENAIR_DIR/cmake_targets/autotests/log/*/*.xml > $OPENAIR_DIR/cmake_targets/autotests/log/results_autotests.xml "
os.system('cmd') res=os.system(cmd)
print "Now copying files to NFS Share" print "Now copying files to NFS Share"
oai_localhost = openair('localdomain','localhost') oai_localhost = openair('localdomain','localhost')
...@@ -1388,7 +1405,7 @@ print "Deleting NFSTestResults Dir..." + res ...@@ -1388,7 +1405,7 @@ print "Deleting NFSTestResults Dir..." + res
print "Copying files from GilabCI Runner Machine : " + host + "locallogdir = " + locallogdir + ", NFSTestsResultsDir = " + NFSTestsResultsDir print "Copying files from GilabCI Runner Machine : " + host + "locallogdir = " + locallogdir + ", NFSTestsResultsDir = " + NFSTestsResultsDir
#ssh = SSHSession(UEMachine , username=user, key_file=None, password=password) #ssh = SSHSession(UEMachine , username=user, key_file=None, password=password)
#ssh.get_all(logdir_UE , logdir_local + '/cmake_targets/autotests/log/'+ testcasename) #ssh.get_all(logdir_UE , logdir_local + '/cmake_targets/autotests/log/'+ testcasename)
SSHSessionWrapper('localhost', user, None, password, NFSTestsResultsDir , locallogdir, "put_all") SSHSessionWrapper('localhost', user, None, pw , NFSTestsResultsDir , locallogdir, "put_all")
sys.exit() sys.exit()
......
<testCaseList> <testCaseList>
<MachineList>calisson mozart stevens nano amerique</MachineList> <MachineList>mozart calisson stevens nano </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>
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<ExmimoRfStop>$OPENAIR_DIR/cmake_targets/build_oai -w EXMIMO -c; sudo -S -E $OPENAIR_DIR/cmake_targets/tools/stop_exmimo2; dmesg|tail</ExmimoRfStop> <ExmimoRfStop>$OPENAIR_DIR/cmake_targets/build_oai -w EXMIMO -c; sudo -S -E $OPENAIR_DIR/cmake_targets/tools/stop_exmimo2; dmesg|tail</ExmimoRfStop>
<Timeout_execution>36000</Timeout_execution> <Timeout_execution>36000</Timeout_execution>
<TestCaseExclusionList>0104+ 015502 015505 015506 015507 015508 015508 015509 015510 015511 015600 015700 016102 016105</TestCaseExclusionList> <TestCaseExclusionList>0104+ 015502 015505 015506 015507 015508 015508 015509 015510 015511 015600 015700 016102 016105</TestCaseExclusionList>
<MachineListGeneric>calisson stevens mozart nano amerique</MachineListGeneric> <MachineListGeneric>mozart calisson stevens nano </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