From b679529e4a17c8c810c89ec09bcd559925c019e2 Mon Sep 17 00:00:00 2001 From: Krisztian Notaisz <61833595+kn-ms@users.noreply.github.com> Date: Fri, 10 Nov 2023 15:35:22 +0100 Subject: [PATCH] make the plan wait properly for interactive start (#1019) moved the helper to a place from where it can be used in the executable as well as in the testcases. Co-authored-by: Krisztian Notaisz --- .../testplan/runnable/interactive/__init__.py | 13 ------------- .../runnable/interactive/interactive_executable.py | 2 ++ .../runnable/interactive/interactive_helper.py | 13 +++++++++++++ .../testplan/runnable/interactive/test_api.py | 2 +- .../runnable/interactive/test_interactive.py | 2 +- 5 files changed, 17 insertions(+), 15 deletions(-) create mode 100644 tests/functional/testplan/runnable/interactive/interactive_helper.py diff --git a/tests/functional/testplan/runnable/interactive/__init__.py b/tests/functional/testplan/runnable/interactive/__init__.py index 2940a72c8..e69de29bb 100644 --- a/tests/functional/testplan/runnable/interactive/__init__.py +++ b/tests/functional/testplan/runnable/interactive/__init__.py @@ -1,13 +0,0 @@ -from testplan.common.utils.timing import wait - - -def interactive_started(plan): - return plan.interactive.http_handler_info[0] is not None - - -def wait_for_interactive_start(plan): - wait( - lambda: interactive_started(plan), - 5, - raise_on_timeout=True, - ) diff --git a/tests/functional/testplan/runnable/interactive/interactive_executable.py b/tests/functional/testplan/runnable/interactive/interactive_executable.py index e1c5b96b5..034b413e1 100644 --- a/tests/functional/testplan/runnable/interactive/interactive_executable.py +++ b/tests/functional/testplan/runnable/interactive/interactive_executable.py @@ -6,6 +6,7 @@ from testplan import TestplanMock from testplan.testing.multitest import MultiTest from testplan.common.utils.comparison import compare +from interactive_helper import wait_for_interactive_start THIS_DIRECTORY = os.path.dirname(os.path.abspath(__file__)) @@ -435,6 +436,7 @@ def main(): kwargs=dict(name="ScheduledTest2"), ) plan.run() + wait_for_interactive_start(plan) # Run tests plan.interactive.run_all_tests() diff --git a/tests/functional/testplan/runnable/interactive/interactive_helper.py b/tests/functional/testplan/runnable/interactive/interactive_helper.py new file mode 100644 index 000000000..2940a72c8 --- /dev/null +++ b/tests/functional/testplan/runnable/interactive/interactive_helper.py @@ -0,0 +1,13 @@ +from testplan.common.utils.timing import wait + + +def interactive_started(plan): + return plan.interactive.http_handler_info[0] is not None + + +def wait_for_interactive_start(plan): + wait( + lambda: interactive_started(plan), + 5, + raise_on_timeout=True, + ) diff --git a/tests/functional/testplan/runnable/interactive/test_api.py b/tests/functional/testplan/runnable/interactive/test_api.py index 1c020553c..e784a5ac8 100644 --- a/tests/functional/testplan/runnable/interactive/test_api.py +++ b/tests/functional/testplan/runnable/interactive/test_api.py @@ -12,7 +12,7 @@ from testplan.report import Status, RuntimeStatus from testplan.testing import multitest from testplan.testing.multitest import driver -from tests.functional.testplan.runnable.interactive import ( +from tests.functional.testplan.runnable.interactive.interactive_helper import ( wait_for_interactive_start, ) from tests.unit.testplan.runnable.interactive import test_api diff --git a/tests/functional/testplan/runnable/interactive/test_interactive.py b/tests/functional/testplan/runnable/interactive/test_interactive.py index f2af46d5c..b93cdbbee 100644 --- a/tests/functional/testplan/runnable/interactive/test_interactive.py +++ b/tests/functional/testplan/runnable/interactive/test_interactive.py @@ -16,7 +16,7 @@ from testplan.environment import LocalEnvironment from testplan.testing.multitest import MultiTest, testcase, testsuite from testplan.testing.multitest.driver.tcp import TCPClient, TCPServer -from tests.functional.testplan.runnable.interactive import ( +from tests.functional.testplan.runnable.interactive.interactive_helper import ( wait_for_interactive_start, )