Skip to content

Commit

Permalink
[matter_yamltests] Update try_update_yaml_node_id_test_runner_state t…
Browse files Browse the repository at this point in the history
…o take into account WaitForCommissionee and cases where the node id should not be updated (#24656)
  • Loading branch information
vivien-apple authored and pull[bot] committed Jan 26, 2024
1 parent e8eb005 commit 5410809
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions scripts/py_matter_yamltests/matter_yamltests/fixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,31 @@ def try_add_yaml_support_for_scientific_notation_without_dot(loader):
# accessory. But this state may not exist in the runner (as in it prevent to have multiple node ids
# associated to a fabric...) so the 'nodeId' needs to be added back manually.
def try_update_yaml_node_id_test_runner_state(tests, config):
default_identity = 'alpha'
identities = {
'alpha': None if 'nodeId' not in config else config['nodeId']}
default_identity: None if 'nodeId' not in config else config['nodeId']}

for test in tests:
if not test.is_enabled:
continue

identity = test.identity

if test.cluster == 'CommissionerCommands':
if test.command == 'PairWithCode':
if test.cluster == 'CommissionerCommands' or test.cluster == 'DelayCommands':
if test.command == 'PairWithCode' or test.command == 'WaitForCommissionee':
if test.response_with_placeholders:
# It the test expects an error, we should not update the
# nodeId of the identity.
error = test.response_with_placeholders.get('error')
if error:
continue

for item in test.arguments_with_placeholders['values']:
if item['name'] == 'nodeId':
identities[identity] = item['value']
elif identity is not None and identity in identities:
node_id = identities[identity]
test.node_id = node_id
elif identity is None and default_identity in identities:
node_id = identities[default_identity]
test.node_id = node_id
2 changes: 1 addition & 1 deletion src/controller/python/chip/yaml/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ class WaitForCommissioneeAction(BaseAction):

def __init__(self, test_step):
super().__init__(test_step)
self._node_id = test_step.node_id
self._expire_existing_session = False
# This is the default when no timeout is provided.
_DEFAULT_TIMEOUT_MS = 10 * 1000
Expand All @@ -254,6 +253,7 @@ def __init__(self, test_step):
args = test_step.arguments['values']
request_data_as_dict = Converter.convert_list_of_name_value_pair_to_dict(args)

self._node_id = request_data_as_dict['nodeId']
self._expire_existing_session = request_data_as_dict.get('expireExistingSession', False)
if 'timeout' in request_data_as_dict:
# Timeout is provided in seconds we need to conver to milliseconds.
Expand Down

0 comments on commit 5410809

Please sign in to comment.