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

Function TestFuncClientMetadata

functional_client_test.go:84–125  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

82}
83
84func TestFuncClientMetadata(t *testing.T) {
85 setupFunctionalTest(t)
86 defer teardownFunctionalTest(t)
87
88 config := NewFunctionalTestConfig()
89 config.Metadata.Retry.Max = 1
90 config.Metadata.Retry.Backoff = 10 * time.Millisecond
91 client, err := NewClient(FunctionalTestEnv.KafkaBrokerAddrs, config)
92 if err != nil {
93 t.Fatal(err)
94 }
95
96 if err := client.RefreshMetadata("unknown_topic"); !errors.Is(err, ErrUnknownTopicOrPartition) {
97 t.Error("Expected ErrUnknownTopicOrPartition, got", err)
98 }
99
100 if _, err := client.Leader("unknown_topic", 0); !errors.Is(err, ErrUnknownTopicOrPartition) {
101 t.Error("Expected ErrUnknownTopicOrPartition, got", err)
102 }
103
104 if _, err := client.Replicas("invalid/topic", 0); !errors.Is(err, ErrUnknownTopicOrPartition) && !errors.Is(err, ErrInvalidTopic) {
105 t.Error("Expected ErrUnknownTopicOrPartition or ErrInvalidTopic, got", err)
106 }
107
108 partitions, err := client.Partitions("test.4")
109 if err != nil {
110 t.Error(err)
111 }
112 if len(partitions) != 4 {
113 t.Errorf("Expected test.4 topic to have 4 partitions, found %v", partitions)
114 }
115
116 partitions, err = client.Partitions("test.1")
117 if err != nil {
118 t.Error(err)
119 }
120 if len(partitions) != 1 {
121 t.Errorf("Expected test.1 topic to have 1 partitions, found %v", partitions)
122 }
123
124 safeClose(t, client)
125}
126
127func TestFuncClientCoordinator(t *testing.T) {
128 checkKafkaVersion(t, "0.8.2")

Callers

nothing calls this directly

Calls 13

RefreshMetadataMethod · 0.95
LeaderMethod · 0.95
ReplicasMethod · 0.95
PartitionsMethod · 0.95
setupFunctionalTestFunction · 0.85
teardownFunctionalTestFunction · 0.85
NewFunctionalTestConfigFunction · 0.85
FatalMethod · 0.80
IsMethod · 0.80
NewClientFunction · 0.70
safeCloseFunction · 0.70
ErrorMethod · 0.65

Tested by

no test coverage detected