From patchwork Wed Feb 7 17:15:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcus Hoffmann X-Patchwork-Id: 1896242 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=buildroot.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver=patchwork.ozlabs.org) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TVRb42DDjz23hb for ; Thu, 8 Feb 2024 04:15:44 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 4F91B416F4; Wed, 7 Feb 2024 17:15:42 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LZL2OyA8X7Cu; Wed, 7 Feb 2024 17:15:41 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.34; helo=ash.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 359D4416D4 Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp2.osuosl.org (Postfix) with ESMTP id 359D4416D4; Wed, 7 Feb 2024 17:15:41 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 99E631BF350 for ; Wed, 7 Feb 2024 17:15:39 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 94856408BD for ; Wed, 7 Feb 2024 17:15:39 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xdnCErmwsi0y for ; Wed, 7 Feb 2024 17:15:38 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=176.9.145.28; helo=smtp.bubu1.eu; envelope-from=buildroot@bubu1.eu; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp4.osuosl.org B098F408A7 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org B098F408A7 Received: from smtp.bubu1.eu (smtp.bubu1.eu [176.9.145.28]) by smtp4.osuosl.org (Postfix) with ESMTPS id B098F408A7 for ; Wed, 7 Feb 2024 17:15:38 +0000 (UTC) Received: from bubutux.localdomain (ip-185-104-138-44.ptr.icomera.net [185.104.138.44]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.bubu1.eu (Postfix) with ESMTPSA id 5542F2C83776; Wed, 7 Feb 2024 18:15:36 +0100 (CET) To: buildroot@buildroot.org Date: Wed, 7 Feb 2024 18:15:12 +0100 Message-ID: <20240207171513.2673706-1-buildroot@bubu1.eu> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=bubu1.eu; s=bubu; t=1707326136; bh=kHlCmqJhaxFD0j9xmKBEB4Bmhv4SO22aqscvRZxQNhc=; h=From:To:Cc:Subject:Date; b=Yx3YMNLd3OTmpUASGmxjRnxHlSSufIbmDZ+wvbAdHDVpbB8i1bXhT4mqmLqnFraPS EzPih7k3b7WLea4WHW7Zzb1pV8kaXjBJk3K0/IxfOG5frg3Tglpts5y74If6XzfOD7 jSv8vcoecW04+yWKZISjmbNrM3TLIDUEKwxeTOxUjbLiFlUWLoHoPKII1dNW+G2k3u iYIB0t3NLUTca31BWh3DsLorUEtmtSHXGFbRudaLHMsMmXw3RbWtdOzlNzk6T2PjQy N6eLQNSOr8YfT+xod8CFz+7FXU/uTb8GF4nnoU+SVihDRJYD+c8HdSfHoOfwIg03/K KtiAc00Pv4J4A== X-Mailman-Original-Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=reject dis=none) header.from=bubu1.eu X-Mailman-Original-Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key) header.d=bubu1.eu header.i=@bubu1.eu header.a=rsa-sha256 header.s=bubu header.b=Yx3YMNLd Subject: [Buildroot] [PATCH] support/testing: remove hardcoded sleep from python-flask test X-BeenThere: buildroot@buildroot.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Marcus Hoffmann via buildroot From: Marcus Hoffmann Reply-To: Marcus Hoffmann Cc: Lionel Flandrin , Marcus Hoffmann , Thomas Petazzoni Errors-To: buildroot-bounces@buildroot.org Sender: "buildroot" Similar to the new fastapi test, instead of waiting for a hard coded amount of time we can retry every second until the server is available and abort if after the timeout we still didn't manage to connect. Signed-off-by: Marcus Hoffmann --- support/testing/tests/package/test_python_flask.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/support/testing/tests/package/test_python_flask.py b/support/testing/tests/package/test_python_flask.py index 9d8587e918..32d9da34a5 100644 --- a/support/testing/tests/package/test_python_flask.py +++ b/support/testing/tests/package/test_python_flask.py @@ -21,9 +21,13 @@ class TestPythonPy3Flask(TestPythonPackageBase): _, exit_code = self.emulator.run(cmd, timeout=self.timeout) # Give enough time for the flask server to start up - time.sleep(30) + for attempt in range(30): + time.sleep(1) - cmd = "wget -q -O - http://127.0.0.1:5000/" - output, exit_code = self.emulator.run(cmd, timeout=self.timeout) - self.assertEqual(exit_code, 0) - self.assertEqual(output[0], "Hello, World!") + cmd = "wget -q -O - http://127.0.0.1:5000/" + output, exit_code = self.emulator.run(cmd, timeout=self.timeout) + if exit_code == 0: + self.assertEqual(output[0], 'Hello, World!') + break + else: + self.assertTrue(False, "Timeout while waiting for flask server")