support/testing: remove hardcoded sleep from python-flask test
PATCH 1/1 support/testing: remove hardcoded sleep from python-flask test
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 <[email protected]>
--- support/testing/tests/package/test_python_flask.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
support/testing/tests/package/test_python_flask.py +9 -5
@@ -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")
Signature · 6 lines
2.43.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Thomas Petazzoni via buildroot
AppliedQuoted 8 lines · On Wed, 7 Feb 2024 18:15:12 +0100 Marcus Hoffmann via 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 <[email protected]>--- support/testing/tests/package/test_python_flask.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
Applied to master, thanks.
Thomas
Signature · 7 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot