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

Function TestClusterAdminDescribeBrokerConfig

admin_test.go:1027–1075  ·  view source on GitHub ↗

TestClusterAdminDescribeBrokerConfig ensures that a describe broker config is sent to the broker in the resource struct, _not_ the controller

(t *testing.T)

Source from the content-addressed store, hash-verified

1025// TestClusterAdminDescribeBrokerConfig ensures that a describe broker config
1026// is sent to the broker in the resource struct, _not_ the controller
1027func TestClusterAdminDescribeBrokerConfig(t *testing.T) {
1028 controllerBroker := NewMockBroker(t, 1)
1029 defer controllerBroker.Close()
1030 configBroker := NewMockBroker(t, 2)
1031 defer configBroker.Close()
1032
1033 controllerBroker.SetHandlerByMap(map[string]MockResponse{
1034 "MetadataRequest": NewMockMetadataResponse(t).
1035 SetController(controllerBroker.BrokerID()).
1036 SetBroker(controllerBroker.Addr(), controllerBroker.BrokerID()).
1037 SetBroker(configBroker.Addr(), configBroker.BrokerID()),
1038 })
1039
1040 configBroker.SetHandlerByMap(map[string]MockResponse{
1041 "MetadataRequest": NewMockMetadataResponse(t).
1042 SetController(controllerBroker.BrokerID()).
1043 SetBroker(controllerBroker.Addr(), controllerBroker.BrokerID()).
1044 SetBroker(configBroker.Addr(), configBroker.BrokerID()),
1045 "DescribeConfigsRequest": NewMockDescribeConfigsResponse(t),
1046 })
1047
1048 config := NewTestConfig()
1049 config.Version = V1_0_0_0
1050 admin, err := NewClusterAdmin(
1051 []string{
1052 controllerBroker.Addr(),
1053 configBroker.Addr(),
1054 }, config)
1055 if err != nil {
1056 t.Fatal(err)
1057 }
1058
1059 for _, resourceType := range []ConfigResourceType{BrokerResource, BrokerLoggerResource} {
1060 resource := ConfigResource{Name: "2", Type: resourceType}
1061 entries, err := admin.DescribeConfig(resource)
1062 if err != nil {
1063 t.Fatal(err)
1064 }
1065
1066 if len(entries) == 0 {
1067 t.Fatal(errors.New("no resource present"))
1068 }
1069 }
1070
1071 err = admin.Close()
1072 if err != nil {
1073 t.Fatal(err)
1074 }
1075}
1076
1077func TestClusterAdminAlterConfig(t *testing.T) {
1078 seedBroker := NewMockBroker(t, 1)

Callers

nothing calls this directly

Calls 14

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

Tested by

no test coverage detected