Skip to content

Commit

Permalink
Start runner on setup and stop on clenaup
Browse files Browse the repository at this point in the history
  • Loading branch information
ccruzagralopes committed Nov 14, 2023
1 parent a271912 commit 23ec330
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
27 changes: 15 additions & 12 deletions app/chip_tool/chip_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,10 @@ def __wait_for_server_exit(self) -> Optional[int]:
return exit_code

async def stop_chip_tool_server(self) -> None:
await self.__test_harness_runner.start()
await self.start_runner()
await self.__test_harness_runner._client.send("quit()")
self.__wait_for_server_exit()
self.stop_runner()
self.__server_started = False

def __get_gateway_ip(self) -> str:
Expand Down Expand Up @@ -393,12 +394,15 @@ async def start_container(

def destroy_device(self) -> None:
"""Destroy the device container."""
self.stop_chip_tool_server()

if self.__chip_tool_container is not None:
container_manager.destroy(self.__chip_tool_container)
self.__chip_tool_container = None

async def start_runner(self) -> None:
await self.__test_harness_runner.start()
if not self.__test_harness_runner.is_connected:
await self.__test_harness_runner.start()

async def stop_runner(self) -> None:
await self.__test_harness_runner.stop()
Expand Down Expand Up @@ -470,12 +474,8 @@ def last_command_exit_code(self) -> Optional[int]:
return exit_code

async def send_websocket_command(self, cmd: str) -> Union[str, bytes, bytearray]:
response = None
try:
await self.__test_harness_runner.start()
response = await self.__test_harness_runner.execute(cmd)
finally:
await self.__test_harness_runner.stop()
await self.start_runner()
response = await self.__test_harness_runner.execute(cmd)

# Log response
if response:
Expand Down Expand Up @@ -523,12 +523,15 @@ async def run_websocket_test(
)
self.__runner_hooks = test_step_interface
runner_config = TestRunnerConfig(
adapter, self.pseudo_clusters, runner_options, test_step_interface
adapter,
self.pseudo_clusters,
runner_options,
test_step_interface,
auto_start_stop=False,
)

web_socket_config = WebSocketRunnerConfig()
web_socket_config.server_address = self.__get_gateway_ip()
self.__test_harness_runner = WebSocketRunner(config=web_socket_config)
await self.start_runner()

return await self.__test_harness_runner.run(
parser_builder_config, runner_config
)
Expand Down
4 changes: 0 additions & 4 deletions app/chip_tool/test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,8 @@ async def cleanup(self) -> None:
# the test completes. So we need to start it again to
# perform decommissioning
elif self.test_type == ChipToolTestType.CHIP_APP:
logger.info("Run simulated app instance to perform decommissioning")
await self.chip_tool.start_runner()
logger.info("Prompt user to perform decommissioning")
await self.__prompt_user_to_perform_decommission()
logger.info("Stop simulated app instance")
await self.chip_tool.stop_runner()

logger.info("Stopping chip-tool container")
self.chip_tool.destroy_device()
Expand Down

0 comments on commit 23ec330

Please sign in to comment.