Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HVAC] Use atomic writes with Presets #34570

Merged
merged 100 commits into from
Aug 5, 2024
Merged
Changes from 1 commit
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
46d9098
Add support for Presets attributes and commands to the Thermostat clu…
nivi-apple Jul 26, 2024
5d2c740
Restyled by whitespace
restyled-commits Jul 26, 2024
f14e43e
Restyled by clang-format
restyled-commits Jul 26, 2024
dfe9f7c
Restyled by gn.
restyled-commits Jul 26, 2024
3dad3f3
Fix build error for Linux configure build of all-clusters-app
nivi-apple Jul 26, 2024
8e6db6e
Fix Darwin CI issues
nivi-apple Jul 26, 2024
362ca12
Restyled by clang-format
restyled-commits Jul 26, 2024
cb96615
More fixes
nivi-apple Jul 26, 2024
07e78e0
Restyled by clang-format
restyled-commits Jul 26, 2024
9c511bf
BUILD.gn fixes for CI
nivi-apple Jul 26, 2024
f027069
Apply suggestions from code review
nivi-apple Jul 26, 2024
a2bb5d6
Address review comments.
nivi-apple Jul 27, 2024
0147c71
Restyled by clang-format
restyled-commits Jul 27, 2024
029e9a4
Regenerate Thermostat XML from spec
hasty Jul 28, 2024
48ac309
Move atomic enum to global-enums.xml, actually
hasty Jul 26, 2024
5216415
Regenerate XML and convert thermostat-server to atomic writes
hasty Jul 28, 2024
72d114f
Merge branch 'master' into add_presets_to_Sdk
hasty Jul 29, 2024
38d14fc
Merge branch 'master' into add_presets_to_Sdk
hasty Jul 29, 2024
8511469
Pull in ACCapacityFormat typo un-fix
hasty Jul 29, 2024
dabf994
Update Test_TC_TSTAT_1_1 to know about AtomicResponse command.
bzbarsky-apple Jul 29, 2024
0212f7c
Merge branch 'master' into add_presets_to_Sdk
hasty Jul 29, 2024
90a20c1
Restyled patch
hasty Jul 29, 2024
a567de4
Merge branch 'add_presets_to_Sdk' of github.com:hasty/connectedhomeip…
hasty Jul 29, 2024
1c49a80
Merge branch 'master' into add_presets_to_Sdk
hasty Jul 29, 2024
aef165e
Fix weird merge with upstream
hasty Jul 29, 2024
9efed86
Merge branch 'add_presets_to_Sdk' of github.com:hasty/connectedhomeip…
hasty Jul 29, 2024
4c457a9
Fix emberAfIsTypeSigned not understanding temperature type
hasty Jul 29, 2024
1257477
Merge branch 'master' into add_presets_to_Sdk
hasty Jul 29, 2024
c34a9cb
Merge fixes from atomic write branch
hasty Jul 30, 2024
4665050
Merge branch 'master' into add_presets_to_Sdk
hasty Jul 30, 2024
6d2fda4
Merge branch 'add_presets_to_Sdk' of github.com:hasty/connectedhomeip…
hasty Jul 30, 2024
7acd5d4
Merge branch 'master' into add_presets_to_Sdk
hasty Jul 30, 2024
8dbabb1
Merge branch 'master' into add_presets_to_Sdk
hasty Jul 30, 2024
704c544
Relocate thermostat-manager sample code to all-clusters-common
hasty Jul 30, 2024
9d89cfe
Merge branch 'master' into add_presets_to_Sdk
hasty Jul 30, 2024
7a4f4fd
Merge branch 'add_presets_to_Sdk' of github.com:hasty/connectedhomeip…
hasty Jul 30, 2024
6de046a
Merge branch 'master' into add_presets_to_Sdk
hasty Jul 30, 2024
d67f988
Fix g++ build error on linux
hasty Jul 30, 2024
449379b
Merge branch 'add_presets_to_Sdk' of github.com:hasty/connectedhomeip…
hasty Jul 30, 2024
4c8e0a0
Fix C formatter for long int, cast whole expression
hasty Jul 30, 2024
c76e768
Merge branch 'master' into add_presets_to_Sdk
hasty Jul 30, 2024
3f40391
Merge branch 'add_presets_to_Sdk' of github.com:hasty/connectedhomeip…
hasty Jul 30, 2024
5ce2df1
Merge branch 'master' into add_presets_to_Sdk
hasty Jul 30, 2024
cf780e3
Sync cast fix with master
hasty Jul 30, 2024
af25396
Merge branch 'master' into add_presets_to_Sdk
hasty Jul 30, 2024
c80f42d
Merge branch 'add_presets_to_Sdk' of github.com:hasty/connectedhomeip…
hasty Jul 30, 2024
b4f50f6
Add thermostat-common dependency to thermostat app under linux
hasty Jul 30, 2024
51d8aaa
Merge branch 'master' into add_presets_to_Sdk
hasty Jul 30, 2024
5abc22d
Merge branch 'add_presets_to_Sdk' of github.com:hasty/connectedhomeip…
hasty Jul 30, 2024
637db40
Remove MatterPostAttributeChangeCallback from thermostat-manager, as …
hasty Jul 30, 2024
fadce3b
Merge branch 'master' into add_presets_to_Sdk
hasty Jul 30, 2024
c6e07d0
Merge branch 'add_presets_to_Sdk' of github.com:hasty/connectedhomeip…
hasty Jul 30, 2024
4b03da7
Merge branch 'master' into add_presets_to_Sdk
hasty Jul 30, 2024
0c1b853
Convert Atomic enums and structs to global
hasty Jul 30, 2024
c41d02c
Restyled patch
hasty Jul 30, 2024
924ad8f
Merge branch 'master' into add_presets_to_Sdk
hasty Jul 30, 2024
7d8df6e
Merge branch 'master' into add_presets_to_Sdk
hasty Jul 31, 2024
31ebe9d
Merge branch 'add_presets_to_Sdk' of github.com:hasty/connectedhomeip…
hasty Jul 31, 2024
2740112
Apply suggestions from code review
hasty Jul 31, 2024
dabc3a0
Regen with alchemy 0.6.1
hasty Aug 1, 2024
f08c0cf
Updates based on comments
hasty Aug 1, 2024
77c0dca
Add TC_MCORE_FS_1_3.py test implementation (#34650)
tehampson Jul 31, 2024
608d034
Fix most TC-SWTCH-2.4 remaining issues (#34677)
tcarmelveilleux Jul 31, 2024
dc312d7
Initial test script for Fabric Sync TC_MCORE_FS_1_2 (#34675)
cletnick Jul 31, 2024
ad792f1
Test automation for FabricSync ICD BridgedDeviceBasicInfoCluster (#34…
rochaferraz Jul 31, 2024
60d0429
ServiceArea test scripts (#34548)
plauric Jul 31, 2024
78dab72
Remove manual tests for Thermostat presets (#34679)
nivi-apple Jul 31, 2024
d7cadf9
Dump details about leaked ExchangeContexts before aborting (#34617)
ksperling-apple Jul 31, 2024
153c398
[TI] CC13x4_26x4 build fixes (#34682)
abiradarti Aug 1, 2024
b2e22c7
[ICD] Add missing polling function to NoWifi connectivity manager (#3…
mkardous-silabs Aug 1, 2024
12d0123
[OPSTATE] Add Q test script for CountdownTime (#34632)
rbultman Aug 1, 2024
9351279
YAML update to BRBINFO, ProductId (#34513)
rochaferraz Aug 1, 2024
08cb38b
Fix simplified Linux tv-casting-app gn build error. (#34692)
shaoltan-amazon Aug 1, 2024
ee27016
adding parallel execution to restyle-diff (#34663)
Alami-Amine Aug 1, 2024
aebaedb
Add some bits to exercise global structs/enums to Unit Testing cluste…
bzbarsky-apple Aug 1, 2024
1a7352f
[Silabs] Port platform specific Multi-Chip OTA work (#34440)
mykrupp Aug 1, 2024
eb59fc3
Add python tests for Thermostat presets feature (#34693)
nivi-apple Aug 1, 2024
5c6312b
removing unneccessary git fetch (#34698)
Alami-Amine Aug 1, 2024
687b1ac
Merge branch 'add_presets_to_Sdk' of github.com:hasty/connectedhomeip…
hasty Aug 1, 2024
6cb787b
Merge branch 'master' into add_presets_to_Sdk
hasty Aug 1, 2024
b815bbd
Restyle patch
hasty Aug 1, 2024
cf97803
Merge branch 'add_presets_to_Sdk' of github.com:hasty/connectedhomeip…
hasty Aug 1, 2024
d424a77
Regen to fix ordering of global structs
hasty Aug 1, 2024
b5410d3
Apply suggestions from code review
hasty Aug 1, 2024
353c9c1
Return correct AtomicResponse when committing or rolling back
hasty Aug 1, 2024
c58ab73
Merge branch 'master' of github.com:project-chip/connectedhomeip into…
hasty Aug 1, 2024
f0b8e7d
Merge branch 'add_presets_to_Sdk' of github.com:hasty/connectedhomeip…
hasty Aug 1, 2024
be7ca99
Patch tests for atomic write of presets
hasty Aug 2, 2024
23f3063
Fix tests to work with the new setup.
bzbarsky-apple Aug 2, 2024
ed59a01
Merge pull request #1 from bzbarsky-apple/pr-34570-fixup
hasty Aug 2, 2024
627e3f6
Merge branch 'master' of github.com:project-chip/connectedhomeip into…
hasty Aug 4, 2024
0966a01
Merge branch 'master' into add_presets_to_Sdk
hasty Aug 4, 2024
c37228c
Fix PICS values for atomic requests
hasty Aug 4, 2024
ba877a8
Remove PresetsSchedulesEditable and QueuedPreset from various places
hasty Aug 4, 2024
1106e1f
Restyled patch
hasty Aug 4, 2024
18d202a
Restyled patch, again
hasty Aug 4, 2024
18325f4
Remove PICS value for PresetsSchedulesEditable
hasty Aug 4, 2024
11eda5a
clang-tidy fixes
hasty Aug 5, 2024
0478b52
clang-tidy fixes
hasty Aug 5, 2024
9a4d415
Merge branch 'add_presets_to_Sdk' of github.com:hasty/connectedhomeip…
hasty Aug 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add TC_MCORE_FS_1_3.py test implementation (#34650)
  • Loading branch information
tehampson authored and hasty committed Aug 1, 2024
commit 77c0dcafc9826b3cb3c456559e31d5aad7b10df1
175 changes: 175 additions & 0 deletions src/python_testing/TC_MCORE_FS_1_3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
#
# Copyright (c) 2024 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.
#

# This test requires a TH_SERVER application that returns UnsupportedAttribute when reading UniqueID from BasicInformation Cluster. Please specify with --string-arg th_server_app_path:<path_to_app>

import logging
import os
import random
import signal
import subprocess
import time
import uuid

import chip.clusters as Clusters
from chip import ChipDeviceCtrl
from chip.interaction_model import Status
from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main, type_matches
from mobly import asserts


class TC_MCORE_FS_1_3(MatterBaseTest):
@async_test_body
async def setup_class(self):
super().setup_class()
self.device_for_th_eco_nodeid = 1111
self.device_for_th_eco_kvs = None
self.device_for_th_eco_port = 5543
self.app_process_for_th_eco = None

self.device_for_dut_eco_nodeid = 1112
self.device_for_dut_eco_kvs = None
self.device_for_dut_eco_port = 5544
self.app_process_for_dut_eco = None

# Create a second controller on a new fabric to communicate to the server
new_certificate_authority = self.certificate_authority_manager.NewCertificateAuthority()
new_fabric_admin = new_certificate_authority.NewFabricAdmin(vendorId=0xFFF1, fabricId=2)
paa_path = str(self.matter_test_config.paa_trust_store_path)
self.TH_server_controller = new_fabric_admin.NewController(nodeId=112233, paaTrustStorePath=paa_path)

def teardown_class(self):
if self.app_process_for_dut_eco is not None:
logging.warning("Stopping app with SIGTERM")
self.app_process_for_dut_eco.send_signal(signal.SIGTERM.value)
self.app_process_for_dut_eco.wait()
if self.app_process_for_th_eco is not None:
logging.warning("Stopping app with SIGTERM")
self.app_process_for_th_eco.send_signal(signal.SIGTERM.value)
self.app_process_for_th_eco.wait()

os.remove(self.device_for_dut_eco_kvs)
if self.device_for_th_eco_kvs is not None:
os.remove(self.device_for_th_eco_kvs)
super().teardown_class()

async def create_device_and_commission_to_th_fabric(self, kvs, port, node_id_for_th, device_info):
# TODO: confirm whether we can open processes like this on the TH
app = self.user_params.get("th_server_app_path", None)
if not app:
asserts.fail('This test requires a TH_SERVER app. Specify app path with --string-arg th_server_app_path:<path_to_app>')

discriminator = random.randint(0, 4095)
passcode = 20202021
app_args = f'--secured-device-port {port} --discriminator {discriminator} --passcode {passcode} --KVS {kvs}'
cmd = f'{app} {app_args}'
# TODO: Determine if we want these logs cooked or pushed to somewhere else
logging.info(f"Starting TH device for {device_info}")
self.app_process_for_dut_eco = subprocess.Popen(cmd, bufsize=0, shell=True)
logging.info(f"Started TH device for {device_info}")
time.sleep(3)

logging.info("Commissioning from separate fabric")
await self.TH_server_controller.CommissionOnNetwork(nodeId=node_id_for_th, setupPinCode=passcode, filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=discriminator)
logging.info("Commissioning device for DUT ecosystem onto TH for managing")

async def create_and_commission_device_for_th_ecosystem(self):
# TODO: confirm whether we can open processes like this on the TH
app = self.user_params.get("th_server_app_path", None)

self.device_for_th_eco_kvs = f'kvs_{str(uuid.uuid4())}'
discriminator = random.randint(0, 4095)
passcode = 20202021
app_args = f'--secured-device-port {self.device_for_th_eco_port} --discriminator {discriminator} --passcode {passcode} --KVS {self.device_for_th_eco_kvs}'
cmd = f'{app} {app_args}'
# TODO: Determine if we want these logs cooked or pushed to somewhere else
logging.info("Starting TH device for TH ecosystem")
self.app_process_for_th_eco = subprocess.Popen(cmd, bufsize=0, shell=True)
logging.info("Started TH device for TH ecosystem")
time.sleep(3)

logging.info("Commissioning from separate fabric")
self.server_nodeid = 1112
await self.TH_server_controller.CommissionOnNetwork(nodeId=self.server_nodeid, setupPinCode=passcode, filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=discriminator)
logging.info("Commissioning TH device for TH ecosystem")

def steps_TC_MCORE_FS_1_3(self) -> list[TestStep]:
steps = [TestStep(1, "DUT_FSA commissions TH_SED_DUT to DUT_FSAs fabric and generates a UniqueID", is_commissioning=True),
TestStep(2, "TH_FSA commissions TH_SED_TH onto TH_FSAs fabric and generates a UniqueID."),
TestStep(3, "Follow manufacturer provided instructions to enable DUT_FSA to synchronize TH_SED_TH onto DUT_FSAs fabric."),
TestStep(4, "DUT_FSA synchronizes TH_SED_TH onto DUT_FSAs fabric and copies the UniqueID presented by TH_FSAs Bridged Device Basic Information Cluster.")]
return steps

@async_test_body
async def test_TC_MCORE_FS_1_3(self):
self.is_ci = self.check_pics('PICS_SDK_CI_ONLY')
self.print_step(0, "Commissioning DUT to TH, already done")
self.step(1)
# These steps are not explicitly in step 1, but they help identify the dynamically added endpoint in step 1.
root_node_endpoint = 0
root_part_list = await self.read_single_attribute_check_success(cluster=Clusters.Descriptor, attribute=Clusters.Descriptor.Attributes.PartsList, endpoint=root_node_endpoint)
set_of_endpoints_before_adding_device = set(root_part_list)

kvs = f'kvs_{str(uuid.uuid4())}'
device_info = "for DUT ecosystem"
await self.create_device_and_commission_to_th_fabric(kvs, self.device_for_dut_eco_port, self.device_for_dut_eco_nodeid, device_info)
self.device_for_dut_eco_kvs = kvs
read_result = await self.TH_server_controller.ReadAttribute(self.device_for_dut_eco_nodeid, [(root_node_endpoint, Clusters.BasicInformation.Attributes.UniqueID)])
result = read_result[root_node_endpoint][Clusters.BasicInformation][Clusters.BasicInformation.Attributes.UniqueID]
asserts.assert_true(type_matches(result, Clusters.Attribute.ValueDecodeFailure), "We were expecting a value decode failure")
asserts.assert_equal(result.Reason.status, Status.UnsupportedAttribute, "Incorrect error returned from reading UniqueID")

params = await self.openCommissioningWindow(dev_ctrl=self.TH_server_controller, node_id=self.device_for_dut_eco_nodeid)

self.wait_for_user_input(
prompt_msg=f"Using the DUT vendor's provided interface, commission the device using the following parameters:\n"
f"- discriminator: {params.randomDiscriminator}\n"
f"- setupPinCode: {params.commissioningParameters.setupPinCode}\n"
f"- setupQRCode: {params.commissioningParameters.setupQRCode}\n"
f"- setupManualcode: {params.commissioningParameters.setupManualCode}\n"
f"If using FabricSync Admin, you may type:\n"
f">>> pairing onnetwork <desired_node_id> {params.commissioningParameters.setupPinCode}")

root_part_list = await self.read_single_attribute_check_success(cluster=Clusters.Descriptor, attribute=Clusters.Descriptor.Attributes.PartsList, endpoint=root_node_endpoint)
set_of_endpoints_after_adding_device = set(root_part_list)

asserts.assert_true(set_of_endpoints_after_adding_device.issuperset(
set_of_endpoints_before_adding_device), "Expected only new endpoints to be added")
unique_endpoints_set = set_of_endpoints_after_adding_device - set_of_endpoints_before_adding_device
asserts.assert_equal(len(unique_endpoints_set), 1, "Expected only one new endpoint")
newly_added_endpoint = list(unique_endpoints_set)[0]

th_sed_dut_unique_id = await self.read_single_attribute_check_success(cluster=Clusters.BridgedDeviceBasicInformation, attribute=Clusters.BridgedDeviceBasicInformation.Attributes.UniqueID, endpoint=newly_added_endpoint)
asserts.assert_true(type_matches(th_sed_dut_unique_id, str), "UniqueID should be a string")
asserts.assert_true(th_sed_dut_unique_id, "UniqueID should not be an empty string")

self.step(2)
kvs = f'kvs_{str(uuid.uuid4())}'
device_info = "for TH_FSA ecosystem"
await self.create_device_and_commission_to_th_fabric(kvs, self.device_for_th_eco_port, self.device_for_th_eco_nodeid, device_info)
self.device_for_th_eco_kvs = kvs
# TODO(https://github.com/CHIP-Specifications/chip-test-plans/issues/4375) During setup we need to create the TH_FSA device
# where we would commission device created in create_device_and_commission_to_th_fabric to be commissioned into TH_FSA.

# TODO(https://github.com/CHIP-Specifications/chip-test-plans/issues/4375) Because we cannot create a TH_FSA and there is
# no way to mock it the following 2 test steps are skipped for now.
self.skip_step(3)
self.skip_step(4)


if __name__ == "__main__":
default_matter_test_main()