From: Uladzimir Bely <ubely@ilbers.de>
To: isar-users@googlegroups.com
Subject: [PATCH v2] testsuite: Improve SSH ping
Date: Wed, 22 Mar 2023 05:46:14 +0100 [thread overview]
Message-ID: <20230322044614.1054-1-ubely@ilbers.de> (raw)
When qemu machine boots, it may happen that consecutive SSH connection
fails right after the previous good one. So, we get a situation when
the command/script fails after we consider SSH is ready.
This patch improves detection of SSH server ready status by making at
least three good consecutive SSH pings.
Example of debug output that shows the case:
```
| Waiting for SSH server ready...
| SSH ping result: 255, left: 300s # <== machine is booting
| SSH ping result: 255, left: 294s
| SSH ping result: 255, left: 288s
| SSH ping result: 255, left: 282s
| SSH ping result: 255, left: 276s
| SSH ping result: 255, left: 270s
| SSH ping result: 255, left: 264s
| SSH ping result: 255, left: 258s
| SSH ping result: 0, left: 253s # <== SSH server is up...
| SSH ping result: 0, left: 251s
| SSH ping result: 255, left: 250s # <== but one ping failed again
| SSH ping result: 0, left: 248s
| SSH ping result: 0, left: 245s
| SSH ping result: 0, left: 243s # <== 3 good pings considered
| `lsmod | grep example_module` returned 0
```
Signed-off-by: Uladzimir Bely <ubely@ilbers.de>
---
Changes since v1:
- patch simplified a bit for better readability
- less unnecessary debug logs are produced
testsuite/cibuilder.py | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/testsuite/cibuilder.py b/testsuite/cibuilder.py
index 9e84c3a3..cd8ff6d4 100755
--- a/testsuite/cibuilder.py
+++ b/testsuite/cibuilder.py
@@ -257,7 +257,10 @@ class CIBuilder(Test):
self.log.debug('Waiting for SSH server ready...')
rc = None
- while time.time() < timeout:
+ goodcnt = 0
+ # Use 3 good SSH ping attempts to consider SSH connection is stable
+ while time.time() < timeout and goodcnt < 3:
+ goodcnt += 1
if proc.poll() is not None:
self.log.error('Machine is not running')
return rc
@@ -265,12 +268,11 @@ class CIBuilder(Test):
rc = self.exec_cmd('/bin/true', cmd_prefix)
time.sleep(1)
- if rc == 0:
- self.log.debug('SSH server is ready')
- break
+ if rc != 0:
+ goodcnt = 0
- if rc != 0:
- self.log.error('SSH server is not ready')
+ time_left = timeout - time.time()
+ self.log.debug('SSH ping result: %d, left: %.fs' % (rc, time_left))
return rc
--
2.20.1
next reply other threads:[~2023-03-22 4:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-22 4:46 Uladzimir Bely [this message]
2023-03-28 4:48 ` Uladzimir Bely
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230322044614.1054-1-ubely@ilbers.de \
--to=ubely@ilbers.de \
--cc=isar-users@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox