summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorJon Mason <jdmason@kudzu.us>2024-06-24 18:20:24 -0400
committerSteve Sakoman <steve@sakoman.com>2024-08-26 05:18:44 -0700
commitdeea7587a0d4d5cd239562e95893e0533f03c1fd (patch)
tree66b4f36759f1c78bd5b36788849f35643aab84fc /meta
parent2d07b2b7342cb663a03a3d6976570ca26af651b5 (diff)
downloadpoky-deea7587a0d4d5cd239562e95893e0533f03c1fd.tar.gz
oeqa/runtime/ssh: add retry logic and sleeps to allow for slower systems
On exceptionally slow systems, the ssh test can intermittently fail due to a race between when ping works and the networking applications being brought up. To work around this issue, add some retry logic when ssh fails to connect. According to the man page of ssh, "ssh exits with the exit status of the remote command or with 255 if an error occurred." So, only retry if the return code is 255, and limit the number of retries to prevent it looping forever. (From OE-Core rev: f6eacc39dc44c6b3dea9c44836addce5d03f20ef) Signed-off-by: Jon Mason <jdmason@kudzu.us> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit f0fe0b490d309cdf1c97754f85a61b5b948b7f28) Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'meta')
-rw-r--r--meta/lib/oeqa/runtime/cases/ssh.py28
1 files changed, 19 insertions, 9 deletions
diff --git a/meta/lib/oeqa/runtime/cases/ssh.py b/meta/lib/oeqa/runtime/cases/ssh.py
index cdbef59500..ae92bb34cd 100644
--- a/meta/lib/oeqa/runtime/cases/ssh.py
+++ b/meta/lib/oeqa/runtime/cases/ssh.py
@@ -4,6 +4,8 @@
4# SPDX-License-Identifier: MIT 4# SPDX-License-Identifier: MIT
5# 5#
6 6
7import time
8
7from oeqa.runtime.case import OERuntimeTestCase 9from oeqa.runtime.case import OERuntimeTestCase
8from oeqa.core.decorator.depends import OETestDepends 10from oeqa.core.decorator.depends import OETestDepends
9from oeqa.runtime.decorator.package import OEHasPackage 11from oeqa.runtime.decorator.package import OEHasPackage
@@ -13,12 +15,20 @@ class SSHTest(OERuntimeTestCase):
13 @OETestDepends(['ping.PingTest.test_ping']) 15 @OETestDepends(['ping.PingTest.test_ping'])
14 @OEHasPackage(['dropbear', 'openssh-sshd']) 16 @OEHasPackage(['dropbear', 'openssh-sshd'])
15 def test_ssh(self): 17 def test_ssh(self):
16 (status, output) = self.target.run('sleep 20', timeout=2) 18 for i in range(5):
17 msg='run() timed out but return code was zero.' 19 status, output = self.target.run("uname -a", timeout=5)
18 self.assertNotEqual(status, 0, msg=msg) 20 if status == 0:
19 (status, output) = self.target.run('uname -a') 21 break
20 self.assertEqual(status, 0, msg='SSH Test failed: %s' % output) 22 elif status == 255:
21 (status, output) = self.target.run('cat /etc/controllerimage') 23 # ssh returns 255 only if a ssh error occurs. This could
22 msg = "This isn't the right image - /etc/controllerimage " \ 24 # be an issue with "Connection refused" because the port
23 "shouldn't be here %s" % output 25 # isn't open yet, and this could check explicitly for that
24 self.assertEqual(status, 1, msg=msg) 26 # here. However, let's keep it simple and just retry for
27 # all errors a limited amount of times with a sleep to
28 # give it time for the port to open.
29 time.sleep(5)
30 continue
31 else:
32 self.fail("uname failed with \"%s\"" %output)
33 if status == 255:
34 self.fail("ssh error %s" %output)