From bfceb0261197b92a3c4215d63cdc943ad0576e76 Mon Sep 17 00:00:00 2001 From: cecille Date: Fri, 7 Jul 2023 14:15:08 -0400 Subject: [PATCH] TC-TIMESYNC-3.1: python automation Using python because it's the easiest way to do wildcard and iterate over all the endpoints Also changing other tests to force EP0 --- .github/workflows/tests.yaml | 1 + src/python_testing/TC_TIMESYNC_2_2.py | 3 +- src/python_testing/TC_TIMESYNC_2_4.py | 3 +- src/python_testing/TC_TIMESYNC_2_5.py | 3 +- src/python_testing/TC_TIMESYNC_2_6.py | 3 +- src/python_testing/TC_TIMESYNC_2_7.py | 3 +- src/python_testing/TC_TIMESYNC_2_8.py | 3 +- src/python_testing/TC_TIMESYNC_2_9.py | 3 +- src/python_testing/TC_TIMESYNC_3_1.py | 48 +++++++++++++++++++++++++++ 9 files changed, 63 insertions(+), 7 deletions(-) create mode 100644 src/python_testing/TC_TIMESYNC_3_1.py diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index dff906bc08feb5..a8ef821ae6d939 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -446,6 +446,7 @@ jobs: 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_decode 1" --script "src/python_testing/TC_ACE_1_3.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021"' 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_decode 1" --script "src/python_testing/TC_CGEN_2_4.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021"' 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_decode 1" --script "src/python_testing/TC_DA_1_2.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"' + 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_decode 1" --script "src/python_testing/TC_TIMESYNC_3_1.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021"' 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_decode 1" --script "src/python_testing/TC_DA_1_5.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"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TestMatterTestingSupport.py"' - name: Uploading core files diff --git a/src/python_testing/TC_TIMESYNC_2_2.py b/src/python_testing/TC_TIMESYNC_2_2.py index 0a92f1c47fcf05..72b9d0978e65f3 100644 --- a/src/python_testing/TC_TIMESYNC_2_2.py +++ b/src/python_testing/TC_TIMESYNC_2_2.py @@ -32,7 +32,8 @@ async def read_ts_attribute_expect_success(self, endpoint, attribute): @async_test_body async def test_TC_TIMESYNC_2_2(self): - endpoint = self.user_params.get("endpoint", 0) + # Time sync is required to be on endpoint 0 if it is present + endpoint = 0 time_cluster = Clusters.Objects.TimeSynchronization diff --git a/src/python_testing/TC_TIMESYNC_2_4.py b/src/python_testing/TC_TIMESYNC_2_4.py index 7ad3dfe840aaaa..b5cd3621f2b319 100644 --- a/src/python_testing/TC_TIMESYNC_2_4.py +++ b/src/python_testing/TC_TIMESYNC_2_4.py @@ -46,7 +46,8 @@ async def send_set_time_zone_cmd_expect_error(self, tz: typing.List[Clusters.Obj @async_test_body async def test_TC_TIMESYNC_2_4(self): - self.endpoint = self.user_params.get("endpoint", 0) + # Time sync is required to be on endpoint 0 if it is present + self.endpoint = 0 time_cluster = Clusters.Objects.TimeSynchronization tz_struct = time_cluster.Structs.TimeZoneStruct diff --git a/src/python_testing/TC_TIMESYNC_2_5.py b/src/python_testing/TC_TIMESYNC_2_5.py index 3b2f62ce8d2810..683009c88733f7 100644 --- a/src/python_testing/TC_TIMESYNC_2_5.py +++ b/src/python_testing/TC_TIMESYNC_2_5.py @@ -43,7 +43,8 @@ async def send_set_dst_cmd_expect_error(self, dst: typing.List[Clusters.Objects. @async_test_body async def test_TC_TIMESYNC_2_5(self): - self.endpoint = self.user_params.get("endpoint", 0) + # Time sync is required to be on endpoint 0 if it is present + self.endpoint = 0 time_cluster = Clusters.Objects.TimeSynchronization dst_struct = time_cluster.Structs.DSTOffsetStruct diff --git a/src/python_testing/TC_TIMESYNC_2_6.py b/src/python_testing/TC_TIMESYNC_2_6.py index 2c12ed803ce221..23ed1a5575b6dd 100644 --- a/src/python_testing/TC_TIMESYNC_2_6.py +++ b/src/python_testing/TC_TIMESYNC_2_6.py @@ -43,7 +43,8 @@ async def send_set_default_ntp_cmd_expect_error(self, ntp: typing.Union[Nullable @async_test_body async def test_TC_TIMESYNC_2_6(self): - self.endpoint = self.user_params.get("endpoint", 0) + # Time sync is required to be on endpoint 0 if it is present + self.endpoint = 0 self.print_step(0, "Commissioning, already done") attributes = Clusters.TimeSynchronization.Attributes diff --git a/src/python_testing/TC_TIMESYNC_2_7.py b/src/python_testing/TC_TIMESYNC_2_7.py index 1aab7f9c126b66..6fe19d0c5b6aad 100644 --- a/src/python_testing/TC_TIMESYNC_2_7.py +++ b/src/python_testing/TC_TIMESYNC_2_7.py @@ -49,7 +49,8 @@ async def send_set_utc_cmd(self, utc: uint) -> None: @async_test_body async def test_TC_TIMESYNC_2_7(self): - self.endpoint = self.user_params.get("endpoint", 0) + # Time sync is required to be on endpoint 0 if it is present + self.endpoint = 0 self.print_step(0, "Commissioning, already done") time_cluster = Clusters.Objects.TimeSynchronization diff --git a/src/python_testing/TC_TIMESYNC_2_8.py b/src/python_testing/TC_TIMESYNC_2_8.py index 589cc61b381752..ac72977625f798 100644 --- a/src/python_testing/TC_TIMESYNC_2_8.py +++ b/src/python_testing/TC_TIMESYNC_2_8.py @@ -49,7 +49,8 @@ async def send_set_utc_cmd(self, utc: uint) -> None: @async_test_body async def test_TC_TIMESYNC_2_8(self): - self.endpoint = self.user_params.get("endpoint", 0) + # Time sync is required to be on endpoint 0 if it is present + self.endpoint = 0 self.print_step(0, "Commissioning, already done") time_cluster = Clusters.Objects.TimeSynchronization diff --git a/src/python_testing/TC_TIMESYNC_2_9.py b/src/python_testing/TC_TIMESYNC_2_9.py index 77857c195540f0..a1d10d4c9616cc 100644 --- a/src/python_testing/TC_TIMESYNC_2_9.py +++ b/src/python_testing/TC_TIMESYNC_2_9.py @@ -48,7 +48,8 @@ async def send_set_utc_cmd(self, utc: uint) -> None: @async_test_body async def test_TC_TIMESYNC_2_9(self): - self.endpoint = self.user_params.get("endpoint", 0) + # Time sync is required to be on endpoint 0 if it is present + self.endpoint = 0 self.print_step(0, "Commissioning, already done") time_cluster = Clusters.Objects.TimeSynchronization diff --git a/src/python_testing/TC_TIMESYNC_3_1.py b/src/python_testing/TC_TIMESYNC_3_1.py new file mode 100644 index 00000000000000..f05730e58dcad0 --- /dev/null +++ b/src/python_testing/TC_TIMESYNC_3_1.py @@ -0,0 +1,48 @@ +# +# Copyright (c) 2023 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. +# + +import chip.clusters as Clusters +from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main +from mobly import asserts + + +class TC_TIMESYNC_3_1(MatterBaseTest): + + @async_test_body + async def test_TC_TIMESYNC_3_1(self): + self.print_step(1, "Wildcard read of time sync cluster") + utc_time_attr = Clusters.TimeSynchronization.Attributes.UTCTime + ret = await self.default_controller.ReadAttribute(nodeid=self.dut_node_id, attributes=[(utc_time_attr)]) + asserts.assert_equal(len(ret.keys()), 1, 'More than one time cluster found on the node') + asserts.assert_equal(next(iter(ret)), 0, 'Time cluster found on non-root endpoint') + + self.print_step(2, "Wildcard read of descriptor cluster") + server_list_attr = Clusters.Descriptor.Attributes.ServerList + ret = await self.default_controller.ReadAttribute(nodeid=self.dut_node_id, attributes=[(server_list_attr)]) + print(ret) + for endpoint, servers in ret.items(): + server_list = servers[Clusters.Descriptor][Clusters.Descriptor.Attributes.ServerList] + if endpoint == 0: + asserts.assert_true(Clusters.TimeSynchronization.id in server_list, + 'Time cluster id is not listed in server list for root endpoint') + else: + asserts.assert_false(Clusters.TimeSynchronization.id in server_list, + f'Time cluster id is incorrectly listed in the server list for ep {endpoint}') + + +if __name__ == "__main__": + default_matter_test_main()