diff --git a/scripts/tests/yaml/runner.py b/scripts/tests/yaml/runner.py index 746fc01656f135..87a57c76f296c7 100755 --- a/scripts/tests/yaml/runner.py +++ b/scripts/tests/yaml/runner.py @@ -344,7 +344,10 @@ def chip_repl(parser_group: ParserGroup, adapter: str, stop_on_error: bool, stop runner_hooks = TestRunnerLogger(show_adapter_logs, show_adapter_logs_on_error, use_test_harness_log_format) runner_config = TestRunnerConfig(adapter, parser_group.pseudo_clusters, runner_options, runner_hooks) - runner = __import__(runner, fromlist=[None]).Runner(repl_storage_path, commission_on_network_dut) + node_id_to_commission = None + if commission_on_network_dut: + node_id_to_commission = parser_group.builder_config.parser_config.config_override['nodeId'] + runner = __import__(runner, fromlist=[None]).Runner(repl_storage_path, node_id_to_commission=node_id_to_commission) loop = asyncio.get_event_loop() return loop.run_until_complete(runner.run(parser_group.builder_config, runner_config)) diff --git a/src/controller/python/py_matter_yamltest_repl_adapter/matter_yamltest_repl_adapter/runner.py b/src/controller/python/py_matter_yamltest_repl_adapter/matter_yamltest_repl_adapter/runner.py index 40f19221358f68..aecba0b2c454e0 100644 --- a/src/controller/python/py_matter_yamltest_repl_adapter/matter_yamltest_repl_adapter/runner.py +++ b/src/controller/python/py_matter_yamltest_repl_adapter/matter_yamltest_repl_adapter/runner.py @@ -28,12 +28,12 @@ class Runner(TestRunner): - def __init__(self, repl_storage_path: str, commission_on_network_dut: bool): + def __init__(self, repl_storage_path: str, node_id_to_commission: int = None): self._repl_runner = None self._chip_stack = None self._certificate_authority_manager = None self._repl_storage_path = repl_storage_path - self._commission_on_network_dut = commission_on_network_dut + self._node_id_to_commission = node_id_to_commission async def start(self): chip.native.Init() @@ -43,13 +43,8 @@ async def start(self): chip_stack, chip_stack.GetStorageManager()) certificate_authority_manager.LoadAuthoritiesFromStorage() - commission_device = False if len(certificate_authority_manager.activeCaList) == 0: - if self._commission_on_network_dut is False: - raise Exception( - 'Provided repl storage does not contain certificate. Without commission_on_network_dut, there is no reachable DUT') certificate_authority_manager.NewCertificateAuthority() - commission_device = True if len(certificate_authority_manager.activeCaList[0].adminList) == 0: certificate_authority_manager.activeCaList[0].NewFabricAdmin( @@ -58,9 +53,13 @@ async def start(self): ca_list = certificate_authority_manager.activeCaList dev_ctrl = ca_list[0].adminList[0].NewController() - if commission_device: - # These magic values are the defaults expected for YAML tests - dev_ctrl.CommissionWithCode('MT:-24J0AFN00KA0648G00', 0x12344321) + + # Unfortunately there is no convenient way to confirm if the provided node_id has + # already been commissioned. At this point we blindly trust that we should commission + # device with the provided node id. + if self._node_id_to_commission is not None: + # Magic value is the defaults expected for YAML tests. + dev_ctrl.CommissionWithCode('MT:-24J0AFN00KA0648G00', self._node_id_to_commission) self._chip_stack = chip_stack self._certificate_authority_manager = certificate_authority_manager