Skip to content

Commit

Permalink
Merge v2.11 beta3.1+fall2024 (#149)
Browse files Browse the repository at this point in the history
* [FIX] Handle Python test execution runtime errors (#145)

* Handle Python test execution runtime errors

* Update test_collections/matter/sdk_tests/support/python_testing/models/test_case.py

Co-authored-by: hiltonlima <116589806+hiltonlima@users.noreply.github.com>

---------

Co-authored-by: hiltonlima <116589806+hiltonlima@users.noreply.github.com>

* [FIX] Force container removal at destroy (#143)

* Force container removal

* Remove __wait_for_server_exit

* Surround __wait_for_server_exit with try except

* Fix mypy

* Fix data_model mapped volume

* Update test_collections/matter/sdk_tests/support/sdk_container.py

Co-authored-by: Romulo Quidute Filho <116586593+rquidute@users.noreply.github.com>

---------

Co-authored-by: Romulo Quidute Filho <116586593+rquidute@users.noreply.github.com>
Co-authored-by: Romulo Quidute Filho <rquidute@apple.com>
  • Loading branch information
3 people authored Sep 26, 2024
1 parent f52d40a commit a26827a
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .version_information
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.11-beta3+fall2024
v2.11-beta3.1+fall2024
2 changes: 1 addition & 1 deletion app/container_manager/container_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 12 additions & 4 deletions test_collections/matter/sdk_tests/support/chip/chip_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,19 @@ 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(
"Could not get exit code after pkill command "
f"{self.__server_full_command}."
)
self.logger.debug(str(e))

self.__wait_for_server_exit()
self.__server_started = False

def trace_file_params(self, topic: str) -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,22 @@ def main() -> None:


def run_test(script_path: str, class_name: str, config: MatterTestConfig) -> None:
# For a script_path like 'custom/TC_XYZ' the module is 'custom.TC_XYZ'
module = importlib.import_module(script_path.replace("/", "."))
TestClassReference = getattr(module, class_name)

BaseManager.register(TestRunnerHooks.__name__)
manager = BaseManager(address=("0.0.0.0", 50000), authkey=b"abc")
manager.connect()
test_runner_hooks = manager.TestRunnerHooks() # shared object proxy # type: ignore

run_tests(TestClassReference, config, test_runner_hooks)
try:
# For a script_path like 'custom/TC_XYZ' the module is 'custom.TC_XYZ'
module = importlib.import_module(script_path.replace("/", "."))
TestClassReference = getattr(module, class_name)

run_tests(TestClassReference, config, test_runner_hooks)
except Exception as e:
test_runner_hooks.step_failure(
logger=None, logs=str(e), duration=0, request=None, received=None
)
test_runner_hooks.stop(duration=0)


def commission(config: MatterTestConfig) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ def step_success(self, logger: Any, logs: str, duration: int, request: Any) -> N
def step_failure(
self, logger: Any, logs: str, duration: int, request: Any, received: Any
) -> None:
self.mark_step_failure("Python test step failure")
failure_msg = "Python test step failure"
if logs:
failure_msg += f": {logs}"

self.mark_step_failure(failure_msg)

# Python tests with only 2 steps are the ones that don't follow the template.
# In the case of a test file with multiple test cases, more than one of these
Expand Down
8 changes: 8 additions & 0 deletions test_collections/matter/sdk_tests/support/sdk_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
)
DOCKER_PYTHON_TESTING_PATH = "/root/python_testing"

MAPPED_DATA_MODEL_VOLUME = "mapped_data_model_volume"
DOCKER_DATA_MODEL_PATH = DOCKER_PYTHON_TESTING_PATH + "/data_model"


# RPC Client Running on SDK Container
LOCAL_RPC_PYTHON_TESTING_PATH = Path(
LOCAL_TEST_COLLECTIONS_PATH + "/sdk_tests/support/python_testing/models/rpc_client/"
Expand Down Expand Up @@ -108,6 +112,10 @@ class SDKContainer(metaclass=Singleton):
"bind": DOCKER_PYTHON_TESTING_PATH,
"mode": "rw",
},
MAPPED_DATA_MODEL_VOLUME: {
"bind": DOCKER_DATA_MODEL_PATH,
"mode": "rw",
},
LOCAL_RPC_PYTHON_TESTING_PATH: {
"bind": DOCKER_RPC_PYTHON_TESTING_PATH,
"mode": "rw",
Expand Down

0 comments on commit a26827a

Please sign in to comment.