MCPcopy Create free account
hub / github.com/IBM/sarama / TestRefreshMetaDataWithDifferentController

Function TestRefreshMetaDataWithDifferentController

admin_test.go:2943–2992  ·  view source on GitHub ↗

TestRefreshMetaDataWithDifferentController ensures that the cached controller can be forcibly updated from Metadata by the admin client

(t *testing.T)

Source from the content-addressed store, hash-verified

2941// TestRefreshMetaDataWithDifferentController ensures that the cached
2942// controller can be forcibly updated from Metadata by the admin client
2943func TestRefreshMetaDataWithDifferentController(t *testing.T) {
2944 seedBroker1 := NewMockBroker(t, 1)
2945 seedBroker2 := NewMockBroker(t, 2)
2946 defer seedBroker1.Close()
2947 defer seedBroker2.Close()
2948
2949 seedBroker1.SetHandlerByMap(map[string]MockResponse{
2950 "MetadataRequest": NewMockMetadataResponse(t).
2951 SetController(seedBroker1.BrokerID()).
2952 SetBroker(seedBroker1.Addr(), seedBroker1.BrokerID()).
2953 SetBroker(seedBroker2.Addr(), seedBroker2.BrokerID()),
2954 })
2955
2956 config := NewTestConfig()
2957 config.Version = V1_1_0_0
2958
2959 client, err := NewClient([]string{seedBroker1.Addr()}, config)
2960 if err != nil {
2961 t.Fatal(err)
2962 }
2963 defer client.Close()
2964
2965 ca := clusterAdmin{client: client, conf: config}
2966
2967 if b, _ := ca.Controller(); seedBroker1.BrokerID() != b.ID() {
2968 t.Fatalf("expected cached controller to be %d rather than %d",
2969 seedBroker1.BrokerID(), b.ID())
2970 }
2971
2972 metadataResponse := NewMockMetadataResponse(t).
2973 SetController(seedBroker2.BrokerID()).
2974 SetBroker(seedBroker1.Addr(), seedBroker1.BrokerID()).
2975 SetBroker(seedBroker2.Addr(), seedBroker2.BrokerID())
2976 seedBroker1.SetHandlerByMap(map[string]MockResponse{
2977 "MetadataRequest": metadataResponse,
2978 })
2979 seedBroker2.SetHandlerByMap(map[string]MockResponse{
2980 "MetadataRequest": metadataResponse,
2981 })
2982
2983 if b, _ := ca.refreshController(); seedBroker2.BrokerID() != b.ID() {
2984 t.Fatalf("expected refreshed controller to be %d rather than %d",
2985 seedBroker2.BrokerID(), b.ID())
2986 }
2987
2988 if b, _ := ca.Controller(); seedBroker2.BrokerID() != b.ID() {
2989 t.Fatalf("expected cached controller to be %d rather than %d",
2990 seedBroker2.BrokerID(), b.ID())
2991 }
2992}
2993
2994func TestDescribeLogDirs(t *testing.T) {
2995 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
ControllerMethod · 0.95
refreshControllerMethod · 0.95
NewMockBrokerFunction · 0.85
NewMockMetadataResponseFunction · 0.85
SetBrokerMethod · 0.80
SetControllerMethod · 0.80
FatalMethod · 0.80

Tested by

no test coverage detected