Skip to content

Commit 3e5a743

Browse files
committed
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.
1 parent 739923c commit 3e5a743

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

src/python_testing/TC_RR_1_1.py

+23-24
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
#
3737

3838

39+
def generate_controller_name(fabric_index: int, controller_index: int):
40+
return f"RD{fabric_index}{str(chr(ord('A') + controller_index))}"
41+
42+
3943
class TC_RR_1_1(MatterBaseTest):
4044
def setup_class(self):
4145
self._pseudo_random_generator = random.Random(1234)
@@ -96,11 +100,6 @@ async def test_TC_RR_1_1(self):
96100
logging.info("--> User label cluster not present on any endpoitns")
97101

98102
# 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}")
104103
client_list = []
105104

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

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

125125
if num_controllers_per_fabric > 1:
@@ -130,8 +130,8 @@ async def test_TC_RR_1_1(self):
130130
privilege=Clusters.AccessControl.Enums.AccessControlEntryPrivilegeEnum.kAdminister,
131131
targetNodeId=self.dut_node_id, catTags=[0x0001_0001]
132132
)
133-
for controller in new_controllers:
134-
controller.name = all_names.pop(0)
133+
for idx, controller in enumerate(new_controllers):
134+
controller.name = generate_controller_name(fabric_index, idx+1)
135135
client_list.extend(new_controllers)
136136

137137
# Step 1c - Ensure there are no leftover fabrics from another process.
@@ -163,11 +163,12 @@ async def test_TC_RR_1_1(self):
163163
fabrics: List[Clusters.OperationalCredentials.Structs.FabricDescriptorStruct] = await self.read_single_attribute(
164164
dev_ctrl, node_id=self.dut_node_id, endpoint=0,
165165
attribute=Clusters.OperationalCredentials.Attributes.Fabrics, fabricFiltered=False)
166+
current_fabric_index = await self.read_single_attribute_check_success(cluster=Clusters.OperationalCredentials, attribute=Clusters.OperationalCredentials.Attributes.CurrentFabricIndex)
167+
print(fabrics)
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,9 @@ 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+
for fabric in fabric_table:
228229
# 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
230+
client_name = "RD%dA" % fabric.fabricIndex
231231
client = client_by_name[client_name]
232232

233233
# Send the UpdateLabel command
@@ -451,10 +451,9 @@ async def test_TC_RR_1_1(self):
451451
# Create a list of per-fabric clients to use for filling group resources accross all fabrics.
452452
fabric_unique_clients: List[Any] = []
453453

454-
for table_idx in range(len(fabric_table)):
454+
for fabric in fabric_table:
455455
# Client is client A for each fabric
456-
fabric = fabric_table[table_idx]
457-
client_name = "RD%dA" % table_idx
456+
client_name = "RD%dA" % fabric.fabricIndex
458457
fabric_unique_clients.append(client_by_name[client_name])
459458

460459
# Step 13: Write and verify indicated_max_group_keys_per_fabric group keys to all fabrics.
@@ -696,9 +695,9 @@ async def send_acl(self,
696695
enable_access_to_group_cluster: bool,
697696
fabric_table: List[
698697
Clusters.OperationalCredentials.Structs.FabricDescriptorStruct]):
699-
for table_idx, fabric in enumerate(fabric_table):
698+
for fabric in fabric_table:
700699
# Client is client A for each fabric
701-
client_name = "RD%dA" % table_idx
700+
client_name = "RD%dA" % fabric.fabricIndex
702701
client = client_by_name[client_name]
703702

704703
acl = self.build_acl(enable_access_to_group_cluster)

0 commit comments

Comments
 (0)