From ae0c4863e2f6f05cd0d0ea15ced957a68ba5d809 Mon Sep 17 00:00:00 2001 From: juandediosg Date: Mon, 17 Feb 2025 12:47:19 -0600 Subject: [PATCH 1/6] Implement TC_DEMM_1_2 with Python --- src/python_testing/TC_DEMM_1_2.py | 110 ++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 src/python_testing/TC_DEMM_1_2.py diff --git a/src/python_testing/TC_DEMM_1_2.py b/src/python_testing/TC_DEMM_1_2.py new file mode 100644 index 00000000000000..4c1842957da19c --- /dev/null +++ b/src/python_testing/TC_DEMM_1_2.py @@ -0,0 +1,110 @@ +# +# Copyright (c) 2025 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# See https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/python.md#defining-the-ci-test-arguments +# for details about the block below. +# +# FIXME: https://github.com/project-chip/connectedhomeip/issues/36885 +# === BEGIN CI TEST ARGUMENTS === +# test-runner-runs: +# run1: +# app: ${CHIP_MICROWAVE_OVEN_APP} +# app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json +# script-args: > +# --storage-path admin_storage.json +# --commissioning-method on-network +# --discriminator 1234 +# --passcode 20202021 +# --PICS src/app/tests/suites/certification/ci-pics-values +# --endpoint 1 +# --trace-to json:${TRACE_TEST_JSON}.json +# --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto +# factory-reset: true +# quiet: true +# === END CI TEST ARGUMENTS === + + +import chip.clusters as Clusters +from chip.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from modebase_cluster_check import ModeBaseClusterChecks + +CLUSTER = Clusters.RefrigeratorAndTemperatureControlledCabinetMode + + +class TC_DEMM_1_2(MatterBaseTest, ModeBaseClusterChecks): + + def __init__(self, *args): + MatterBaseTest.__init__(self, *args) + ModeBaseClusterChecks.__init__(self, + modebase_derived_cluster=CLUSTER) + + def desc_TC_DEMM_1_2(self) -> str: + return "[TC-DEMM-1.2] Cluster attributes with DUT as Server" + + def steps_TC_DEMM_1_2(self) -> list[TestStep]: + steps = [ + TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep(2, "TH reads from the DUT the SupportedModes attribute."), + TestStep(3, "TH reads from the DUT the CurrentMode attribute."), + TestStep(4, "TH reads from the DUT the OnMode attribute."), + TestStep(5, "TH reads from the DUT the StartUpMode attribute.") + ] + return steps + + def pics_TC_DEMM_1_2(self) -> list[str]: + pics = [ + "DEMM.S" + ] + return pics + + @async_test_body + async def test_TC_DEMM_1_2(self): + + # Setup common mode check + endpoint = self.get_endpoint(default=1) + + self.step(1) + + self.step(2) + # Verify common checks for Mode Base as described in the TC-DEMM-1.2 + supported_modes = await self.check_supported_modes_and_labels(endpoint=endpoint) + # According to the spec, there should be at least one RapidCool or RapidFreeze tag in + # the ones supported. + additional_tags = [CLUSTER.Enums.ModeTag.kRapidCool, + CLUSTER.Enums.ModeTag.kRapidFreeze] + self.check_tags_in_lists(supported_modes=supported_modes, required_tags=additional_tags) + + self.step(3) + # Verify that the CurrentMode attribute has a valid value. + mode = self.cluster.Attributes.CurrentMode + await self.read_and_check_mode(endpoint=endpoint, mode=mode, supported_modes=supported_modes) + + self.step(4) + # Verify that the OnMode attribute has a valid value or null. + mode = self.cluster.Attributes.OnMode + await self.read_and_check_mode(endpoint=endpoint, mode=mode, + supported_modes=supported_modes, is_nullable=True) + + self.step(5) + # Verify that the StartUpMode has a valid value or null + mode = self.cluster.Attributes.StartUpMode + await self.read_and_check_mode(endpoint=endpoint, mode=mode, + supported_modes=supported_modes, is_nullable=True) + + +if __name__ == "__main__": + default_matter_test_main() From f4e89768904d24d99760a309d27c6b4e25a4623e Mon Sep 17 00:00:00 2001 From: juandediosg Date: Mon, 17 Feb 2025 19:08:05 -0600 Subject: [PATCH 2/6] Implemented functionality to validate DEMM in tests --- src/python_testing/TC_DEMM_1_2.py | 35 ++++++++++++++++--------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/python_testing/TC_DEMM_1_2.py b/src/python_testing/TC_DEMM_1_2.py index 4c1842957da19c..ebec7674079f3f 100644 --- a/src/python_testing/TC_DEMM_1_2.py +++ b/src/python_testing/TC_DEMM_1_2.py @@ -42,7 +42,7 @@ from chip.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from modebase_cluster_check import ModeBaseClusterChecks -CLUSTER = Clusters.RefrigeratorAndTemperatureControlledCabinetMode +CLUSTER = Clusters.DeviceEnergyManagementMode class TC_DEMM_1_2(MatterBaseTest, ModeBaseClusterChecks): @@ -60,8 +60,8 @@ def steps_TC_DEMM_1_2(self) -> list[TestStep]: TestStep(1, "Commissioning, already done", is_commissioning=True), TestStep(2, "TH reads from the DUT the SupportedModes attribute."), TestStep(3, "TH reads from the DUT the CurrentMode attribute."), - TestStep(4, "TH reads from the DUT the OnMode attribute."), - TestStep(5, "TH reads from the DUT the StartUpMode attribute.") + # TestStep(4, "TH reads from the DUT the OnMode attribute."), + # TestStep(5, "TH reads from the DUT the StartUpMode attribute.") ] return steps @@ -82,10 +82,11 @@ async def test_TC_DEMM_1_2(self): self.step(2) # Verify common checks for Mode Base as described in the TC-DEMM-1.2 supported_modes = await self.check_supported_modes_and_labels(endpoint=endpoint) - # According to the spec, there should be at least one RapidCool or RapidFreeze tag in + # According to the spec, there should be at least on like + # No Optimization, Device Optimization, Local Optimization, or Grid Optimization tag in # the ones supported. - additional_tags = [CLUSTER.Enums.ModeTag.kRapidCool, - CLUSTER.Enums.ModeTag.kRapidFreeze] + additional_tags = [CLUSTER.Enums.ModeTag.kNoOptimization, + CLUSTER.Enums.ModeTag.kDeviceOptimization] self.check_tags_in_lists(supported_modes=supported_modes, required_tags=additional_tags) self.step(3) @@ -93,17 +94,17 @@ async def test_TC_DEMM_1_2(self): mode = self.cluster.Attributes.CurrentMode await self.read_and_check_mode(endpoint=endpoint, mode=mode, supported_modes=supported_modes) - self.step(4) - # Verify that the OnMode attribute has a valid value or null. - mode = self.cluster.Attributes.OnMode - await self.read_and_check_mode(endpoint=endpoint, mode=mode, - supported_modes=supported_modes, is_nullable=True) - - self.step(5) - # Verify that the StartUpMode has a valid value or null - mode = self.cluster.Attributes.StartUpMode - await self.read_and_check_mode(endpoint=endpoint, mode=mode, - supported_modes=supported_modes, is_nullable=True) + # self.step(4) + # # Verify that the OnMode attribute has a valid value or null. + # mode = self.cluster.Attributes.OnMode + # await self.read_and_check_mode(endpoint=endpoint, mode=mode, + # supported_modes=supported_modes, is_nullable=True) + + # self.step(5) + # # Verify that the StartUpMode has a valid value or null + # mode = self.cluster.Attributes.StartUpMode + # await self.read_and_check_mode(endpoint=endpoint, mode=mode, + # supported_modes=supported_modes, is_nullable=True) if __name__ == "__main__": From c40f74cd006651855cc2a1a2183e30b640a8a796 Mon Sep 17 00:00:00 2001 From: juandediosg Date: Mon, 17 Feb 2025 19:32:34 -0600 Subject: [PATCH 3/6] Update functionality to validate DEMM in tests --- src/python_testing/TC_DEMM_1_2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/python_testing/TC_DEMM_1_2.py b/src/python_testing/TC_DEMM_1_2.py index ebec7674079f3f..41dbd06628d57b 100644 --- a/src/python_testing/TC_DEMM_1_2.py +++ b/src/python_testing/TC_DEMM_1_2.py @@ -83,8 +83,8 @@ async def test_TC_DEMM_1_2(self): # Verify common checks for Mode Base as described in the TC-DEMM-1.2 supported_modes = await self.check_supported_modes_and_labels(endpoint=endpoint) # According to the spec, there should be at least on like - # No Optimization, Device Optimization, Local Optimization, or Grid Optimization tag in - # the ones supported. + # No Optimization, Device Optimization, Local Optimization, or Grid Optimization + # tag in the ones supported. additional_tags = [CLUSTER.Enums.ModeTag.kNoOptimization, CLUSTER.Enums.ModeTag.kDeviceOptimization] self.check_tags_in_lists(supported_modes=supported_modes, required_tags=additional_tags) From 3738da478c6c4f7d70f48ef6aed014cd4c1b62aa Mon Sep 17 00:00:00 2001 From: juandediosg Date: Wed, 19 Feb 2025 07:18:17 -0600 Subject: [PATCH 4/6] Fixed: Updated CI test arguments and Removed DEMM Arguments implemetation (OnMode and StartUpMode). --- src/python_testing/TC_DEMM_1_2.py | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/src/python_testing/TC_DEMM_1_2.py b/src/python_testing/TC_DEMM_1_2.py index 41dbd06628d57b..b2790de8cb9f4a 100644 --- a/src/python_testing/TC_DEMM_1_2.py +++ b/src/python_testing/TC_DEMM_1_2.py @@ -15,21 +15,19 @@ # limitations under the License. # -# See https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/python.md#defining-the-ci-test-arguments -# for details about the block below. -# -# FIXME: https://github.com/project-chip/connectedhomeip/issues/36885 # === BEGIN CI TEST ARGUMENTS === # test-runner-runs: # run1: -# app: ${CHIP_MICROWAVE_OVEN_APP} -# app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json +# app: ${ALL_CLUSTERS_APP} +# app-args: > +# --discriminator 1234 +# --KVS kvs1 +# --trace-to json:${TRACE_APP}.json # script-args: > # --storage-path admin_storage.json # --commissioning-method on-network # --discriminator 1234 # --passcode 20202021 -# --PICS src/app/tests/suites/certification/ci-pics-values # --endpoint 1 # --trace-to json:${TRACE_TEST_JSON}.json # --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto @@ -60,8 +58,6 @@ def steps_TC_DEMM_1_2(self) -> list[TestStep]: TestStep(1, "Commissioning, already done", is_commissioning=True), TestStep(2, "TH reads from the DUT the SupportedModes attribute."), TestStep(3, "TH reads from the DUT the CurrentMode attribute."), - # TestStep(4, "TH reads from the DUT the OnMode attribute."), - # TestStep(5, "TH reads from the DUT the StartUpMode attribute.") ] return steps @@ -94,18 +90,6 @@ async def test_TC_DEMM_1_2(self): mode = self.cluster.Attributes.CurrentMode await self.read_and_check_mode(endpoint=endpoint, mode=mode, supported_modes=supported_modes) - # self.step(4) - # # Verify that the OnMode attribute has a valid value or null. - # mode = self.cluster.Attributes.OnMode - # await self.read_and_check_mode(endpoint=endpoint, mode=mode, - # supported_modes=supported_modes, is_nullable=True) - - # self.step(5) - # # Verify that the StartUpMode has a valid value or null - # mode = self.cluster.Attributes.StartUpMode - # await self.read_and_check_mode(endpoint=endpoint, mode=mode, - # supported_modes=supported_modes, is_nullable=True) - if __name__ == "__main__": default_matter_test_main() From 56d2a50b57cee2be6ef55bfd102b732eb7d82876 Mon Sep 17 00:00:00 2001 From: juandediosg Date: Thu, 20 Feb 2025 18:34:07 -0600 Subject: [PATCH 5/6] Fixed: Renamed CLUSTER to cluster_demm_mode for clarity. --- src/python_testing/TC_DEMM_1_2.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/python_testing/TC_DEMM_1_2.py b/src/python_testing/TC_DEMM_1_2.py index b2790de8cb9f4a..785713eecde694 100644 --- a/src/python_testing/TC_DEMM_1_2.py +++ b/src/python_testing/TC_DEMM_1_2.py @@ -40,7 +40,7 @@ from chip.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from modebase_cluster_check import ModeBaseClusterChecks -CLUSTER = Clusters.DeviceEnergyManagementMode +cluster_demm_mode = Clusters.DeviceEnergyManagementMode class TC_DEMM_1_2(MatterBaseTest, ModeBaseClusterChecks): @@ -48,7 +48,7 @@ class TC_DEMM_1_2(MatterBaseTest, ModeBaseClusterChecks): def __init__(self, *args): MatterBaseTest.__init__(self, *args) ModeBaseClusterChecks.__init__(self, - modebase_derived_cluster=CLUSTER) + modebase_derived_cluster=cluster_demm_mode) def desc_TC_DEMM_1_2(self) -> str: return "[TC-DEMM-1.2] Cluster attributes with DUT as Server" @@ -81,8 +81,8 @@ async def test_TC_DEMM_1_2(self): # According to the spec, there should be at least on like # No Optimization, Device Optimization, Local Optimization, or Grid Optimization # tag in the ones supported. - additional_tags = [CLUSTER.Enums.ModeTag.kNoOptimization, - CLUSTER.Enums.ModeTag.kDeviceOptimization] + additional_tags = [cluster_demm_mode.Enums.ModeTag.kNoOptimization, + cluster_demm_mode.Enums.ModeTag.kDeviceOptimization] self.check_tags_in_lists(supported_modes=supported_modes, required_tags=additional_tags) self.step(3) From d104bc4ccc4fc823814fe45d164c62bd4ac27bc5 Mon Sep 17 00:00:00 2001 From: juandediosg Date: Thu, 27 Mar 2025 19:36:12 -0600 Subject: [PATCH 6/6] Fixed: Remove 'kDeviceOptimization' tag, leaving only 'kNoOptimization' as required and updating the CI arguments app: . --- src/python_testing/TC_DEMM_1_2.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/python_testing/TC_DEMM_1_2.py b/src/python_testing/TC_DEMM_1_2.py index 785713eecde694..0015b5b7383696 100644 --- a/src/python_testing/TC_DEMM_1_2.py +++ b/src/python_testing/TC_DEMM_1_2.py @@ -18,7 +18,7 @@ # === BEGIN CI TEST ARGUMENTS === # test-runner-runs: # run1: -# app: ${ALL_CLUSTERS_APP} +# app: ${ENERGY_MANAGEMENT_APP} # app-args: > # --discriminator 1234 # --KVS kvs1 @@ -81,8 +81,7 @@ async def test_TC_DEMM_1_2(self): # According to the spec, there should be at least on like # No Optimization, Device Optimization, Local Optimization, or Grid Optimization # tag in the ones supported. - additional_tags = [cluster_demm_mode.Enums.ModeTag.kNoOptimization, - cluster_demm_mode.Enums.ModeTag.kDeviceOptimization] + additional_tags = [cluster_demm_mode.Enums.ModeTag.kNoOptimization] self.check_tags_in_lists(supported_modes=supported_modes, required_tags=additional_tags) self.step(3)