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

Function TestClusterAdminDescribeConfig

admin_test.go:878–946  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

876}
877
878func TestClusterAdminDescribeConfig(t *testing.T) {
879 seedBroker := NewMockBroker(t, 1)
880 defer seedBroker.Close()
881
882 seedBroker.SetHandlerByMap(map[string]MockResponse{
883 "MetadataRequest": NewMockMetadataResponse(t).
884 SetController(seedBroker.BrokerID()).
885 SetBroker(seedBroker.Addr(), seedBroker.BrokerID()),
886 "DescribeConfigsRequest": NewMockDescribeConfigsResponse(t),
887 })
888
889 tests := []struct {
890 saramaVersion KafkaVersion
891 requestVersion int16
892 includeSynonyms bool
893 }{
894 {V1_0_0_0, 0, false},
895 {V1_1_0_0, 1, true},
896 {V1_1_1_0, 1, true},
897 {V2_0_0_0, 2, true},
898 {V2_6_0_0, 3, true},
899 {V2_8_0_0, 4, true},
900 }
901 for _, tt := range tests {
902 t.Run(tt.saramaVersion.String(), func(t *testing.T) {
903 config := NewTestConfig()
904 config.Version = tt.saramaVersion
905 admin, err := NewClusterAdmin([]string{seedBroker.Addr()}, config)
906 if err != nil {
907 t.Fatal(err)
908 }
909 defer func() {
910 _ = admin.Close()
911 }()
912
913 resource := ConfigResource{
914 Name: "r1",
915 Type: TopicResource,
916 ConfigNames: []string{"my_topic"},
917 }
918
919 entries, err := admin.DescribeConfig(resource)
920 if err != nil {
921 t.Fatal(err)
922 }
923
924 history := seedBroker.History()
925 describeReq, ok := history[len(history)-1].Request.(*DescribeConfigsRequest)
926 if !ok {
927 t.Fatal("failed to find DescribeConfigsRequest in mockBroker history")
928 }
929
930 if describeReq.Version != tt.requestVersion {
931 t.Fatalf(
932 "requestVersion %v did not match expected %v",
933 describeReq.Version, tt.requestVersion)
934 }
935

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
SetHandlerByMapMethod · 0.95
BrokerIDMethod · 0.95
AddrMethod · 0.95
CloseMethod · 0.95
DescribeConfigMethod · 0.95
HistoryMethod · 0.95
NewMockBrokerFunction · 0.85
NewMockMetadataResponseFunction · 0.85
NewClusterAdminFunction · 0.85
SetBrokerMethod · 0.80

Tested by

no test coverage detected