Skip to content

Commit aa1ecd2

Browse files
cecilleandy31415
andauthored
TC-RR-1.1: Fix for pre-existing fabric removal (#32921) (#33596)
* 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 * Update src/python_testing/TC_RR_1_1.py * Address review comments, fix --------- Co-authored-by: Andrei Litvin <andy314@gmail.com>
1 parent 46e1ad8 commit aa1ecd2

File tree

1 file changed

+23
-27
lines changed

1 file changed

+23
-27
lines changed

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)

0 commit comments

Comments
 (0)