Skip to content

Commit fb2c0e5

Browse files
raju-applececilleandy31415restyled-commits
authored
Cherry Picking commits for 1.3TH (CCBs) (#33758)
* TC-SC-3.6: Add precondition to remove extra fabrics (#33503) * TC-SC-3.6: Add precondition to remove extra fabrics Before commissioning the other fabrics, remove pre-existing fabrics from the device because the TH does not have the ability to check for subscriptions from them. Note that this change means that any pre-exisiting fabrics on the device WILL NOT BE THERE after this test. This is the same behaviour as in RR-1.1. Test: Tested against all-clusters app. chip-tool pairing onnetwork-long 0x12344321 20202021 3840 chip-tool pairing open-commissioning-window 0x12344321 0 900 10000 3840 python src/python_testing/TC_SC_3_6.py --commissioning-method on-network \ --discriminator 3840 --passcode 20202021 Results (only relevant logs): [MatterTest] 05-17 07:54:32.981 INFO Pre-condition: Remove all pre-existing fabrics on the device that do not belong to the TH ... [MatterTest] 05-17 07:54:32.994 INFO Removing extra fabric at 1 from device. ... INFO:root:Final result: PASS ! * add missing import * TC-RR-1.1: Fix for pre-existing fabric removal (#32921) * TC-RR-1.1: Fix for pre-existing fabric removal This test assumed that the client ordering matched to the ordering of the fabric table, but this is not the case if there is a fabric on the device before the test starts. In this case, the initial fabric is in table slot 1 with index 1, the test starts in table slot 2, with fabric index 2. Then the initial fabric is removed from table slot 1, and the test adds a new fabric. The new fabric is allocated fabric index 3, but appears in slot 1 in the table, and the order between the controllers and the fabric table as read off the device is now out of sync. Instead, name the controllers based on the fabric index rather than the index in the fabric table. TEST: commissioned all-clusters using chip-tool then ran RR-1.1. Test now passes, whereas before there was a failure. * Update src/python_testing/TC_RR_1_1.py Co-authored-by: Andrei Litvin <andy314@gmail.com> * Update src/python_testing/TC_RR_1_1.py * Address review comments, fix --------- Co-authored-by: Andrei Litvin <andy314@gmail.com> * TC-OPCREDS-3.7: support DUTs with existing fabrics (#33511) * TC-OPCREDS-3.7: support DUTs with existing fabrics * Restyled by prettier-yaml --------- Co-authored-by: Restyled.io <commits@restyled.io> --------- Co-authored-by: C Freeman <cecille@google.com> Co-authored-by: Andrei Litvin <andy314@gmail.com> Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 7dbf446 commit fb2c0e5

File tree

3 files changed

+63
-39
lines changed

3 files changed

+63
-39
lines changed

src/app/tests/suites/certification/Test_TC_OPCREDS_3_7.yaml

+21-12
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,14 @@ tests:
6565
saveAs: TH1_Fabric_Index
6666

6767
- label:
68-
"Step 3.2: TH1 does a non-fabric-filtered read of the Fabrics
69-
attribute from the Node Operational Credentials cluster. Save the
70-
FabricIndex for TH1 as TH1_Fabric_Index for future use."
71-
PICS: OPCREDS.S.A0001
68+
"Step 3.2: TH1 does a fabric-filtered read of the Fabrics attribute
69+
from the Node Operational Credentials cluster. Save the FabricIndex
70+
for TH1 as TH1_Fabric_Index for future use."
7271
identity: "alpha"
7372
command: "readAttribute"
7473
cluster: "Operational Credentials"
7574
attribute: "Fabrics"
76-
fabricFiltered: false
75+
fabricFiltered: true
7776
response:
7877
value: [{ "FabricIndex": TH1_Fabric_Index, "Label": "" }]
7978
constraints:
@@ -251,21 +250,31 @@ tests:
251250

252251
# verification: ""
253252
- label:
254-
"Step 13: TH2 does a non-fabric-filtered read of the Fabrics attribute
253+
"Step 13a: TH1 does a fabric-filtered read of the Fabrics attribute
254+
from the Node Operational Credentials cluster"
255+
nodeId: 0x43211234
256+
command: "readAttribute"
257+
cluster: "Operational Credentials"
258+
attribute: "Fabrics"
259+
fabricFiltered: true
260+
response:
261+
value: [{ "FabricIndex": TH1_Fabric_Index, "Label": "" }]
262+
constraints:
263+
type: list
264+
265+
# verification: ""
266+
- label:
267+
"Step 13b: TH2 does a fabric-filtered read of the Fabrics attribute
255268
from the Node Operational Credentials cluster"
256269
PICS: OPCREDS.S.A0001
257270
identity: "beta"
258271
nodeId: 0x43211234
259272
command: "readAttribute"
260273
cluster: "Operational Credentials"
261274
attribute: "Fabrics"
262-
fabricFiltered: false
275+
fabricFiltered: true
263276
response:
264-
value:
265-
[
266-
{ "FabricIndex": TH1_Fabric_Index, "Label": "" },
267-
{ "FabricIndex": TH2_Fabric_Index, "Label": "" },
268-
]
277+
value: [{ "FabricIndex": TH2_Fabric_Index, "Label": "" }]
269278
constraints:
270279
type: list
271280

src/python_testing/TC_RR_1_1.py

+23-27
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import math
2121
import queue
2222
import random
23+
import string
2324
import time
2425
from typing import Any, Dict, List, Set
2526

@@ -36,6 +37,10 @@
3637
#
3738

3839

40+
def generate_controller_name(fabric_index: int, controller_index: int):
41+
return f"RD{fabric_index}{string.ascii_uppercase[controller_index]}"
42+
43+
3944
class TC_RR_1_1(MatterBaseTest):
4045
def setup_class(self):
4146
self._pseudo_random_generator = random.Random(1234)
@@ -96,11 +101,6 @@ async def test_TC_RR_1_1(self):
96101
logging.info("--> User label cluster not present on any endpoitns")
97102

98103
# Generate list of all clients names
99-
all_names = []
100-
for fabric_idx in range(num_fabrics_to_commission):
101-
for controller_idx in range(num_controllers_per_fabric):
102-
all_names.append("RD%d%s" % (fabric_idx, chr(ord('A') + controller_idx)))
103-
logging.info(f"Client names that will be used: {all_names}")
104104
client_list = []
105105

106106
# TODO: Shall we also verify SupportedFabrics attribute, and the CapabilityMinima attribute?
@@ -119,7 +119,8 @@ async def test_TC_RR_1_1(self):
119119
node_ids = [200 + (i * 100) for i in range(num_controllers_per_fabric - 1)]
120120

121121
# Prepare clients for first fabric, that includes the default controller
122-
dev_ctrl.name = all_names.pop(0)
122+
fabric_index = await self.read_single_attribute_check_success(cluster=Clusters.OperationalCredentials, attribute=Clusters.OperationalCredentials.Attributes.CurrentFabricIndex, dev_ctrl=dev_ctrl)
123+
dev_ctrl.name = generate_controller_name(fabric_index, 0)
123124
client_list.append(dev_ctrl)
124125

125126
if num_controllers_per_fabric > 1:
@@ -130,8 +131,8 @@ async def test_TC_RR_1_1(self):
130131
privilege=Clusters.AccessControl.Enums.AccessControlEntryPrivilegeEnum.kAdminister,
131132
targetNodeId=self.dut_node_id, catTags=[0x0001_0001]
132133
)
133-
for controller in new_controllers:
134-
controller.name = all_names.pop(0)
134+
for idx, controller in enumerate(new_controllers):
135+
controller.name = generate_controller_name(fabric_index, idx+1)
135136
client_list.extend(new_controllers)
136137

137138
# Step 1c - Ensure there are no leftover fabrics from another process.
@@ -163,11 +164,11 @@ async def test_TC_RR_1_1(self):
163164
fabrics: List[Clusters.OperationalCredentials.Structs.FabricDescriptorStruct] = await self.read_single_attribute(
164165
dev_ctrl, node_id=self.dut_node_id, endpoint=0,
165166
attribute=Clusters.OperationalCredentials.Attributes.Fabrics, fabricFiltered=False)
167+
current_fabric_index = await self.read_single_attribute_check_success(cluster=Clusters.OperationalCredentials, attribute=Clusters.OperationalCredentials.Attributes.CurrentFabricIndex)
166168
for fabric in fabrics:
167-
if fabric.fabricID == dev_ctrl.fabricId:
169+
if fabric.fabricIndex == current_fabric_index:
168170
continue
169-
170-
# This is not the initial client's fabric, so remove it.
171+
# This is not the test client's fabric, so remove it.
171172
await dev_ctrl.SendCommand(
172173
self.dut_node_id, 0, Clusters.OperationalCredentials.Commands.RemoveFabric(fabricIndex=fabric.fabricIndex))
173174

@@ -184,13 +185,13 @@ async def test_TC_RR_1_1(self):
184185
new_fabric_admin = new_certificate_authority.NewFabricAdmin(vendorId=0xFFF1, fabricId=admin_index)
185186

186187
new_admin_ctrl = new_fabric_admin.NewController(nodeId=dev_ctrl.nodeId, catTags=[0x0001_0001])
187-
new_admin_ctrl.name = all_names.pop(0)
188-
client_list.append(new_admin_ctrl)
189188
await CommissioningBuildingBlocks.AddNOCForNewFabricFromExisting(commissionerDevCtrl=dev_ctrl,
190189
newFabricDevCtrl=new_admin_ctrl,
191190
existingNodeId=self.dut_node_id,
192191
newNodeId=self.dut_node_id)
193-
192+
fabric_index = await self.read_single_attribute_check_success(cluster=Clusters.OperationalCredentials, attribute=Clusters.OperationalCredentials.Attributes.CurrentFabricIndex, dev_ctrl=new_admin_ctrl)
193+
new_admin_ctrl.name = generate_controller_name(fabric_index, 0)
194+
client_list.append(new_admin_ctrl)
194195
if num_controllers_per_fabric > 1:
195196
new_controllers = await CommissioningBuildingBlocks.CreateControllersOnFabric(
196197
fabricAdmin=new_fabric_admin,
@@ -200,8 +201,8 @@ async def test_TC_RR_1_1(self):
200201
targetNodeId=self.dut_node_id,
201202
catTags=[0x0001_0001]
202203
)
203-
for controller in new_controllers:
204-
controller.name = all_names.pop(0)
204+
for idx, controller in enumerate(new_controllers):
205+
controller.name = generate_controller_name(fabric_index, idx+1)
205206

206207
client_list.extend(new_controllers)
207208

@@ -224,10 +225,8 @@ async def test_TC_RR_1_1(self):
224225
# Step 2: Set the Label field for each fabric and BasicInformation.NodeLabel to 32 characters
225226
logging.info("Step 2: Setting the Label field for each fabric and BasicInformation.NodeLabel to 32 characters")
226227

227-
for table_idx in range(len(fabric_table)):
228-
# Client is client A for each fabric to set the Label field
229-
fabric = fabric_table[table_idx]
230-
client_name = "RD%dA" % table_idx
228+
for fabric in fabric_table:
229+
client_name = generate_controller_name(fabric.fabricIndex, 0)
231230
client = client_by_name[client_name]
232231

233232
# Send the UpdateLabel command
@@ -451,10 +450,8 @@ async def test_TC_RR_1_1(self):
451450
# Create a list of per-fabric clients to use for filling group resources accross all fabrics.
452451
fabric_unique_clients: List[Any] = []
453452

454-
for table_idx in range(len(fabric_table)):
455-
# Client is client A for each fabric
456-
fabric = fabric_table[table_idx]
457-
client_name = "RD%dA" % table_idx
453+
for fabric in fabric_table:
454+
client_name = generate_controller_name(fabric.fabricIndex, 0)
458455
fabric_unique_clients.append(client_by_name[client_name])
459456

460457
# Step 13: Write and verify indicated_max_group_keys_per_fabric group keys to all fabrics.
@@ -696,9 +693,8 @@ async def send_acl(self,
696693
enable_access_to_group_cluster: bool,
697694
fabric_table: List[
698695
Clusters.OperationalCredentials.Structs.FabricDescriptorStruct]):
699-
for table_idx, fabric in enumerate(fabric_table):
700-
# Client is client A for each fabric
701-
client_name = "RD%dA" % table_idx
696+
for fabric in fabric_table:
697+
client_name = generate_controller_name(fabric.fabricIndex, 0)
702698
client = client_by_name[client_name]
703699

704700
acl = self.build_acl(enable_access_to_group_cluster)

src/python_testing/TC_SC_3_6.py

+19
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import queue
2121
import time
2222
from threading import Event
23+
from typing import List
2324

2425
import chip.clusters as Clusters
2526
from chip.clusters import ClusterObjects as ClustersObjects
@@ -123,6 +124,24 @@ async def test_TC_SC_3_6(self):
123124
)
124125
asserts.assert_greater_equal(capability_minima.caseSessionsPerFabric, 3)
125126

127+
logging.info("Pre-condition: Remove all pre-existing fabrics on the device that do not belong to the TH")
128+
commissioned_fabric_count: int = await self.read_single_attribute(
129+
dev_ctrl, node_id=self.dut_node_id,
130+
endpoint=0, attribute=Clusters.OperationalCredentials.Attributes.CommissionedFabrics)
131+
132+
if commissioned_fabric_count > 1:
133+
fabrics: List[Clusters.OperationalCredentials.Structs.FabricDescriptorStruct] = await self.read_single_attribute(
134+
dev_ctrl, node_id=self.dut_node_id, endpoint=0,
135+
attribute=Clusters.OperationalCredentials.Attributes.Fabrics, fabricFiltered=False)
136+
current_fabric_index = await self.read_single_attribute_check_success(cluster=Clusters.OperationalCredentials, attribute=Clusters.OperationalCredentials.Attributes.CurrentFabricIndex)
137+
for fabric in fabrics:
138+
if fabric.fabricIndex == current_fabric_index:
139+
continue
140+
# This is not the test client's fabric, so remove it.
141+
logging.info(f"Removing extra fabric at {fabric.fabricIndex} from device.")
142+
await dev_ctrl.SendCommand(
143+
self.dut_node_id, 0, Clusters.OperationalCredentials.Commands.RemoveFabric(fabricIndex=fabric.fabricIndex))
144+
126145
logging.info("Pre-conditions: use existing fabric to configure new fabrics so that total is %d fabrics" %
127146
num_fabrics_to_commission)
128147

0 commit comments

Comments
 (0)