Skip to content

Commit db09a64

Browse files
Add test steps to IDM_1_4 to validate multiple InvokeResponseMessages (#31979)
* Add test steps to IDM_1_4 to validate multiple InvokeResponseMessages * Restyled by autopep8 * Address PR comments and CI issues * rename variable * Fix CI * Fix incorrect merge attempt * Fix CI --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 2bfb41e commit db09a64

File tree

2 files changed

+74
-14
lines changed

2 files changed

+74
-14
lines changed

.github/workflows/tests.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ jobs:
500500
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_FAN_3_5.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
501501
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-lit-icd-ipv6only-no-ble-no-wifi-tsan-clang-test/lit-icd-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_ICDM_2_1.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
502502
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_IDM_1_2.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
503-
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_IDM_1_4.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
503+
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json --enable-key 000102030405060708090a0b0c0d0e0f" --script "src/python_testing/TC_IDM_1_4.py" --script-args "--hex-arg PIXIT.DGGEN.TEST_EVENT_TRIGGER_KEY:000102030405060708090a0b0c0d0e0f --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
504504
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_IDM_4_2.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
505505
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_RR_1_1.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
506506
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_RVCCLEANM_1_2.py" --script-args "--int-arg PIXIT_ENDPOINT:1 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'

src/python_testing/TC_IDM_1_4.py

+73-13
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,16 @@
1616
#
1717

1818
import logging
19-
from dataclasses import dataclass
2019

2120
import chip.clusters as Clusters
22-
from chip import ChipUtility
2321
from chip.exceptions import ChipStackError
2422
from chip.interaction_model import InteractionModelError, Status
2523
from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main, type_matches
2624
from mobly import asserts
2725

28-
29-
@dataclass
30-
class FakeInvalidBasicInformationCommand(Clusters.BasicInformation.Commands.MfgSpecificPing):
31-
@ChipUtility.classproperty
32-
def must_use_timed_invoke(cls) -> bool:
33-
return False
26+
# If DUT supports `MaxPathsPerInvoke > 1`, additional command line argument
27+
# run with
28+
# --hex-arg PIXIT.DGGEN.TEST_EVENT_TRIGGER_KEY:<key>
3429

3530

3631
class TC_IDM_1_4(MatterBaseTest):
@@ -44,7 +39,9 @@ def steps_TC_IDM_1_4(self) -> list[TestStep]:
4439
TestStep(6, "Verify DUT responds to InvokeRequestMessage containing one valid paths, and one InvokeRequest to unsupported endpoint"),
4540
TestStep(7, "Verify DUT responds to InvokeRequestMessage containing two valid paths. One of which requires timed invoke, and TimedRequest in InvokeResponseMessage set to true, but never sending preceding Timed Invoke Action"),
4641
TestStep(8, "Verify DUT responds to InvokeRequestMessage containing two valid paths. One of which requires timed invoke, and TimedRequest in InvokeResponseMessage set to true"),
47-
TestStep(9, "Verify DUT capable of responding to request with multiple InvokeResponseMessages")]
42+
TestStep(9, "Verify DUT supports extended Data Model Testing feature in General Diagnostics Cluster"),
43+
TestStep(10, "Verify DUT has TestEventTriggersEnabled attribute set to true in General Diagnostics Cluster"),
44+
TestStep(11, "Verify DUT capable of responding to request with multiple InvokeResponseMessages")]
4845
return steps
4946

5047
@async_test_body
@@ -118,9 +115,14 @@ async def test_TC_IDM_1_4(self):
118115
if max_paths_per_invoke == 1:
119116
self.skip_all_remaining_steps(3)
120117
else:
121-
await self.steps_3_to_9(False)
118+
asserts.assert_true('PIXIT.DGGEN.TEST_EVENT_TRIGGER_KEY' in self.matter_test_config.global_test_params,
119+
"PIXIT.DGGEN.TEST_EVENT_TRIGGER_KEY must be included on the command line in "
120+
"the --hex-arg flag as PIXIT.DGGEN.TEST_EVENT_TRIGGER_KEY:<key>, "
121+
"e.g. --hex-arg PIXIT.DGGEN.TEST_EVENT_TRIGGER_KEY:000102030405060708090a0b0c0d0e0f")
122+
123+
await self.remaining_batch_commands_test_steps(False)
122124

123-
async def steps_3_to_9(self, dummy_value):
125+
async def remaining_batch_commands_test_steps(self, dummy_value):
124126
dev_ctrl = self.default_controller
125127
dut_node_id = self.dut_node_id
126128

@@ -247,8 +249,66 @@ async def steps_3_to_9(self, dummy_value):
247249
except InteractionModelError:
248250
asserts.fail("DUT failed with non-path specific error when path specific error was expected")
249251

250-
# Skipping test until https://github.com/project-chip/connectedhomeip/issues/31434 resolved
251-
self.skip_step(9)
252+
self.step(9)
253+
try:
254+
feature_map = await self.read_single_attribute(
255+
dev_ctrl,
256+
dut_node_id,
257+
endpoint=0,
258+
attribute=Clusters.GeneralDiagnostics.Attributes.FeatureMap
259+
)
260+
except InteractionModelError:
261+
asserts.fail("DUT failed to respond reading FeatureMap attribute")
262+
has_data_model_test_feature = (feature_map & Clusters.GeneralDiagnostics.Bitmaps.Feature.kDataModelTest) != 0
263+
asserts.assert_true(has_data_model_test_feature, "DataModelTest Feature is not supported by DUT")
264+
265+
self.step(10)
266+
try:
267+
test_event_triggers_enabled = await self.read_single_attribute(
268+
dev_ctrl,
269+
dut_node_id,
270+
endpoint=0,
271+
attribute=Clusters.GeneralDiagnostics.Attributes.TestEventTriggersEnabled
272+
)
273+
except InteractionModelError:
274+
asserts.fail("DUT failed to respond reading TestEventTriggersEnabled attribute")
275+
asserts.assert_true(test_event_triggers_enabled, "Test Event Triggers must be enabled on DUT")
276+
277+
self.step(11)
278+
enable_key = self.matter_test_config.global_test_params['PIXIT.DGGEN.TEST_EVENT_TRIGGER_KEY']
279+
endpoint = 0
280+
command = Clusters.GeneralDiagnostics.Commands.PayloadTestRequest(
281+
enableKey=enable_key,
282+
value=ord('A'),
283+
count=800
284+
)
285+
invoke_request_1 = Clusters.Command.InvokeRequestInfo(endpoint, command)
286+
287+
command = Clusters.OperationalCredentials.Commands.CertificateChainRequest(
288+
Clusters.OperationalCredentials.Enums.CertificateChainTypeEnum.kDACCertificate)
289+
invoke_request_2 = Clusters.Command.InvokeRequestInfo(endpoint, command)
290+
291+
try:
292+
test_only_result = await dev_ctrl.TestOnlySendBatchCommands(dut_node_id, [invoke_request_1, invoke_request_2])
293+
except InteractionModelError:
294+
asserts.fail("DUT failed to respond to batch commands, where response is expected to be too large to fit in a single ResponseMessage")
295+
296+
responses = test_only_result.Responses
297+
# This check is validating the number of InvokeResponses we got
298+
asserts.assert_equal(len(responses), 2, "Unexpected number of InvokeResponses sent back from DUT")
299+
asserts.assert_true(type_matches(
300+
responses[0], Clusters.GeneralDiagnostics.Commands.PayloadTestResponse), "Unexpected return type for first InvokeRequest")
301+
asserts.assert_true(type_matches(
302+
responses[1], Clusters.OperationalCredentials.Commands.CertificateChainResponse), "Unexpected return type for second InvokeRequest")
303+
logging.info("DUT successfully responded to a InvokeRequest action with two valid commands")
304+
305+
asserts.assert_equal(responses[0].payload, b'A' * 800, "Expect response to match for count == 800")
306+
# If this assert below fails then some assumptions we were relying on are now no longer true.
307+
# This check is validating the number of InvokeResponsesMessages we got. This is different then the earlier
308+
# `len(responses)` check as you can have multiple InvokeResponses in a single message. But this test step
309+
# is explicitly making sure that we recieved multiple ResponseMessages.
310+
asserts.assert_greater_equal(test_only_result.ResponseMessageCount, 2,
311+
"DUT was expected to send multiple InvokeResponseMessages")
252312

253313

254314
if __name__ == "__main__":

0 commit comments

Comments
 (0)