summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorJon Mason <jdmason@kudzu.us>2024-06-24 18:20:24 -0400
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-07-02 22:29:13 +0100
commita65a3dd4aaa9cba5219ebd136c43a0a9994f6161 (patch)
treeb8a5ba6aad7b4a950e90e6fad0c4f301ec74eadc /meta
parentceb6a4ecf9796c1c7b07f29ae4d435c589ed9957 (diff)
downloadpoky-a65a3dd4aaa9cba5219ebd136c43a0a9994f6161.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: f0fe0b490d309cdf1c97754f85a61b5b948b7f28) Signed-off-by: Jon Mason <jdmason@kudzu.us> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
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)