MCPcopy
hub / github.com/IBM/sarama / TestFuncAdminDescribeGroups

Function TestFuncAdminDescribeGroups

functional_admin_test.go:268–324  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

266}
267
268func TestFuncAdminDescribeGroups(t *testing.T) {
269 t.Parallel()
270 checkKafkaVersion(t, "2.3.0.0")
271 setupFunctionalTest(t)
272 defer teardownFunctionalTest(t)
273
274 group1 := testFuncConsumerGroupID(t)
275 group2 := testFuncConsumerGroupID(t)
276
277 kafkaVersion, err := ParseKafkaVersion(FunctionalTestEnv.KafkaVersion)
278 if err != nil {
279 t.Fatal(err)
280 }
281
282 config := NewFunctionalTestConfig()
283 config.Version = kafkaVersion
284 adminClient, err := NewClusterAdmin(FunctionalTestEnv.KafkaBrokerAddrs, config)
285 if err != nil {
286 t.Fatal(err)
287 }
288 defer safeClose(t, adminClient)
289
290 config1 := NewFunctionalTestConfig()
291 config1.ClientID = "M1"
292 config1.Version = V2_3_0_0
293 config1.Consumer.Offsets.Initial = OffsetNewest
294 m1 := runTestFuncConsumerGroupMemberWithConfig(t, config1, group1, 100, nil, "test.4")
295 defer m1.Close()
296
297 config2 := NewFunctionalTestConfig()
298 config2.ClientID = "M2"
299 config2.Version = V2_3_0_0
300 config2.Consumer.Offsets.Initial = OffsetNewest
301 config2.Consumer.Group.InstanceId = "Instance2"
302 m2 := runTestFuncConsumerGroupMemberWithConfig(t, config2, group2, 100, nil, "test.4")
303 defer m2.Close()
304
305 m1.WaitForState(2)
306 m2.WaitForState(2)
307
308 res, err := adminClient.DescribeConsumerGroups([]string{group1, group2})
309 if err != nil {
310 t.Fatal(err)
311 }
312 if len(res) != 2 {
313 t.Errorf("group description should be 2, got %v\n", len(res))
314 }
315 if len(res[0].Members) != 1 {
316 t.Errorf("should have 1 members in group , got %v\n", len(res[0].Members))
317 }
318 if len(res[1].Members) != 1 {
319 t.Errorf("should have 1 members in group , got %v\n", len(res[1].Members))
320 }
321
322 m1.AssertCleanShutdown()
323 m2.AssertCleanShutdown()
324}
325

Callers

nothing calls this directly

Calls 15

checkKafkaVersionFunction · 0.85
setupFunctionalTestFunction · 0.85
teardownFunctionalTestFunction · 0.85
testFuncConsumerGroupIDFunction · 0.85
ParseKafkaVersionFunction · 0.85
NewFunctionalTestConfigFunction · 0.85
NewClusterAdminFunction · 0.85
FatalMethod · 0.80
WaitForStateMethod · 0.80
AssertCleanShutdownMethod · 0.80

Tested by

no test coverage detected