All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] support/testing: remove hardcoded sleep from python-flask test
@ 2024-02-07 17:15 Marcus Hoffmann via buildroot
  2024-02-11 22:12 ` Thomas Petazzoni via buildroot
  0 siblings, 1 reply; 2+ messages in thread
From: Marcus Hoffmann via buildroot @ 2024-02-07 17:15 UTC (permalink / raw)
  To: buildroot; +Cc: Lionel Flandrin, Marcus Hoffmann, Thomas Petazzoni

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 <buildroot@bubu1.eu>
---
 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")
-- 
2.43.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Buildroot] [PATCH] support/testing: remove hardcoded sleep from python-flask test
  2024-02-07 17:15 [Buildroot] [PATCH] support/testing: remove hardcoded sleep from python-flask test Marcus Hoffmann via buildroot
@ 2024-02-11 22:12 ` Thomas Petazzoni via buildroot
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Petazzoni via buildroot @ 2024-02-11 22:12 UTC (permalink / raw)
  To: Marcus Hoffmann via buildroot; +Cc: Lionel Flandrin, Marcus Hoffmann

On Wed,  7 Feb 2024 18:15:12 +0100
Marcus Hoffmann via buildroot <buildroot@buildroot.org> wrote:

> 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 <buildroot@bubu1.eu>
> ---
>  support/testing/tests/package/test_python_flask.py | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)

Applied to master, thanks.

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-02-11 22:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-07 17:15 [Buildroot] [PATCH] support/testing: remove hardcoded sleep from python-flask test Marcus Hoffmann via buildroot
2024-02-11 22:12 ` Thomas Petazzoni via buildroot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.