Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove start and stop from run #30396

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions scripts/py_matter_yamltests/matter_yamltests/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,15 @@ class TestRunnerConfig:
hooks: A configurable set of hooks to be called at various steps while
running. It may may allow the callers to gain insights about the
current running state.

auto_start_stop: Indicates whether the run method should start and stop
the runner of if that will be handled outside of that method.
"""
adapter: TestAdapter = None
pseudo_clusters: PseudoClusters = PseudoClusters([])
options: TestRunnerOptions = field(default_factory=TestRunnerOptions)
hooks: TestRunnerHooks = TestRunnerHooks()
auto_start_stop: bool = True


class TestRunnerBase(ABC):
Expand Down Expand Up @@ -109,7 +113,7 @@ async def execute(self, request):
pass

@abstractmethod
def run(self, config: TestRunnerConfig) -> bool:
def run(self, parser_builder_config: TestParserBuilderConfig, runner_config: TestRunnerConfig) -> bool:
"""
This method runs a test suite.

Expand Down Expand Up @@ -156,12 +160,14 @@ async def run(self, parser_builder_config: TestParserBuilderConfig, runner_confi
async def _run_with_timeout(self, parser: TestParser, config: TestRunnerConfig):
status = True
try:
await self.start()
if config.auto_start_stop:
await self.start()
status = await asyncio.wait_for(self._run(parser, config), parser.timeout)
except (Exception, CancelledError) as exception:
status = exception
finally:
await self.stop()
if config.auto_start_stop:
await self.stop()
return status

async def _run(self, parser: TestParser, config: TestRunnerConfig):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ def __init__(self, config: WebSocketRunnerConfig):
self._server_startup_command = self._make_server_startup_command(
config.server_path, config.server_arguments, config.server_port)

@property
def is_connected(self) -> bool:
if self._client is None:
return False

return self._client.state == websockets.protocol.State.OPEN

async def start(self):
self._server = await self._start_server(self._server_startup_command)
self._client = await self._start_client(self._server_connection_url)
Expand Down
Loading