github.com/rbisecke/kafka-go@v0.4.27/describeconfigs_test.go (about) 1 package kafka 2 3 import ( 4 "context" 5 "testing" 6 7 ktesting "github.com/rbisecke/kafka-go/testing" 8 "github.com/stretchr/testify/assert" 9 ) 10 11 func TestClientDescribeConfigs(t *testing.T) { 12 if !ktesting.KafkaIsAtLeast("0.11.0") { 13 return 14 } 15 16 const ( 17 MaxMessageBytes = "max.message.bytes" 18 MaxMessageBytesValue = "200000" 19 ) 20 21 client, shutdown := newLocalClient() 22 defer shutdown() 23 24 topic := makeTopic() 25 createTopic(t, topic, 1) 26 defer deleteTopic(t, topic) 27 28 _, err := client.AlterConfigs(context.Background(), &AlterConfigsRequest{ 29 Resources: []AlterConfigRequestResource{{ 30 ResourceType: ResourceTypeTopic, 31 ResourceName: topic, 32 Configs: []AlterConfigRequestConfig{{ 33 Name: MaxMessageBytes, 34 Value: MaxMessageBytesValue, 35 }, 36 }, 37 }}, 38 }) 39 40 if err != nil { 41 t.Fatal(err) 42 } 43 44 describeResp, err := client.DescribeConfigs(context.Background(), &DescribeConfigsRequest{ 45 Resources: []DescribeConfigRequestResource{{ 46 ResourceType: ResourceTypeTopic, 47 ResourceName: topic, 48 ConfigNames: []string{MaxMessageBytes}, 49 }}, 50 }) 51 52 maxMessageBytesValue := "0" 53 for _, resource := range describeResp.Resources { 54 if resource.ResourceType == int8(ResourceTypeTopic) && resource.ResourceName == topic { 55 for _, entry := range resource.ConfigEntries { 56 if entry.ConfigName == MaxMessageBytes { 57 maxMessageBytesValue = entry.ConfigValue 58 } 59 } 60 } 61 } 62 assert.Equal(t, maxMessageBytesValue, MaxMessageBytesValue) 63 }