mirror of
https://git.yoctoproject.org/poky
synced 2026-02-26 19:39:40 +01:00
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>
35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
#
|
|
# Copyright OpenEmbedded Contributors
|
|
#
|
|
# SPDX-License-Identifier: MIT
|
|
#
|
|
|
|
import time
|
|
|
|
from oeqa.runtime.case import OERuntimeTestCase
|
|
from oeqa.core.decorator.depends import OETestDepends
|
|
from oeqa.runtime.decorator.package import OEHasPackage
|
|
|
|
class SSHTest(OERuntimeTestCase):
|
|
|
|
@OETestDepends(['ping.PingTest.test_ping'])
|
|
@OEHasPackage(['dropbear', 'openssh-sshd'])
|
|
def test_ssh(self):
|
|
for i in range(5):
|
|
status, output = self.target.run("uname -a", timeout=5)
|
|
if status == 0:
|
|
break
|
|
elif status == 255:
|
|
# ssh returns 255 only if a ssh error occurs. This could
|
|
# be an issue with "Connection refused" because the port
|
|
# isn't open yet, and this could check explicitly for that
|
|
# here. However, let's keep it simple and just retry for
|
|
# all errors a limited amount of times with a sleep to
|
|
# give it time for the port to open.
|
|
time.sleep(5)
|
|
continue
|
|
else:
|
|
self.fail("uname failed with \"%s\"" %output)
|
|
if status == 255:
|
|
self.fail("ssh error %s" %output)
|