Commit 42a21722 authored by Raphael Defosseux's avatar Raphael Defosseux

CI: fixes for OpenShift deployment of physical-simulators

  -- Missing finished tag in one deployment
  -- Deep copy of the array of pod names
  -- Hack for the out-of-sync on pexpect for `oc logs` and `oc get pods` commands
Signed-off-by: default avatarRaphael Defosseux <raphael.defosseux@eurecom.fr>
parent 7acc966b
...@@ -40,6 +40,7 @@ spec: ...@@ -40,6 +40,7 @@ spec:
export OPENAIR_DIR=/opt/oai-physim && export OPENAIR_DIR=/opt/oai-physim &&
cd cmake_targets/autotests && cd cmake_targets/autotests &&
./run_exec_autotests.bash -g "015106" -q -np -b && ./run_exec_autotests.bash -g "015106" -q -np -b &&
echo "FINISHED" &&
sleep infinity sleep infinity
dnsPolicy: ClusterFirst dnsPolicy: ClusterFirst
restartPolicy: Always restartPolicy: Always
......
...@@ -189,7 +189,7 @@ class PhySim: ...@@ -189,7 +189,7 @@ class PhySim:
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
podNames = re.findall('oai[\S\d\w]+', mySSH.getBefore()) podNames = re.findall('oai-[\S\d\w]+', mySSH.getBefore())
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')
...@@ -200,14 +200,15 @@ class PhySim: ...@@ -200,14 +200,15 @@ class PhySim:
# Waiting to complete the running test # Waiting to complete the running test
count = 0 count = 0
isFinished = False isFinished = False
tmpPodNames = podNames # doing a deep copy!
while(count < 25 and isFinished == False): tmpPodNames = podNames.copy()
time.sleep(58) while(count < 28 and isFinished == False):
time.sleep(60)
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)
if mySSH.getBefore().count('Finished') != 0: if mySSH.getBefore().count('FINISHED') != 0:
logging.debug(podName + ' is finished')
tmpPodNames.remove(podName) tmpPodNames.remove(podName)
time.sleep(2)
if not tmpPodNames: if not tmpPodNames:
isFinished = True isFinished = True
count += 1 count += 1
...@@ -216,14 +217,14 @@ class PhySim: ...@@ -216,14 +217,14 @@ 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', '\$', 6) mySSH.command(f'oc logs {podName} >> cmake_targets/log/physim_test.txt 2>&1', '\$', 15)
time.sleep(30) time.sleep(30)
# UnDeploy the physical simulator pods # UnDeploy the physical simulator pods
mySSH.command('helm uninstall physim | tee -a cmake_targets/log/physim_helm_summary.txt 2>&1', '\$', 6) mySSH.command('helm uninstall physim | tee -a cmake_targets/log/physim_helm_summary.txt 2>&1', '\$', 6)
isFinished1 = False isFinished1 = False
while(isFinished1 == False): while(isFinished1 == False):
time.sleep(10) 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)
if re.search('No resources found', mySSH.getBefore()): if re.search('No resources found', mySSH.getBefore()):
isFinished1 = True isFinished1 = True
......
...@@ -112,8 +112,17 @@ class SSHConnection(): ...@@ -112,8 +112,17 @@ class SSHConnection():
return self.sshresponse return self.sshresponse
def command(self, commandline, expectedline, timeout): def command(self, commandline, expectedline, timeout):
if commandline.count('oc logs') == 0:
logging.debug(commandline) logging.debug(commandline)
self.ssh.timeout = timeout self.ssh.timeout = timeout
# Nasty patch when pexpect output is out of sync.
# Much pronounced when running back-to-back-back oc commands
if (commandline.count('oc logs') > 0) or (commandline.count('oc get') > 0):
self.ssh.send(commandline)
self.ssh.expect([commandline, pexpect.TIMEOUT])
self.ssh.send('\r\n')
self.sshresponse = self.ssh.expect([expectedline, pexpect.EOF, pexpect.TIMEOUT])
else:
self.ssh.sendline(commandline) self.ssh.sendline(commandline)
self.sshresponse = self.ssh.expect([expectedline, pexpect.EOF, pexpect.TIMEOUT]) self.sshresponse = self.ssh.expect([expectedline, pexpect.EOF, pexpect.TIMEOUT])
if self.sshresponse == 0: if self.sshresponse == 0:
......
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