From eb00219dc92f24ba9b4524d8d4b04e3b122251bd Mon Sep 17 00:00:00 2001 From: Jake Ororke Date: Mon, 12 Aug 2024 10:21:10 -0700 Subject: [PATCH 01/14] Updated TC_ICDM_2_1 test module: - Removed automatable PICS from TC_ICDM_2_1 test module --- src/python_testing/TC_ICDM_2_1.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/python_testing/TC_ICDM_2_1.py b/src/python_testing/TC_ICDM_2_1.py index 63b27c64d6d8fa..bc5a7853ac2bc6 100644 --- a/src/python_testing/TC_ICDM_2_1.py +++ b/src/python_testing/TC_ICDM_2_1.py @@ -130,6 +130,8 @@ async def test_TC_ICDM_2_1(self): cluster = Clusters.Objects.IcdManagement attributes = cluster.Attributes + attribute_list = await self._read_icdm_attribute_expect_success(attribute=attributes.AttributeList) + # Commissioning self.step(1) # Read feature map @@ -138,8 +140,7 @@ async def test_TC_ICDM_2_1(self): # Validate ActiveModeThreshold self.step(2) - if self.check_pics("ICDM.S.A0002"): - + if attributes.ActiveModeThreshold.attribute_id in attribute_list: activeModeThreshold = await self._read_icdm_attribute_expect_success( attributes.ActiveModeThreshold) # Verify ActiveModeThreshold is not bigger than uint16 @@ -156,7 +157,7 @@ async def test_TC_ICDM_2_1(self): # Validate ActiveModeDuration self.step(3) - if self.check_pics("ICDM.S.A0001"): + if attributes.ActiveModeDuration.attribute_id in attribute_list: activeModeDuration = await self._read_icdm_attribute_expect_success( attributes.ActiveModeDuration) # Verify ActiveModeDuration is not bigger than uint32 @@ -168,7 +169,7 @@ async def test_TC_ICDM_2_1(self): # Validate IdleModeDuration self.step(4) - if self.check_pics("ICDM.S.A0000"): + if attributes.IdleModeDuration.attribute_id in attribute_list: idleModeDuration = await self._read_icdm_attribute_expect_success( attributes.IdleModeDuration) # Verify IdleModeDuration is not bigger than uint32 @@ -184,7 +185,7 @@ async def test_TC_ICDM_2_1(self): # Validate ClientsSupportedPerFabric self.step(5) - if self.pics_guard(self.check_pics("ICDM.S.A0005")): + if attributes.ClientsSupportedPerFabric.attribute_id in attribute_list: clientsSupportedPerFabric = await self._read_icdm_attribute_expect_success( attributes.ClientsSupportedPerFabric) @@ -197,7 +198,7 @@ async def test_TC_ICDM_2_1(self): # Validate RegisteredClients self.step(6) - if self.pics_guard(self.check_pics("ICDM.S.A0003")): + if attributes.RegisteredClients.attribute_id in attribute_list: registeredClients = await self._read_icdm_attribute_expect_success( attributes.RegisteredClients) @@ -206,8 +207,7 @@ async def test_TC_ICDM_2_1(self): # Validate ICDCounter self.step(7) - if self.pics_guard(self.check_pics("ICDM.S.A0004")): - + if attributes.ICDCounter.attribute_id in attribute_list: icdCounter = await self._read_icdm_attribute_expect_success( attributes.ICDCounter) # Verify ICDCounter is not bigger than uint32 @@ -216,7 +216,7 @@ async def test_TC_ICDM_2_1(self): # Validate UserActiveModeTriggerHint self.step(8) - if self.pics_guard(self.check_pics("ICDM.S.A0006")): + if attributes.UserActiveModeTriggerHint.attribute_id in attribute_list: userActiveModeTriggerHint = await self._read_icdm_attribute_expect_success( attributes.UserActiveModeTriggerHint) @@ -233,7 +233,7 @@ async def test_TC_ICDM_2_1(self): # Valdate UserActiveModeTriggerInstruction self.step(9) - if self.check_pics("ICDM.S.A0007"): + if attributes.UserActiveModeTriggerInstruction.attribute_id in attribute_list: userActiveModeTriggerInstruction = await self._read_icdm_attribute_expect_success( attributes.UserActiveModeTriggerInstruction) @@ -265,7 +265,7 @@ async def test_TC_ICDM_2_1(self): # Verify OperatingMode self.step(10) - if self.pics_guard(self.check_pics("ICDM.S.A0008")): + if attributes.OperatingMode.attribute_id in attribute_list: operatingMode = await self._read_icdm_attribute_expect_success( attributes.OperatingMode) @@ -274,8 +274,9 @@ async def test_TC_ICDM_2_1(self): asserts.assert_less( operatingMode, modes.kUnknownEnumValue, "OperatingMode can only have 0 and 1 as valid values") + self.step(11) - if self.pics_guard(self.check_pics("ICDM.S.A0009")): + if attributes.MaximumCheckInBackOff.attribute_id in attribute_list: maximumCheckInBackOff = await self._read_icdm_attribute_expect_success(attributes.MaximumCheckInBackOff) asserts.assert_true(self.is_valid_uint32_value(maximumCheckInBackOff), From f74cdc7c3a9b2b072f7d2f5704b2c91ee70d74bd Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Mon, 12 Aug 2024 17:28:26 +0000 Subject: [PATCH 02/14] Restyled by autopep8 --- src/python_testing/TC_ICDM_2_1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/TC_ICDM_2_1.py b/src/python_testing/TC_ICDM_2_1.py index bc5a7853ac2bc6..e9e1d58b5d17a6 100644 --- a/src/python_testing/TC_ICDM_2_1.py +++ b/src/python_testing/TC_ICDM_2_1.py @@ -131,7 +131,7 @@ async def test_TC_ICDM_2_1(self): attributes = cluster.Attributes attribute_list = await self._read_icdm_attribute_expect_success(attribute=attributes.AttributeList) - + # Commissioning self.step(1) # Read feature map From dd77706ddd674ff07c9440dc1d8078e497316e2b Mon Sep 17 00:00:00 2001 From: Jake Ororke Date: Mon, 12 Aug 2024 15:27:19 -0700 Subject: [PATCH 03/14] updated TC_ICDM_2_1: Attempting to resolve issue in CI/CD pipeline --- src/python_testing/TC_ICDM_2_1.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/python_testing/TC_ICDM_2_1.py b/src/python_testing/TC_ICDM_2_1.py index e9e1d58b5d17a6..70b89416110013 100644 --- a/src/python_testing/TC_ICDM_2_1.py +++ b/src/python_testing/TC_ICDM_2_1.py @@ -130,8 +130,8 @@ async def test_TC_ICDM_2_1(self): cluster = Clusters.Objects.IcdManagement attributes = cluster.Attributes - attribute_list = await self._read_icdm_attribute_expect_success(attribute=attributes.AttributeList) - + attribute_list = await self.read_single_attribute_check_success(endpoint=kRootEndpointId, cluster=cluster, attribute=attributes.AttributeList) + # Commissioning self.step(1) # Read feature map From 355e460b66fbd318b333685556defd8b441d795a Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Mon, 12 Aug 2024 22:28:19 +0000 Subject: [PATCH 04/14] Restyled by autopep8 --- src/python_testing/TC_ICDM_2_1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/TC_ICDM_2_1.py b/src/python_testing/TC_ICDM_2_1.py index 70b89416110013..7b88dd7e536b02 100644 --- a/src/python_testing/TC_ICDM_2_1.py +++ b/src/python_testing/TC_ICDM_2_1.py @@ -131,7 +131,7 @@ async def test_TC_ICDM_2_1(self): attributes = cluster.Attributes attribute_list = await self.read_single_attribute_check_success(endpoint=kRootEndpointId, cluster=cluster, attribute=attributes.AttributeList) - + # Commissioning self.step(1) # Read feature map From 6f9e1e5c496061bcd9f2753b6453d696370d4386 Mon Sep 17 00:00:00 2001 From: Jake Ororke Date: Mon, 12 Aug 2024 17:16:14 -0700 Subject: [PATCH 05/14] Updated TC_ICDM_2_1 test module: - Enabling verbose output in CI/CD pipeline to get more context on current issue --- src/python_testing/TC_ICDM_2_1.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/python_testing/TC_ICDM_2_1.py b/src/python_testing/TC_ICDM_2_1.py index 7b88dd7e536b02..9cc7d306e9c131 100644 --- a/src/python_testing/TC_ICDM_2_1.py +++ b/src/python_testing/TC_ICDM_2_1.py @@ -22,7 +22,7 @@ # test-runner-runs: run1 # test-runner-run/run1/app: ${LIT_ICD_APP} # test-runner-run/run1/factoryreset: True -# test-runner-run/run1/quiet: True +# test-runner-run/run1/quiet: False # test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json # test-runner-run/run1/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:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto # === END CI TEST ARGUMENTS === @@ -130,7 +130,10 @@ async def test_TC_ICDM_2_1(self): cluster = Clusters.Objects.IcdManagement attributes = cluster.Attributes - attribute_list = await self.read_single_attribute_check_success(endpoint=kRootEndpointId, cluster=cluster, attribute=attributes.AttributeList) + self.print_step("Attributes cluster", cluster.Attributes.AttributeList.__dict__) + + attribute_list = await self._read_icdm_attribute_expect_success(attribute=attributes.AttributeList) + self.print_step("attribute list", attribute_list) # Commissioning self.step(1) From 076cbe61111d2bc9835df668d9ab691338bf198a Mon Sep 17 00:00:00 2001 From: Jake Ororke Date: Tue, 13 Aug 2024 10:17:44 -0700 Subject: [PATCH 06/14] Updating TC_ICDM_2_1 and test_TC_ICDM_2_1 test modules: - Removed additional print statements from TC_ICDM_2_1 due to no longer needed - Added AttributeList to list of attrs in test_TC_ICDM_2_1 to see if we can get the CI/CD to pass. --- src/python_testing/TC_ICDM_2_1.py | 7 ++----- src/python_testing/test_testing/test_TC_ICDM_2_1.py | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/python_testing/TC_ICDM_2_1.py b/src/python_testing/TC_ICDM_2_1.py index 9cc7d306e9c131..bc5a7853ac2bc6 100644 --- a/src/python_testing/TC_ICDM_2_1.py +++ b/src/python_testing/TC_ICDM_2_1.py @@ -22,7 +22,7 @@ # test-runner-runs: run1 # test-runner-run/run1/app: ${LIT_ICD_APP} # test-runner-run/run1/factoryreset: True -# test-runner-run/run1/quiet: False +# test-runner-run/run1/quiet: True # test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json # test-runner-run/run1/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:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto # === END CI TEST ARGUMENTS === @@ -130,11 +130,8 @@ async def test_TC_ICDM_2_1(self): cluster = Clusters.Objects.IcdManagement attributes = cluster.Attributes - self.print_step("Attributes cluster", cluster.Attributes.AttributeList.__dict__) - attribute_list = await self._read_icdm_attribute_expect_success(attribute=attributes.AttributeList) - self.print_step("attribute list", attribute_list) - + # Commissioning self.step(1) # Read feature map diff --git a/src/python_testing/test_testing/test_TC_ICDM_2_1.py b/src/python_testing/test_testing/test_TC_ICDM_2_1.py index a337b91ccef41d..d1a6def602992a 100755 --- a/src/python_testing/test_testing/test_TC_ICDM_2_1.py +++ b/src/python_testing/test_testing/test_TC_ICDM_2_1.py @@ -222,7 +222,7 @@ def test_spec_to_attribute_cache(test_icdm: ICDMData) -> Attribute.AsyncReadTran resp.attributes = {0: {c: {attr.FeatureMap: test_icdm.FeatureMap, attr.IdleModeDuration: test_icdm.IdleModeDuration, attr.ActiveModeDuration: test_icdm.ActiveModeDuration, attr.ActiveModeThreshold: test_icdm.ActiveModeThreshold, attr.RegisteredClients: test_icdm.RegisteredClients, attr.ICDCounter: test_icdm.ICDCounter, attr.ClientsSupportedPerFabric: test_icdm.ClientsSupportedPerFabric, attr.UserActiveModeTriggerHint: test_icdm.UserActiveModeTriggerHint, - attr.UserActiveModeTriggerInstruction: test_icdm.UserActiveModeTriggerInstruction, attr.OperatingMode: test_icdm.OperatingMode, attr.MaximumCheckInBackOff: test_icdm.MaximumCheckInBackOff}}} + attr.UserActiveModeTriggerInstruction: test_icdm.UserActiveModeTriggerInstruction, attr.OperatingMode: test_icdm.OperatingMode, attr.MaximumCheckInBackOff: test_icdm.MaximumCheckInBackOff, attr.AttributeList: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 65528, 65529, 65531, 65532, 65533]}}} return resp From 267afbea535b14584dca62a06aa2ced85d409ec7 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 13 Aug 2024 17:20:18 +0000 Subject: [PATCH 07/14] Restyled by autopep8 --- src/python_testing/TC_ICDM_2_1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/TC_ICDM_2_1.py b/src/python_testing/TC_ICDM_2_1.py index bc5a7853ac2bc6..e9e1d58b5d17a6 100644 --- a/src/python_testing/TC_ICDM_2_1.py +++ b/src/python_testing/TC_ICDM_2_1.py @@ -131,7 +131,7 @@ async def test_TC_ICDM_2_1(self): attributes = cluster.Attributes attribute_list = await self._read_icdm_attribute_expect_success(attribute=attributes.AttributeList) - + # Commissioning self.step(1) # Read feature map From d7747ed0d2b45bc023b4a0a54486ee53e203da94 Mon Sep 17 00:00:00 2001 From: Jake Ororke Date: Wed, 18 Dec 2024 18:54:46 -0800 Subject: [PATCH 08/14] Update TC_ICDM_2_1 test module: - Updating to using attribute_guard() --- src/python_testing/TC_ICDM_2_1.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/python_testing/TC_ICDM_2_1.py b/src/python_testing/TC_ICDM_2_1.py index 78c210f60045c1..47143c8ccd1a0c 100644 --- a/src/python_testing/TC_ICDM_2_1.py +++ b/src/python_testing/TC_ICDM_2_1.py @@ -135,12 +135,11 @@ def pics_TC_ICDM_2_1(self) -> list[str]: @async_test_body async def test_TC_ICDM_2_1(self): + self.endpoint = self.get_endpoint() cluster = Clusters.Objects.IcdManagement attributes = cluster.Attributes - attribute_list = await self._read_icdm_attribute_expect_success(attribute=attributes.AttributeList) - # Commissioning self.step("1a") # Read feature map @@ -150,7 +149,7 @@ async def test_TC_ICDM_2_1(self): # Validate ActiveModeThreshold self.step(2) - if attributes.ActiveModeThreshold.attribute_id in attribute_list: + if await self.attribute_guard(endpoint=self.endpoint, attribute=attributes.ActiveModeThreshold): activeModeThreshold = await self._read_icdm_attribute_expect_success( attributes.ActiveModeThreshold) # Verify ActiveModeThreshold is not bigger than uint16 @@ -167,7 +166,7 @@ async def test_TC_ICDM_2_1(self): # Validate ActiveModeDuration self.step(3) - if attributes.ActiveModeDuration.attribute_id in attribute_list: + if await self.attribute_guard(endpoint=self.endpoint, attribute=attributes.ActiveModeDuration): activeModeDuration = await self._read_icdm_attribute_expect_success( attributes.ActiveModeDuration) # Verify ActiveModeDuration is not bigger than uint32 @@ -179,7 +178,7 @@ async def test_TC_ICDM_2_1(self): # Validate IdleModeDuration self.step(4) - if attributes.IdleModeDuration.attribute_id in attribute_list: + if await self.attribute_guard(endpoint=self.endpoint, attribute=attributes.IdleModeDuration): idleModeDuration = await self._read_icdm_attribute_expect_success( attributes.IdleModeDuration) # Verify IdleModeDuration is not bigger than uint32 @@ -195,7 +194,7 @@ async def test_TC_ICDM_2_1(self): # Validate ClientsSupportedPerFabric self.step(5) - if attributes.ClientsSupportedPerFabric.attribute_id in attribute_list: + if await self.attribute_guard(endpoint=self.endpoint, attribute=attributes.ClientsSupportedPerFabric): clientsSupportedPerFabric = await self._read_icdm_attribute_expect_success( attributes.ClientsSupportedPerFabric) @@ -208,7 +207,7 @@ async def test_TC_ICDM_2_1(self): # Validate RegisteredClients self.step(6) - if attributes.RegisteredClients.attribute_id in attribute_list: + if await self.attribute_guard(endpoint=self.endpoint, attribute=attributes.RegisteredClients): registeredClients = await self._read_icdm_attribute_expect_success( attributes.RegisteredClients) @@ -217,7 +216,7 @@ async def test_TC_ICDM_2_1(self): # Validate ICDCounter self.step(7) - if attributes.ICDCounter.attribute_id in attribute_list: + if await self.attribute_guard(endpoint=self.endpoint, attribute=attributes.ICDCounter): icdCounter = await self._read_icdm_attribute_expect_success( attributes.ICDCounter) # Verify ICDCounter is not bigger than uint32 @@ -226,7 +225,7 @@ async def test_TC_ICDM_2_1(self): # Validate UserActiveModeTriggerHint self.step(8) - if attributes.UserActiveModeTriggerHint.attribute_id in attribute_list: + if await self.attribute_guard(endpoint=self.endpoint, attribute=attributes.UserActiveModeTriggerHint): userActiveModeTriggerHint = await self._read_icdm_attribute_expect_success( attributes.UserActiveModeTriggerHint) @@ -243,7 +242,7 @@ async def test_TC_ICDM_2_1(self): # Valdate UserActiveModeTriggerInstruction self.step(9) - if attributes.UserActiveModeTriggerInstruction.attribute_id in attribute_list: + if await self.attribute_guard(endpoint=self.endpoint, attribute=attributes.UserActiveModeTriggerInstruction): userActiveModeTriggerInstruction = await self._read_icdm_attribute_expect_success( attributes.UserActiveModeTriggerInstruction) @@ -275,7 +274,7 @@ async def test_TC_ICDM_2_1(self): # Verify OperatingMode self.step(10) - if attributes.OperatingMode.attribute_id in attribute_list: + if await self.attribute_guard(endpoint=self.endpoint, attribute=attributes.OperatingMode): operatingMode = await self._read_icdm_attribute_expect_success( attributes.OperatingMode) @@ -286,7 +285,7 @@ async def test_TC_ICDM_2_1(self): operatingMode, modes.kUnknownEnumValue, "OperatingMode can only have 0 and 1 as valid values") self.step(11) - if attributes.MaximumCheckInBackOff.attribute_id in attribute_list: + if await self.attribute_guard(endpoint=self.endpoint, attribute=attributes.MaximumCheckInBackOff): maximumCheckInBackOff = await self._read_icdm_attribute_expect_success(attributes.MaximumCheckInBackOff) asserts.assert_true(self.is_valid_uint32_value(maximumCheckInBackOff), From 0d6274727819a94687271ddc653b22af74e39f44 Mon Sep 17 00:00:00 2001 From: Jake Ororke Date: Mon, 20 Jan 2025 11:39:08 -0800 Subject: [PATCH 09/14] Updating TC_ICDM_2_1 test module: - Updating to remove unneeded if statements for checking mandatory attributes --- src/python_testing/TC_ICDM_2_1.py | 58 ++++++++++++------------------- 1 file changed, 23 insertions(+), 35 deletions(-) diff --git a/src/python_testing/TC_ICDM_2_1.py b/src/python_testing/TC_ICDM_2_1.py index 47143c8ccd1a0c..2f4693740cf78d 100644 --- a/src/python_testing/TC_ICDM_2_1.py +++ b/src/python_testing/TC_ICDM_2_1.py @@ -35,6 +35,7 @@ # quiet: true # === END CI TEST ARGUMENTS === +import asyncio import logging import re @@ -149,48 +150,35 @@ async def test_TC_ICDM_2_1(self): # Validate ActiveModeThreshold self.step(2) - if await self.attribute_guard(endpoint=self.endpoint, attribute=attributes.ActiveModeThreshold): - activeModeThreshold = await self._read_icdm_attribute_expect_success( - attributes.ActiveModeThreshold) - # Verify ActiveModeThreshold is not bigger than uint16 - asserts.assert_true(self.is_valid_uint16_value(activeModeThreshold), - "ActiveModeThreshold attribute does not fit in a uint16.") + activeModeThreshold = await self._read_icdm_attribute_expect_success( + attributes.ActiveModeThreshold) + # Verify ActiveModeThreshold is not bigger than uint16 + asserts.assert_true(self.is_valid_uint16_value(activeModeThreshold), + "ActiveModeThreshold attribute does not fit in a uint16.") - if featureMap > 0 and features.kLongIdleTimeSupport in features(featureMap): - asserts.assert_greater_equal( - activeModeThreshold, 5000, "Minimum ActiveModeThreshold is 5s for a LIT ICD.") - - else: - asserts.assert_true( - False, "ActiveModeThreshold is a mandatory attribute and must be present in the PICS file") + if featureMap > 0 and features.kLongIdleTimeSupport in features(featureMap): + asserts.assert_greater_equal( + activeModeThreshold, 5000, "Minimum ActiveModeThreshold is 5s for a LIT ICD.") # Validate ActiveModeDuration self.step(3) - if await self.attribute_guard(endpoint=self.endpoint, attribute=attributes.ActiveModeDuration): - activeModeDuration = await self._read_icdm_attribute_expect_success( - attributes.ActiveModeDuration) - # Verify ActiveModeDuration is not bigger than uint32 - asserts.assert_true(self.is_valid_uint32_value(activeModeDuration), - "ActiveModeDuration attribute does not fit in a uint32") - else: - asserts.assert_true( - False, "ActiveModeDuration is a mandatory attribute and must be present in the PICS file") + activeModeDuration = await self._read_icdm_attribute_expect_success( + attributes.ActiveModeDuration) + # Verify ActiveModeDuration is not bigger than uint32 + asserts.assert_true(self.is_valid_uint32_value(activeModeDuration), + "ActiveModeDuration attribute does not fit in a uint32") # Validate IdleModeDuration self.step(4) - if await self.attribute_guard(endpoint=self.endpoint, attribute=attributes.IdleModeDuration): - idleModeDuration = await self._read_icdm_attribute_expect_success( - attributes.IdleModeDuration) - # Verify IdleModeDuration is not bigger than uint32 - asserts.assert_greater_equal( - idleModeDuration, 1, "IdleModeDuration attribute is smaller than minimum value (1).") - asserts.assert_less_equal( - idleModeDuration, 64800, "IdleModeDuration attribute is greater than maximum value (64800).") - asserts.assert_greater_equal(idleModeDuration * 1000, activeModeDuration, - "ActiveModeDuration attribute is greater than the IdleModeDuration attrbiute.") - else: - asserts.assert_true( - False, "IdleModeDuration is a mandatory attribute and must be present in the PICS file") + idleModeDuration = await self._read_icdm_attribute_expect_success( + attributes.IdleModeDuration) + # Verify IdleModeDuration is not bigger than uint32 + asserts.assert_greater_equal( + idleModeDuration, 1, "IdleModeDuration attribute is smaller than minimum value (1).") + asserts.assert_less_equal( + idleModeDuration, 64800, "IdleModeDuration attribute is greater than maximum value (64800).") + asserts.assert_greater_equal(idleModeDuration * 1000, activeModeDuration, + "ActiveModeDuration attribute is greater than the IdleModeDuration attrbiute.") # Validate ClientsSupportedPerFabric self.step(5) From fcb86b7f5eeb5c88379a6e9a40e8bb912041e338 Mon Sep 17 00:00:00 2001 From: Jake Ororke Date: Wed, 22 Jan 2025 07:23:39 -0800 Subject: [PATCH 10/14] Updating TC_ICDM_2_1 and matter_testing support module: - Added new function "async_function_runner" to matter_testing support module, allowing async functions to be run synchronously even in the event that another event loop is already running - Updated TC_ICDM_2_1 to using async_function_runner for calling functions such as attribute_guard when not wanted for those to be awaited. --- src/python_testing/TC_ICDM_2_1.py | 17 +++++++++-------- .../chip/testing/matter_testing.py | 13 +++++++++++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/python_testing/TC_ICDM_2_1.py b/src/python_testing/TC_ICDM_2_1.py index 2f4693740cf78d..6a94ba3db26a43 100644 --- a/src/python_testing/TC_ICDM_2_1.py +++ b/src/python_testing/TC_ICDM_2_1.py @@ -40,7 +40,7 @@ import re import chip.clusters as Clusters -from chip.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from chip.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main, async_function_runner from mobly import asserts logger = logging.getLogger(__name__) @@ -137,6 +137,7 @@ def pics_TC_ICDM_2_1(self) -> list[str]: @async_test_body async def test_TC_ICDM_2_1(self): self.endpoint = self.get_endpoint() + self.timeout = self.matter_test_config.timeout if self.matter_test_config.timeout is not None else self.default_timeout cluster = Clusters.Objects.IcdManagement attributes = cluster.Attributes @@ -182,7 +183,7 @@ async def test_TC_ICDM_2_1(self): # Validate ClientsSupportedPerFabric self.step(5) - if await self.attribute_guard(endpoint=self.endpoint, attribute=attributes.ClientsSupportedPerFabric): + if async_function_runner(self.attribute_guard(endpoint=self.endpoint, attribute=attributes.ClientsSupportedPerFabric), timeout=self.timeout): clientsSupportedPerFabric = await self._read_icdm_attribute_expect_success( attributes.ClientsSupportedPerFabric) @@ -195,7 +196,7 @@ async def test_TC_ICDM_2_1(self): # Validate RegisteredClients self.step(6) - if await self.attribute_guard(endpoint=self.endpoint, attribute=attributes.RegisteredClients): + if async_function_runner(self.attribute_guard(endpoint=self.endpoint, attribute=attributes.RegisteredClients), timeout= self.timeout): registeredClients = await self._read_icdm_attribute_expect_success( attributes.RegisteredClients) @@ -204,7 +205,7 @@ async def test_TC_ICDM_2_1(self): # Validate ICDCounter self.step(7) - if await self.attribute_guard(endpoint=self.endpoint, attribute=attributes.ICDCounter): + if async_function_runner(self.attribute_guard(endpoint=self.endpoint, attribute=attributes.ICDCounter), timeout= self.timeout): icdCounter = await self._read_icdm_attribute_expect_success( attributes.ICDCounter) # Verify ICDCounter is not bigger than uint32 @@ -213,7 +214,7 @@ async def test_TC_ICDM_2_1(self): # Validate UserActiveModeTriggerHint self.step(8) - if await self.attribute_guard(endpoint=self.endpoint, attribute=attributes.UserActiveModeTriggerHint): + if async_function_runner(self.attribute_guard(endpoint=self.endpoint, attribute=attributes.UserActiveModeTriggerHint), timeout= self.timeout): userActiveModeTriggerHint = await self._read_icdm_attribute_expect_success( attributes.UserActiveModeTriggerHint) @@ -230,7 +231,7 @@ async def test_TC_ICDM_2_1(self): # Valdate UserActiveModeTriggerInstruction self.step(9) - if await self.attribute_guard(endpoint=self.endpoint, attribute=attributes.UserActiveModeTriggerInstruction): + if async_function_runner(self.attribute_guard(endpoint=self.endpoint, attribute=attributes.UserActiveModeTriggerInstruction), timeout= self.timeout): userActiveModeTriggerInstruction = await self._read_icdm_attribute_expect_success( attributes.UserActiveModeTriggerInstruction) @@ -262,7 +263,7 @@ async def test_TC_ICDM_2_1(self): # Verify OperatingMode self.step(10) - if await self.attribute_guard(endpoint=self.endpoint, attribute=attributes.OperatingMode): + if async_function_runner(self.attribute_guard(endpoint=self.endpoint, attribute=attributes.OperatingMode), timeout= self.timeout): operatingMode = await self._read_icdm_attribute_expect_success( attributes.OperatingMode) @@ -273,7 +274,7 @@ async def test_TC_ICDM_2_1(self): operatingMode, modes.kUnknownEnumValue, "OperatingMode can only have 0 and 1 as valid values") self.step(11) - if await self.attribute_guard(endpoint=self.endpoint, attribute=attributes.MaximumCheckInBackOff): + if async_function_runner(self.attribute_guard(endpoint=self.endpoint, attribute=attributes.MaximumCheckInBackOff), timeout= self.timeout): maximumCheckInBackOff = await self._read_icdm_attribute_expect_success(attributes.MaximumCheckInBackOff) asserts.assert_true(self.is_valid_uint32_value(maximumCheckInBackOff), diff --git a/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py b/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py index 0ad55369e106cb..7b1b690249b438 100644 --- a/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py +++ b/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py @@ -33,6 +33,7 @@ import typing import uuid from binascii import hexlify, unhexlify +from concurrent.futures import ThreadPoolExecutor from dataclasses import asdict as dataclass_asdict from dataclasses import dataclass, field from datetime import datetime, timedelta, timezone @@ -2075,6 +2076,18 @@ def parse_matter_test_args(argv: Optional[List[str]] = None) -> MatterTestConfig return convert_args_to_matter_config(parser.parse_known_args(argv)[0]) +def async_function_runner(function, timeout): + """ + Runs an async function synchronously, even if an event loop is already running. + Follows similar below flow for _async_runner() + """ + async def frapper(): + return await asyncio.wait_for(function, timeout=timeout) + + with ThreadPoolExecutor(max_workers=1) as executor: + future = executor.submit(lambda: asyncio.run(frapper())) + return future.result() + def _async_runner(body, self: MatterBaseTest, *args, **kwargs): timeout = self.matter_test_config.timeout if self.matter_test_config.timeout is not None else self.default_timeout runner_with_timeout = asyncio.wait_for(body(self, *args, **kwargs), timeout=timeout) From 4618ff44ea3f21f3298092f9e7eec6d4cda65576 Mon Sep 17 00:00:00 2001 From: Jake Ororke Date: Wed, 22 Jan 2025 16:46:38 -0800 Subject: [PATCH 11/14] Updating TC_ICDM_2_1 test module: - Resolving linting error --- src/python_testing/TC_ICDM_2_1.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/python_testing/TC_ICDM_2_1.py b/src/python_testing/TC_ICDM_2_1.py index 79ae68e113bec9..d3d698a47f8361 100644 --- a/src/python_testing/TC_ICDM_2_1.py +++ b/src/python_testing/TC_ICDM_2_1.py @@ -35,7 +35,6 @@ # quiet: true # === END CI TEST ARGUMENTS === -import asyncio import logging import re From 0eb6b99bcd86449014c6b4b92f27a124ef01c865 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 23 Jan 2025 17:17:24 +0000 Subject: [PATCH 12/14] Restyled by autopep8 --- src/python_testing/TC_ICDM_2_1.py | 14 +++++++------- .../chip/testing/matter_testing.py | 3 ++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/python_testing/TC_ICDM_2_1.py b/src/python_testing/TC_ICDM_2_1.py index d3d698a47f8361..7305cce32eb5d7 100644 --- a/src/python_testing/TC_ICDM_2_1.py +++ b/src/python_testing/TC_ICDM_2_1.py @@ -178,7 +178,7 @@ async def test_TC_ICDM_2_1(self): asserts.assert_less_equal( idleModeDuration, 64800, "IdleModeDuration attribute is greater than maximum value (64800).") asserts.assert_greater_equal(idleModeDuration * 1000, activeModeDuration, - "ActiveModeDuration attribute is greater than the IdleModeDuration attrbiute.") + "ActiveModeDuration attribute is greater than the IdleModeDuration attrbiute.") # Validate ClientsSupportedPerFabric self.step(5) @@ -195,7 +195,7 @@ async def test_TC_ICDM_2_1(self): # Validate RegisteredClients self.step(6) - if async_function_runner(self.attribute_guard(endpoint=self.endpoint, attribute=attributes.RegisteredClients), timeout= self.timeout): + if async_function_runner(self.attribute_guard(endpoint=self.endpoint, attribute=attributes.RegisteredClients), timeout=self.timeout): registeredClients = await self._read_icdm_attribute_expect_success( attributes.RegisteredClients) @@ -204,7 +204,7 @@ async def test_TC_ICDM_2_1(self): # Validate ICDCounter self.step(7) - if async_function_runner(self.attribute_guard(endpoint=self.endpoint, attribute=attributes.ICDCounter), timeout= self.timeout): + if async_function_runner(self.attribute_guard(endpoint=self.endpoint, attribute=attributes.ICDCounter), timeout=self.timeout): icdCounter = await self._read_icdm_attribute_expect_success( attributes.ICDCounter) # Verify ICDCounter is not bigger than uint32 @@ -213,7 +213,7 @@ async def test_TC_ICDM_2_1(self): # Validate UserActiveModeTriggerHint self.step(8) - if async_function_runner(self.attribute_guard(endpoint=self.endpoint, attribute=attributes.UserActiveModeTriggerHint), timeout= self.timeout): + if async_function_runner(self.attribute_guard(endpoint=self.endpoint, attribute=attributes.UserActiveModeTriggerHint), timeout=self.timeout): userActiveModeTriggerHint = await self._read_icdm_attribute_expect_success( attributes.UserActiveModeTriggerHint) @@ -230,7 +230,7 @@ async def test_TC_ICDM_2_1(self): # Valdate UserActiveModeTriggerInstruction self.step(9) - if async_function_runner(self.attribute_guard(endpoint=self.endpoint, attribute=attributes.UserActiveModeTriggerInstruction), timeout= self.timeout): + if async_function_runner(self.attribute_guard(endpoint=self.endpoint, attribute=attributes.UserActiveModeTriggerInstruction), timeout=self.timeout): userActiveModeTriggerInstruction = await self._read_icdm_attribute_expect_success( attributes.UserActiveModeTriggerInstruction) @@ -262,7 +262,7 @@ async def test_TC_ICDM_2_1(self): # Verify OperatingMode self.step(10) - if async_function_runner(self.attribute_guard(endpoint=self.endpoint, attribute=attributes.OperatingMode), timeout= self.timeout): + if async_function_runner(self.attribute_guard(endpoint=self.endpoint, attribute=attributes.OperatingMode), timeout=self.timeout): operatingMode = await self._read_icdm_attribute_expect_success( attributes.OperatingMode) @@ -273,7 +273,7 @@ async def test_TC_ICDM_2_1(self): operatingMode, modes.kUnknownEnumValue, "OperatingMode can only have 0 and 1 as valid values") self.step(11) - if async_function_runner(self.attribute_guard(endpoint=self.endpoint, attribute=attributes.MaximumCheckInBackOff), timeout= self.timeout): + if async_function_runner(self.attribute_guard(endpoint=self.endpoint, attribute=attributes.MaximumCheckInBackOff), timeout=self.timeout): maximumCheckInBackOff = await self._read_icdm_attribute_expect_success(attributes.MaximumCheckInBackOff) asserts.assert_true(self.is_valid_uint32_value(maximumCheckInBackOff), diff --git a/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py b/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py index 656bbcda9f6976..dd1e67fc5d6000 100644 --- a/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py +++ b/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py @@ -2140,9 +2140,10 @@ async def frapper(): return await asyncio.wait_for(function, timeout=timeout) with ThreadPoolExecutor(max_workers=1) as executor: - future = executor.submit(lambda: asyncio.run(frapper())) + future = executor.submit(lambda: asyncio.run(frapper())) return future.result() + def _async_runner(body, self: MatterBaseTest, *args, **kwargs): timeout = self.matter_test_config.timeout if self.matter_test_config.timeout is not None else self.default_timeout return self.event_loop.run_until_complete(asyncio.wait_for(body(self, *args, **kwargs), timeout=timeout)) From 1b63d633fb4f1f8d67248d4783d216455a205a08 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 23 Jan 2025 17:17:26 +0000 Subject: [PATCH 13/14] Restyled by isort --- src/python_testing/TC_ICDM_2_1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/TC_ICDM_2_1.py b/src/python_testing/TC_ICDM_2_1.py index 7305cce32eb5d7..8955cb6c324aed 100644 --- a/src/python_testing/TC_ICDM_2_1.py +++ b/src/python_testing/TC_ICDM_2_1.py @@ -39,7 +39,7 @@ import re import chip.clusters as Clusters -from chip.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main, async_function_runner +from chip.testing.matter_testing import MatterBaseTest, TestStep, async_function_runner, async_test_body, default_matter_test_main from mobly import asserts logger = logging.getLogger(__name__) From 545232f8668e144d7254cd8ee328667246079152 Mon Sep 17 00:00:00 2001 From: Jake Ororke Date: Mon, 27 Jan 2025 09:22:09 -0800 Subject: [PATCH 14/14] Updating TC_ICDM_2_1 test module: - Replaced PICS with new async_function_runner function to resolve issue with unit test failing --- src/python_testing/TC_ICDM_2_1.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/python_testing/TC_ICDM_2_1.py b/src/python_testing/TC_ICDM_2_1.py index 8955cb6c324aed..3566155b4940b9 100644 --- a/src/python_testing/TC_ICDM_2_1.py +++ b/src/python_testing/TC_ICDM_2_1.py @@ -255,7 +255,8 @@ async def test_TC_ICDM_2_1(self): pattern = re.compile(r'^[0-9A-F]{6}$') asserts.assert_true(pattern.match(userActiveModeTriggerInstruction), "UserActiveModeTriggerInstruction is not in the correct format for the associated UserActiveModeTriggerHint") - elif self.check_pics("ICDM.S.A0006"): + + elif async_function_runner(self.attribute_guard(endpoint=self.endpoint, attribute=attributes.UserActiveModeTriggerHint), timeout=self.timeout): # Check if the UserActiveModeTriggerInstruction was required asserts.assert_false(uatHintInstructionDepedentBitmap in kUatInstructionMandatoryBitMask, "UserActiveModeTriggerHint requires the UserActiveModeTriggerInstruction")