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

Function TestClusterAdminDescribeConfigs

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

Source from the content-addressed store, hash-verified

946}
947
948func TestClusterAdminDescribeConfigs(t *testing.T) {
949 seedBroker := NewMockBroker(t, 1)
950 defer seedBroker.Close()
951
952 seedBroker.SetHandlerByMap(map[string]MockResponse{
953 "MetadataRequest": NewMockMetadataResponse(t).
954 SetController(seedBroker.BrokerID()).
955 SetBroker(seedBroker.Addr(), seedBroker.BrokerID()),
956 "DescribeConfigsRequest": NewMockDescribeConfigsResponse(t),
957 })
958
959 config := NewTestConfig()
960 config.Version = V2_8_0_0
961 admin, err := NewClusterAdmin([]string{seedBroker.Addr()}, config)
962 require.NoError(t, err)
963 defer func() { _ = admin.Close() }()
964
965 resources := []*ConfigResource{
966 {Name: "r1", Type: TopicResource, ConfigNames: []string{"my_topic"}},
967 {Name: "r2", Type: TopicResource, ConfigNames: []string{"my_topic"}},
968 }
969
970 results, err := admin.DescribeConfigs(resources, DescribeConfigsOptions{
971 IncludeSynonyms: true,
972 IncludeDocumentation: true,
973 })
974 require.NoError(t, err)
975 require.Len(t, results, 2)
976 assert.Equal(t, "r1", results[0].Name)
977 assert.Equal(t, "r2", results[1].Name)
978 for _, result := range results {
979 assert.Equal(t, ErrNoError, result.ErrorCode)
980 assert.NotEmpty(t, result.Configs)
981 }
982
983 history := seedBroker.History()
984 describeReq, ok := history[len(history)-1].Request.(*DescribeConfigsRequest)
985 require.True(t, ok, "failed to find DescribeConfigsRequest in mockBroker history")
986 assert.Equal(t, int16(4), describeReq.Version)
987 assert.True(t, describeReq.IncludeSynonyms)
988 assert.True(t, describeReq.IncludeDocumentation)
989 assert.Len(t, describeReq.Resources, 2)
990}
991
992func TestClusterAdminDescribeConfigWithErrorCode(t *testing.T) {
993 seedBroker := NewMockBroker(t, 1)

Callers

nothing calls this directly

Calls 15

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

Tested by

no test coverage detected