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

Function TestClientLeaveGroup

leavegroup_test.go:13–191  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestClientLeaveGroup(t *testing.T) {
14 // In order to get to a leave group call we need to first
15 // join a group then sync the group.
16 topic := makeTopic()
17 client, shutdown := newLocalClient()
18 client.Timeout = time.Minute
19 // Although at higher api versions ClientID is nullable
20 // for some reason the SyncGroup API call errors
21 // when ClientID is null.
22 // The Java Kafka Consumer generates a ClientID if one is not
23 // present or if the provided ClientID is empty.
24 client.Transport.(*Transport).ClientID = "test-client"
25 defer shutdown()
26
27 err := clientCreateTopic(client, topic, 3)
28 if err != nil {
29 t.Fatal(err)
30 }
31
32 groupID := makeGroupID()
33
34 ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
35 defer cancel()
36 respc, err := waitForCoordinatorIndefinitely(ctx, client, &FindCoordinatorRequest{
37 Addr: client.Addr,
38 Key: groupID,
39 KeyType: CoordinatorKeyTypeConsumer,
40 })
41 if err != nil {
42 t.Fatal(err)
43 }
44
45 if respc.Error != nil {
46 t.Fatal(err)
47 }
48
49 groupInstanceID := "group-instance-id"
50 userData := "user-data"
51
52 var rrGroupBalancer RoundRobinGroupBalancer
53
54 req := &JoinGroupRequest{
55 GroupID: groupID,
56 GroupInstanceID: groupInstanceID,
57 ProtocolType: "consumer",
58 SessionTimeout: time.Minute,
59 RebalanceTimeout: time.Minute,
60 Protocols: []GroupProtocol{
61 {
62 Name: rrGroupBalancer.ProtocolName(),
63 Metadata: GroupProtocolSubscription{
64 Topics: []string{topic},
65 UserData: []byte(userData),
66 OwnedPartitions: map[string][]int{
67 topic: {0, 1, 2},
68 },
69 },
70 },

Callers

nothing calls this directly

Calls 11

ProtocolNameMethod · 0.95
AssignGroupsMethod · 0.95
makeGroupIDFunction · 0.85
JoinGroupMethod · 0.80
MetadataMethod · 0.80
SyncGroupMethod · 0.80
LeaveGroupMethod · 0.80
makeTopicFunction · 0.70
newLocalClientFunction · 0.70
clientCreateTopicFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…