MCPcopy
hub / github.com/segmentio/kafka-go / TestDescribeGroupsErrorHandling

Function TestDescribeGroupsErrorHandling

describegroups_test.go:148–258  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

146}
147
148func TestDescribeGroupsErrorHandling(t *testing.T) {
149 // This test verifies that when one group has invalid metadata/assignments,
150 // it doesn't prevent other groups from being returned successfully.
151
152 // Create a mock response with multiple groups where one has invalid data.
153 mockResp := &describegroups.Response{
154 Groups: []describegroups.ResponseGroup{
155 {
156 ErrorCode: 0,
157 GroupID: "valid-group-1",
158 GroupState: "Stable",
159 ProtocolType: "consumer",
160 Members: []describegroups.ResponseGroupMember{
161 {
162 MemberID: "member-1",
163 ClientID: "client-1",
164 ClientHost: "/127.0.0.1",
165 // Valid metadata: version (int16) = 0, topics array length (int32) = 0, userdata length (int32) = 0
166 MemberMetadata: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
167 // Valid assignments: version (int16) = 0, topics array length (int32) = 0, userdata length (int32) = 0
168 MemberAssignment: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
169 },
170 },
171 },
172 {
173 ErrorCode: 0,
174 GroupID: "invalid-group",
175 GroupState: "Stable",
176 ProtocolType: "consumer",
177 Members: []describegroups.ResponseGroupMember{
178 {
179 MemberID: "member-2",
180 ClientID: "client-2",
181 ClientHost: "/127.0.0.1",
182 // Invalid metadata - truncated data
183 MemberMetadata: []byte{0x00},
184 MemberAssignment: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
185 },
186 },
187 },
188 {
189 ErrorCode: 0,
190 GroupID: "valid-group-2",
191 GroupState: "Stable",
192 ProtocolType: "consumer",
193 Members: []describegroups.ResponseGroupMember{
194 {
195 MemberID: "member-3",
196 ClientID: "client-3",
197 ClientHost: "/127.0.0.1",
198 // Valid metadata
199 MemberMetadata: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
200 // Valid assignments
201 MemberAssignment: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
202 },
203 },
204 },
205 },

Callers

nothing calls this directly

Calls 3

DescribeGroupsMethod · 0.95
TCPFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected