From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7211363025731715072 X-Received: by 2002:a67:c104:0:b0:425:e457:6dfc with SMTP id d4-20020a67c104000000b00425e4576dfcmr3257749vsj.0.1679460378253; Tue, 21 Mar 2023 21:46:18 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:ac5:cbe8:0:b0:435:c285:c5a0 with SMTP id i8-20020ac5cbe8000000b00435c285c5a0ls1588648vkn.1.-pod-prod-gmail; Tue, 21 Mar 2023 21:46:17 -0700 (PDT) X-Google-Smtp-Source: AK7set8bPJs84Vu2sQoo/9joE36JQmf91lu0622wOhm0xVhRwP8x/RpZPsGvlDGuDaHqm+IJ94z/ X-Received: by 2002:a1f:641b:0:b0:3ea:8d4d:4ffb with SMTP id y27-20020a1f641b000000b003ea8d4d4ffbmr2021153vkb.8.1679460377320; Tue, 21 Mar 2023 21:46:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679460377; cv=none; d=google.com; s=arc-20160816; b=NYlos2IitKjBD7AvKkJzeLjoXv4L6weM/n5NmRkSsFS57LlASqQ2NuBkJWlXngDYPd B8Rk/A1j+K+mqA7bdV7xivI0MBauonBx0ukVfGyaldcrjCgVlrKbHFwQUM/2T63JL4v+ 0ehe4wa89h9nDNNepuyN0BSihdjmVXQcVpmUQL532gVCV5VrPm2G4bg1uGEiaFvU5oxB MkkB9wxX4L4PHnGPNOCJwK86Uec4henAMxZ17g2WwUyCVYBrCmmUuVC0N9Mulr9cJC/u pIwpZG0SPMhE3LuZXpd84/Q6MCpVEBDDe1bF4a72vBCx16Hbp987wTtzBR5sE2nCUyQd 2u8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from; bh=s1E35qJ5rumKJu88rx5UB/OvGC0+revo9XyepkpNXtM=; b=M/6zeYlQOJHrUGGSRoBhCvHAQZTX8NbZIGx4RfQmgtRKxxzOMOQhGmS4i6U/Xy/GCs JBAQF0rGsrRstvjA+YMANJkqkW7rjN8ZSUoCZGKMpJXJ/fEiACTA7askSIYdus3WaRqI HCRG81vTC1c9yYFokCoO6eIiQrMHb3htucA4NmU2TMAuCFygDUn9lE+WAWNDXQb8fwHQ kldJqpGd8kwCViK/15KEoMiBQf/h3iYaMYrVTg+0c+OEce+ghgVL8/C205BN+SNyK+9a lZlRpoZKRAkI08ae01Sj4yrsgsPJ65NKhDTuuHEG/qAwxUqHh/QyDZqLXVHagZM8ZNNs RhXw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of ubely@ilbers.de designates 85.214.156.166 as permitted sender) smtp.mailfrom=ubely@ilbers.de Return-Path: Received: from shymkent.ilbers.de (shymkent.ilbers.de. [85.214.156.166]) by gmr-mx.google.com with ESMTPS id f37-20020ab014e8000000b00690829432ebsi1113221uae.2.2023.03.21.21.46.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Mar 2023 21:46:17 -0700 (PDT) Received-SPF: pass (google.com: domain of ubely@ilbers.de designates 85.214.156.166 as permitted sender) client-ip=85.214.156.166; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of ubely@ilbers.de designates 85.214.156.166 as permitted sender) smtp.mailfrom=ubely@ilbers.de Received: from baighyz.m.ilbers.de (host-80-81-17-52.static.customer.m-online.net [80.81.17.52]) (authenticated bits=0) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPSA id 32M4kEQj028302 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 22 Mar 2023 05:46:14 +0100 From: Uladzimir Bely To: isar-users@googlegroups.com Subject: [PATCH v2] testsuite: Improve SSH ping Date: Wed, 22 Mar 2023 05:46:14 +0100 Message-Id: <20230322044614.1054-1-ubely@ilbers.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shymkent.ilbers.de X-TUID: UwGPiErro7tS 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 --- 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