MCPcopy
hub / github.com/grafana/tempo / TestLeaveConsumerGroupByInstanceID_NoOp

Function TestLeaveConsumerGroupByInstanceID_NoOp

pkg/ingest/reader_client_test.go:26–45  ·  view source on GitHub ↗

TestLeaveConsumerGroupByInstanceID_NoOp verifies that an empty instanceID is a no-op: no request is sent and nil is returned.

(t *testing.T)

Source from the content-addressed store, hash-verified

24// TestLeaveConsumerGroupByInstanceID_NoOp verifies that an empty instanceID is a
25// no-op: no request is sent and nil is returned.
26func TestLeaveConsumerGroupByInstanceID_NoOp(t *testing.T) {
27 fake, err := kfake.NewCluster(kfake.NumBrokers(1), kfake.SeedTopics(1, leaveTestTopic))
28 require.NoError(t, err)
29 t.Cleanup(fake.Close)
30 addr := fake.ListenAddrs()[0]
31
32 var leaveGroupCalled atomic.Int32
33 fake.ControlKey(int16(kmsg.LeaveGroup), func(_ kmsg.Request) (kmsg.Response, error, bool) {
34 leaveGroupCalled.Inc()
35 return nil, nil, false
36 })
37
38 client, err := kgo.NewClient(kgo.SeedBrokers(addr), kgo.DisableClientMetrics())
39 require.NoError(t, err)
40 defer client.Close()
41
42 err = ingest.LeaveConsumerGroupByInstanceID(t.Context(), client, leaveTestGroup, "", log.NewNopLogger())
43 assert.NoError(t, err)
44 assert.EqualValues(t, 0, leaveGroupCalled.Load(), "LeaveGroup must not be sent for empty instanceID")
45}
46
47// TestLeaveConsumerGroupByInstanceID_SendsRequestWithInstanceID verifies that a
48// LeaveGroup request is sent to the broker and contains the correct instance ID.

Callers

nothing calls this directly

Calls 5

ControlKeyMethod · 0.95
CloseMethod · 0.95
IncMethod · 0.65
ContextMethod · 0.65

Tested by

no test coverage detected