Skip to content

Commit

Permalink
TC-TIMESYNC-3.1: python automation (project-chip#27925)
Browse files Browse the repository at this point in the history
Using python because it's the easiest way to do wildcard
and iterate over all the endpoints

Also changing other tests to force EP0
  • Loading branch information
cecille authored and erwinpan1 committed Jul 21, 2023
1 parent 9ff969a commit 8d306b4
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,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 --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_IDM_1_2.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 --script "src/python_testing/TestMatterTestingSupport.py"'
Expand Down
3 changes: 2 additions & 1 deletion src/python_testing/TC_TIMESYNC_2_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion src/python_testing/TC_TIMESYNC_2_4.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/python_testing/TC_TIMESYNC_2_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/python_testing/TC_TIMESYNC_2_6.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/python_testing/TC_TIMESYNC_2_7.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/python_testing/TC_TIMESYNC_2_8.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/python_testing/TC_TIMESYNC_2_9.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
48 changes: 48 additions & 0 deletions src/python_testing/TC_TIMESYNC_3_1.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 8d306b4

Please sign in to comment.