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

Function TestClientAlterClientQuotas

alterclientquotas_test.go:12–110  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestClientAlterClientQuotas(t *testing.T) {
13 // Added in Version 2.6.0 https://issues.apache.org/jira/browse/KAFKA-7740
14 if !ktesting.KafkaIsAtLeast("2.6.0") {
15 return
16 }
17
18 const (
19 entityType = "client-id"
20 entityName = "my-client-id"
21 key = "producer_byte_rate"
22 value = 500000.0
23 )
24
25 client, shutdown := newLocalClient()
26 defer shutdown()
27
28 alterResp, err := client.AlterClientQuotas(context.Background(), &AlterClientQuotasRequest{
29 Entries: []AlterClientQuotaEntry{
30 {
31 Entities: []AlterClientQuotaEntity{
32 {
33 EntityType: entityType,
34 EntityName: entityName,
35 },
36 },
37 Ops: []AlterClientQuotaOps{
38 {
39 Key: key,
40 Value: value,
41 Remove: false,
42 },
43 },
44 },
45 },
46 })
47
48 if err != nil {
49 t.Fatal(err)
50 }
51
52 expectedAlterResp := AlterClientQuotasResponse{
53 Throttle: 0,
54 Entries: []AlterClientQuotaResponseQuotas{
55 {
56 Error: makeError(0, ""),
57 Entities: []AlterClientQuotaEntity{
58 {
59 EntityName: entityName,
60 EntityType: entityType,
61 },
62 },
63 },
64 },
65 }
66
67 assert.Equal(t, expectedAlterResp, *alterResp)
68
69 // kraft mode is slow

Callers

nothing calls this directly

Calls 4

makeErrorFunction · 0.85
AlterClientQuotasMethod · 0.80
DescribeClientQuotasMethod · 0.80
newLocalClientFunction · 0.70

Tested by

no test coverage detected