Commit 1041a6d8 authored by Raphael Defosseux's avatar Raphael Defosseux

CI: better silent and resync optional arguments

Signed-off-by: default avatarRaphael Defosseux <raphael.defosseux@eurecom.fr>
parent 42a21722
...@@ -185,7 +185,7 @@ class PhySim: ...@@ -185,7 +185,7 @@ class PhySim:
count = 0 count = 0
while(count < 2 and isRunning == False): while(count < 2 and isRunning == False):
time.sleep(60) time.sleep(60)
mySSH.command('oc get pods -l app.kubernetes.io/instance=physim', '\$', 6) mySSH.command('oc get pods -o wide -l app.kubernetes.io/instance=physim | tee -a cmake_targets/log/physim_pods_summary.txt', '\$', 6, resync=True)
if mySSH.getBefore().count('Running') == 12: if mySSH.getBefore().count('Running') == 12:
logging.debug('\u001B[1m Running the physim test Scenarios\u001B[0m') logging.debug('\u001B[1m Running the physim test Scenarios\u001B[0m')
isRunning = True isRunning = True
...@@ -193,7 +193,7 @@ class PhySim: ...@@ -193,7 +193,7 @@ class PhySim:
count +=1 count +=1
if isRunning == False: if isRunning == False:
logging.error('\u001B[1m Some PODS Running FAILED \u001B[0m') logging.error('\u001B[1m Some PODS Running FAILED \u001B[0m')
mySSH.command('oc get pods -l app.kubernetes.io/instance=physim > cmake_targets/log/physim_pods_summary.txt 2>&1', '\$', 6) mySSH.command('oc get pods -l app.kubernetes.io/instance=physim 2>&1 | tee -a cmake_targets/log/physim_pods_summary.txt', '\$', 6)
mySSH.command('helm uninstall physim >> cmake_targets/log/physim_helm_summary.txt 2>&1', '\$', 6) mySSH.command('helm uninstall physim >> cmake_targets/log/physim_helm_summary.txt 2>&1', '\$', 6)
self.AnalyzeLogFile_phySim(HTML) self.AnalyzeLogFile_phySim(HTML)
sys.exit(-1) sys.exit(-1)
...@@ -203,9 +203,10 @@ class PhySim: ...@@ -203,9 +203,10 @@ class PhySim:
# doing a deep copy! # doing a deep copy!
tmpPodNames = podNames.copy() tmpPodNames = podNames.copy()
while(count < 28 and isFinished == False): while(count < 28 and isFinished == False):
time.sleep(60) time.sleep(58)
for podName in tmpPodNames: for podName in tmpPodNames:
mySSH.command(f'oc logs --tail=1 {podName} 2>&1', '\$', 6) mySSH.command(f'oc logs --tail=1 {podName} 2>&1', '\$', 6, silent=True, resync=True)
time.sleep(2)
if mySSH.getBefore().count('FINISHED') != 0: if mySSH.getBefore().count('FINISHED') != 0:
logging.debug(podName + ' is finished') logging.debug(podName + ' is finished')
tmpPodNames.remove(podName) tmpPodNames.remove(podName)
...@@ -217,7 +218,7 @@ class PhySim: ...@@ -217,7 +218,7 @@ class PhySim:
# Getting the logs of each executables running in individual pods # Getting the logs of each executables running in individual pods
for podName in podNames: for podName in podNames:
mySSH.command(f'oc logs {podName} >> cmake_targets/log/physim_test.txt 2>&1', '\$', 15) mySSH.command(f'oc logs {podName} >> cmake_targets/log/physim_test.txt 2>&1', '\$', 15, resync=True)
time.sleep(30) time.sleep(30)
# UnDeploy the physical simulator pods # UnDeploy the physical simulator pods
...@@ -225,7 +226,7 @@ class PhySim: ...@@ -225,7 +226,7 @@ class PhySim:
isFinished1 = False isFinished1 = False
while(isFinished1 == False): while(isFinished1 == False):
time.sleep(20) time.sleep(20)
mySSH.command('oc get pods -l app.kubernetes.io/instance=physim', '\$', 6) mySSH.command('oc get pods -l app.kubernetes.io/instance=physim', '\$', 6, resync=True)
if re.search('No resources found', mySSH.getBefore()): if re.search('No resources found', mySSH.getBefore()):
isFinished1 = True isFinished1 = True
if isFinished1 == True: if isFinished1 == True:
...@@ -249,7 +250,7 @@ class PhySim: ...@@ -249,7 +250,7 @@ class PhySim:
mySSH.command('cd ' + lSourcePath, '\$', 5) mySSH.command('cd ' + lSourcePath, '\$', 5)
mySSH.command('cd ' + lSourcePath + '/cmake_targets', '\$', 5) mySSH.command('cd ' + lSourcePath + '/cmake_targets', '\$', 5)
mySSH.command('mkdir -p physim_test_log_' + self.testCase_id, '\$', 5) mySSH.command('mkdir -p physim_test_log_' + self.testCase_id, '\$', 5)
mySSH.command('mv log/physim_* ' + 'physim_test_log_' + self.testCase_id, '\$', 5) mySSH.command('cp log/physim_* ' + 'physim_test_log_' + self.testCase_id, '\$', 5)
if not os.path.exists(f'./physim_test_logs_{self.testCase_id}'): if not os.path.exists(f'./physim_test_logs_{self.testCase_id}'):
os.mkdir(f'./physim_test_logs_{self.testCase_id}') os.mkdir(f'./physim_test_logs_{self.testCase_id}')
mySSH.copyin(lIpAddr, lUserName, lPassWord, lSourcePath + '/cmake_targets/physim_test_log_' + self.testCase_id + '/*', './physim_test_logs_' + self.testCase_id) mySSH.copyin(lIpAddr, lUserName, lPassWord, lSourcePath + '/cmake_targets/physim_test_log_' + self.testCase_id + '/*', './physim_test_logs_' + self.testCase_id)
......
...@@ -111,13 +111,13 @@ class SSHConnection(): ...@@ -111,13 +111,13 @@ class SSHConnection():
self.sshresponse = self.ssh.expect(expected) self.sshresponse = self.ssh.expect(expected)
return self.sshresponse return self.sshresponse
def command(self, commandline, expectedline, timeout): def command(self, commandline, expectedline, timeout, silent=False, resync=False):
if commandline.count('oc logs') == 0: if not silent:
logging.debug(commandline) logging.debug(commandline)
self.ssh.timeout = timeout self.ssh.timeout = timeout
# Nasty patch when pexpect output is out of sync. # Nasty patch when pexpect output is out of sync.
# Much pronounced when running back-to-back-back oc commands # Much pronounced when running back-to-back-back oc commands
if (commandline.count('oc logs') > 0) or (commandline.count('oc get') > 0): if resync:
self.ssh.send(commandline) self.ssh.send(commandline)
self.ssh.expect([commandline, pexpect.TIMEOUT]) self.ssh.expect([commandline, pexpect.TIMEOUT])
self.ssh.send('\r\n') self.ssh.send('\r\n')
......
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