From fb7c44fc58168c7efafa1cf0af0616dfe44cfb2e Mon Sep 17 00:00:00 2001 From: Romulo Quidute Filho Date: Wed, 11 Sep 2024 22:21:49 +0000 Subject: [PATCH 1/4] Force container removal --- app/container_manager/container_manager.py | 2 +- test_collections/matter/sdk_tests/support/chip/chip_server.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/container_manager/container_manager.py b/app/container_manager/container_manager.py index 5b26a72a..cc3be8b7 100644 --- a/app/container_manager/container_manager.py +++ b/app/container_manager/container_manager.py @@ -45,7 +45,7 @@ async def create_container( def destroy(self, container: Container) -> None: if self.is_running(container): container.kill() - container.remove() + container.remove(force=True) def get_container(self, id_or_name: str) -> Optional[Container]: try: diff --git a/test_collections/matter/sdk_tests/support/chip/chip_server.py b/test_collections/matter/sdk_tests/support/chip/chip_server.py index bd27147b..d8d9a1e4 100644 --- a/test_collections/matter/sdk_tests/support/chip/chip_server.py +++ b/test_collections/matter/sdk_tests/support/chip/chip_server.py @@ -179,7 +179,6 @@ async def stop(self) -> None: f'-SIGTERM -f "{self.__server_full_command}"', prefix="pkill" ) - self.__wait_for_server_exit() self.__server_started = False def trace_file_params(self, topic: str) -> str: From 9a5bb69f64b4f25d1f4e60a0d606f63ed6829c91 Mon Sep 17 00:00:00 2001 From: Romulo Quidute Filho Date: Wed, 11 Sep 2024 22:27:38 +0000 Subject: [PATCH 2/4] Remove __wait_for_server_exit --- .../matter/sdk_tests/support/chip/chip_server.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/test_collections/matter/sdk_tests/support/chip/chip_server.py b/test_collections/matter/sdk_tests/support/chip/chip_server.py index d8d9a1e4..8b87c1a0 100644 --- a/test_collections/matter/sdk_tests/support/chip/chip_server.py +++ b/test_collections/matter/sdk_tests/support/chip/chip_server.py @@ -158,19 +158,6 @@ async def start( return cast(Generator, self.__server_logs) - def __wait_for_server_exit(self) -> Optional[int]: - if self.__chip_server_id is None: - self.logger.info( - "Server execution id not found, cannot wait for server exit." - ) - return None - - exit_code = self.sdk_container.exec_exit_code(self.__chip_server_id) - while exit_code is None: - exit_code = self.sdk_container.exec_exit_code(self.__chip_server_id) - - return exit_code - async def stop(self) -> None: if not self.__server_started: return From 8251e35b9330c94bc430d6c7eb29b3748d5520b5 Mon Sep 17 00:00:00 2001 From: Romulo Quidute Filho Date: Fri, 13 Sep 2024 17:53:30 +0000 Subject: [PATCH 3/4] Surround __wait_for_server_exit with try except --- .../sdk_tests/support/chip/chip_server.py | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/test_collections/matter/sdk_tests/support/chip/chip_server.py b/test_collections/matter/sdk_tests/support/chip/chip_server.py index 8b87c1a0..f48b9f94 100644 --- a/test_collections/matter/sdk_tests/support/chip/chip_server.py +++ b/test_collections/matter/sdk_tests/support/chip/chip_server.py @@ -158,13 +158,34 @@ async def start( return cast(Generator, self.__server_logs) + def __wait_for_server_exit(self) -> Optional[int]: + if self.__chip_server_id is None: + self.logger.info( + "Server execution id not found, cannot wait for server exit." + ) + return None + + exit_code = self.sdk_container.exec_exit_code(self.__chip_server_id) + while exit_code is None: + exit_code = self.sdk_container.exec_exit_code(self.__chip_server_id) + + return exit_code + async def stop(self) -> None: if not self.__server_started: return - self.sdk_container.send_command( - f'-SIGTERM -f "{self.__server_full_command}"', prefix="pkill" - ) + try: + self.sdk_container.send_command( + f'-SIGTERM -f "{self.__server_full_command}"', prefix="pkill" + ) + self.__wait_for_server_exit() + except Exception as e: + # Issue: https://github.com/project-chip/certification-tool/issues/414 + self.logger.info( + f"Could not get exit code after pkill command {__server_full_command}." + ) + self.logger.debug(str(e)) self.__server_started = False From 08276c34896e3beed84e5117018550db74fa3db2 Mon Sep 17 00:00:00 2001 From: Romulo Quidute Filho Date: Fri, 13 Sep 2024 17:56:24 +0000 Subject: [PATCH 4/4] Fix mypy --- test_collections/matter/sdk_tests/support/chip/chip_server.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test_collections/matter/sdk_tests/support/chip/chip_server.py b/test_collections/matter/sdk_tests/support/chip/chip_server.py index f48b9f94..7c8082a8 100644 --- a/test_collections/matter/sdk_tests/support/chip/chip_server.py +++ b/test_collections/matter/sdk_tests/support/chip/chip_server.py @@ -183,7 +183,8 @@ async def stop(self) -> None: except Exception as e: # Issue: https://github.com/project-chip/certification-tool/issues/414 self.logger.info( - f"Could not get exit code after pkill command {__server_full_command}." + "Could not get exit code after pkill command " + f"{self.__server_full_command}." ) self.logger.debug(str(e))