From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7211363025731715072 X-Received: by 2002:a17:90b:f08:b0:237:20cf:de16 with SMTP id br8-20020a17090b0f0800b0023720cfde16mr1927415pjb.4.1679026294261; Thu, 16 Mar 2023 21:11:34 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a17:90a:187:b0:210:6f33:e22d with SMTP id 7-20020a17090a018700b002106f33e22dls3842650pjc.2.-pod-control-gmail; Thu, 16 Mar 2023 21:11:33 -0700 (PDT) X-Google-Smtp-Source: AK7set9oWgmyOEupK99BPLPcn/mtd+Ozbmd3VH2SI4sF+gE5jIOZGaRlSfPhgR3pDiEa0AfXPSC+ X-Received: by 2002:a17:902:d18d:b0:19e:b2ed:6ff4 with SMTP id m13-20020a170902d18d00b0019eb2ed6ff4mr4754708plb.54.1679026293241; Thu, 16 Mar 2023 21:11:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679026293; cv=none; d=google.com; s=arc-20160816; b=lJREYWd1L/djUmsVUvNllO0hsLAHk/F3+Z/C0gbnbSptmOHMBD6otg9xIpfSVNmDES NBeSlzEtQlBkeCFiKIcZ2zPqLJJkLSjjr7yaSN2p1+MXgLFmXJxHLu7LXTnF40/0Z9FB hMlBTJgR4ZYp5Qhb2LdhGPGSqtl3AmI8I4lDZazLvzQT1KFtVKOV8C8kheTi4kJ1TTRh wIPjQ9WQSU0+BbGT3OHCiETcR1ZU9XALE+eixZQP0BGnwW3ZXRkIEJoj2z1hxWUZxqjB u9Lv9RtMrBHRIxmz6ZkTgDs25dN+Tbj/Ojm3Ioh9fvPiPfiPqYWKzzRXE9tsAZwroZL8 ZGrw== 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=J3BB81oszI81IhtK3NowFjdVW7JitSuaDFysZxCr7J8=; b=LeRCyJ5RVIRcESYpVNsJwl6dlACsGREGEF8/Gb2e5BORvFyj+kB9LZVJ4vmkSCwvqj EP151sjZI3+0yEO4V+Emi6AYtbZUYx8JimW0YIuB2idm3ltoMyYe6f6OxMPb7v8pxJja aNR9RjULjGuNKBUpm7wc8rLoK4liARqqk43nEqUp4DZawEOT03bPlTrn6Rg2H4iYFRz8 6Gd3UE0T/XaH2UPaDHQbdwZCh/68E3AmSLD63zfJ4yzQPLluMApQV1marVfxaby5SCP/ QHYaBBmhws0qoJX8XjF8aDaJPI4oen//2PX1jHRvMDpDxBD7jRZRjKku7s0/oiCVGY/z szJg== 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 d16-20020a170902b71000b001a0767b58e8si22384pls.7.2023.03.16.21.11.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 Mar 2023 21:11:32 -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 32H4BUD8003399 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 17 Mar 2023 05:11:30 +0100 From: Uladzimir Bely To: isar-users@googlegroups.com Subject: [PATCH] testsuite: Improve SSH ping Date: Fri, 17 Mar 2023 05:11:30 +0100 Message-Id: <20230317041130.7987-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: pKQghDqOocQl 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 | SSH server is ready | `lsmod | grep example_module` returned 0 ``` Signed-off-by: Uladzimir Bely --- testsuite/cibuilder.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/testsuite/cibuilder.py b/testsuite/cibuilder.py index 9e84c3a3..4e568b8e 100755 --- a/testsuite/cibuilder.py +++ b/testsuite/cibuilder.py @@ -257,17 +257,25 @@ class CIBuilder(Test): self.log.debug('Waiting for SSH server ready...') rc = None + goodcnt = 0 while time.time() < timeout: if proc.poll() is not None: self.log.error('Machine is not running') return rc rc = self.exec_cmd('/bin/true', cmd_prefix) + time_left = timeout - time.time() + self.log.debug('SSH ping result: %d, left: %.fs' % (rc, time_left)) time.sleep(1) if rc == 0: - self.log.debug('SSH server is ready') - break + goodcnt += 1 + # Let 3 good SSH pings to make sure SSH connection is stable + if goodcnt >= 3: + self.log.debug('SSH server is ready') + break + else: + goodcnt = 0 if rc != 0: self.log.error('SSH server is not ready') -- 2.20.1