Skip to content

Commit bf354ec

Browse files
[Groupcast] Align GroupDataProvider limits with membership count (project-chip#43167)
* Update GroupDataProvider Constructor, the Max group per fabric and Max keys per fabric configurations inline with groupcast definitions. Add a unit test for LeaveGroup 0 (ALL) command * Add explicit constructor in the MockGroupDataProvider * Update all-cluster-app config to set CHIP_CONFIG_MAX_GROUPCAST_MEMBERSHIP_COUNT at 24 for backward compatibility of test TestGroupKeyManagementCluster that still usese Groups cluster. Add one additinal key creation in the test inline with groupdataprovider changes. * Restyled by whitespace * Update KeySetWrite command in yaml inline with changes on master --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent d5b7185 commit bf354ec

13 files changed

Lines changed: 99 additions & 14 deletions

File tree

examples/all-clusters-app/infineon/psoc6/include/CHIPProjectConfig.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@
109109
// CHIP_CONFIG_MAX_GROUPS_PER_FABRIC is properly configured.
110110
#define CHIP_CONFIG_MAX_GROUP_ENDPOINTS_PER_FABRIC 3
111111

112+
// Temporary set MaxMembershipCount to 24 for all-cluster-app due to hardcoded TestGroupKeyManagementCluster.yaml
113+
// Where 12 group are created on a single fabric with the group clusters.
114+
// TODO cleanup this config #43166
115+
#define CHIP_CONFIG_MAX_GROUPCAST_MEMBERSHIP_COUNT 24
116+
112117
// Enable `Extension` attribute of ACL Cluster
113118
#ifndef CHIP_CONFIG_ENABLE_ACL_EXTENSIONS
114119
#define CHIP_CONFIG_ENABLE_ACL_EXTENSIONS 1

examples/all-clusters-app/linux/include/CHIPProjectAppConfig.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
// CHIP_CONFIG_MAX_GROUPS_PER_FABRIC is properly configured.
4040
#define CHIP_CONFIG_MAX_GROUP_ENDPOINTS_PER_FABRIC 3
4141

42+
// Temporary set MaxMembershipCount to 24 for all-cluster-app due to hardcoded TestGroupKeyManagementCluster.yaml
43+
// Where 12 group are created on a single fabric with the group clusters.
44+
// TODO cleanup this config #43166
45+
#define CHIP_CONFIG_MAX_GROUPCAST_MEMBERSHIP_COUNT 24
46+
4247
// Allows app options (ports) to be configured on launch of app
4348
#define CHIP_DEVICE_ENABLE_PORT_PARAMS 1
4449

examples/all-clusters-app/nrfconnect/main/include/CHIPProjectConfig.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,9 @@
3030
// CHIP_CONFIG_MAX_GROUPS_PER_FABRIC is properly configured.
3131
#define CHIP_CONFIG_MAX_GROUP_ENDPOINTS_PER_FABRIC 3
3232

33+
// Temporary set MaxMembershipCount to 24 for all-cluster-app due to hardcoded TestGroupKeyManagementCluster.yaml
34+
// Where 12 group are created on a single fabric with the group clusters.
35+
// TODO cleanup this config #43166
36+
#define CHIP_CONFIG_MAX_GROUPCAST_MEMBERSHIP_COUNT 24
37+
3338
#define CHIP_CONFIG_ENABLE_ACL_EXTENSIONS 1

examples/all-clusters-app/nxp/zephyr/main/include/CHIPProjectConfig.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,9 @@
3030
// CHIP_CONFIG_MAX_GROUPS_PER_FABRIC is properly configured.
3131
#define CHIP_CONFIG_MAX_GROUP_ENDPOINTS_PER_FABRIC 3
3232

33+
// Temporary set MaxMembershipCount to 24 for all-cluster-app due to hardcoded TestGroupKeyManagementCluster.yaml
34+
// Where 12 group are created on a single fabric with the group clusters.
35+
// TODO cleanup this config #43166
36+
#define CHIP_CONFIG_MAX_GROUPCAST_MEMBERSHIP_COUNT 24
37+
3338
#define CHIP_CONFIG_ENABLE_ACL_EXTENSIONS 1

examples/all-clusters-app/telink/include/CHIPProjectConfig.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,9 @@
3535
// CHIP_CONFIG_MAX_GROUPS_PER_FABRIC is properly configured.
3636
#define CHIP_CONFIG_MAX_GROUP_ENDPOINTS_PER_FABRIC 3
3737

38+
// Temporary set MaxMembershipCount to 24 for all-cluster-app due to hardcoded TestGroupKeyManagementCluster.yaml
39+
// Where 12 group are created on a single fabric with the group clusters.
40+
// TODO cleanup this config #43166
41+
#define CHIP_CONFIG_MAX_GROUPCAST_MEMBERSHIP_COUNT 24
42+
3843
#define CHIP_CONFIG_ENABLE_ACL_EXTENSIONS 1

examples/all-clusters-app/tizen/include/CHIPProjectAppConfig.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
// CHIP_CONFIG_MAX_GROUPS_PER_FABRIC is properly configured.
3535
#define CHIP_CONFIG_MAX_GROUP_ENDPOINTS_PER_FABRIC 3
3636

37+
// Temporary set MaxMembershipCount to 24 for all-cluster-app due to hardcoded TestGroupKeyManagementCluster.yaml
38+
// Where 12 group are created on a single fabric with the group clusters.
39+
// TODO cleanup this config #43166
40+
#define CHIP_CONFIG_MAX_GROUPCAST_MEMBERSHIP_COUNT 24
41+
3742
// Claim a device type while advertising that matches the device type on our
3843
// endpoint 1. 0x0101 is the "Dimmable Light" device type.
3944
#define CHIP_DEVICE_CONFIG_DEVICE_TYPE 0x0101

src/app/clusters/groupcast/tests/TestGroupcastCluster.cpp

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ TEST_F(TestGroupcastCluster, TestLeaveGroup)
369369
chip::Testing::ClusterTester tester(mListener);
370370
tester.SetFabricIndex(kTestFabricIndex);
371371

372-
// Join grojups
372+
// Join groups
373373
{
374374
// Group 1
375375
Commands::JoinGroup::Type data;
@@ -494,11 +494,10 @@ TEST_F(TestGroupcastCluster, TestLeaveGroup)
494494
}
495495
}
496496

497-
// LeaveGroup (all)
497+
// LeaveGroup a List of endpoints from all groups
498498
{
499499
Commands::LeaveGroup::Type data;
500500

501-
// Update existing key (invalid)
502501
data.groupID = 0;
503502
data.endpoints =
504503
MakeOptional(chip::app::DataModel::List<const EndpointId>(kLeaveEndpoints2, MATTER_ARRAY_SIZE(kLeaveEndpoints2)));
@@ -547,6 +546,26 @@ TEST_F(TestGroupcastCluster, TestLeaveGroup)
547546
group_id++;
548547
}
549548
}
549+
550+
// LeaveGroup all groups completely.
551+
{
552+
Commands::LeaveGroup::Type data;
553+
data.groupID = 0;
554+
auto result = tester.Invoke(Commands::LeaveGroup::Id, data);
555+
ASSERT_TRUE(result.status.has_value());
556+
EXPECT_EQ(result.status.value().GetStatusCode().GetStatus(), // NOLINT(bugprone-unchecked-optional-access)
557+
Protocols::InteractionModel::Status::Success);
558+
}
559+
560+
// Read Membership
561+
{
562+
app::Clusters::Groupcast::Attributes::Membership::TypeInfo::DecodableType memberships;
563+
ASSERT_EQ(tester.ReadAttribute(Attributes::Membership::Id, memberships), CHIP_NO_ERROR);
564+
565+
size_t memershipCount = 0;
566+
ASSERT_EQ(CountListElements(memberships, memershipCount), CHIP_NO_ERROR);
567+
ASSERT_EQ(memershipCount, 0u);
568+
}
550569
}
551570

552571
TEST_F(TestGroupcastCluster, TestUpdateGroupKey)

src/app/clusters/scenes-server/tests/TestScenesManagementCluster.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ class MockSceneHandler : public scenes::SceneHandler
165165
class MockGroupDataProvider : public GroupDataProvider
166166
{
167167
public:
168+
MockGroupDataProvider() : GroupDataProvider(0, 0) {}
168169
CHIP_ERROR Init() override { return CHIP_NO_ERROR; }
169170
void Finish() override {}
170171
CHIP_ERROR SetGroupInfo(FabricIndex, const GroupInfo &) override { return CHIP_NO_ERROR; }

src/app/tests/suites/TestGroupKeyManagementCluster.yaml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,10 @@ tests:
608608
# Note: There's always an IPK keyset with index 0
609609
contains: [0x01a1, 0x01a2, 0]
610610

611-
- label: "Write one keyset too many when already full"
611+
# TODO: This is really hardcoded based on the default value of CHIP_CONFIG_MAX_GROUP_KEYS_PER_FABRIC.
612+
# Logic should be added to handle configurations variability.
613+
# To do so, this whole test should be moved to python tests for better flexibility.
614+
- label: "Write additional KeySets to reach fabric 1 capacity"
612615
command: "KeySetWrite"
613616
arguments:
614617
values:
@@ -625,6 +628,24 @@ tests:
625628
EpochStartTime2: 3110002,
626629
GroupKeyMulticastPolicy: 0,
627630
}
631+
632+
- label: "Write one keyset too many when already full"
633+
command: "KeySetWrite"
634+
arguments:
635+
values:
636+
- name: "GroupKeySet"
637+
value:
638+
{
639+
GroupKeySetID: 0x0333,
640+
GroupKeySecurityPolicy: 0,
641+
EpochKey0: "\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf",
642+
EpochStartTime0: 3110000,
643+
EpochKey1: "\xe1\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef",
644+
EpochStartTime1: 3110001,
645+
EpochKey2: "\xf1\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
646+
EpochStartTime2: 3110002,
647+
GroupKeyMulticastPolicy: 0,
648+
}
628649
response:
629650
error: RESOURCE_EXHAUSTED
630651

src/controller/python/BUILD.gn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ shared_library("ChipDeviceCtrl") {
105105
]
106106
}
107107
defines += [ "CHIP_CONFIG_MAX_ACTIVE_TCP_CONNECTIONS=20" ]
108-
defines += [ "CHIP_CONFIG_MAX_GROUPS_PER_FABRIC=50" ]
109108
defines += [ "CHIP_CONFIG_MAX_GROUP_KEYS_PER_FABRIC=50" ]
109+
defines += [ "CHIP_CONFIG_MAX_GROUPCAST_MEMBERSHIP_COUNT=100" ]
110110

111111
if (chip_python_supports_stack_locking) {
112112
sources += [ "matter/native/ChipMainLoopWork_StackLock.cpp" ]

0 commit comments

Comments
 (0)