|
@@ -3,24 +3,63 @@ package sarama
|
|
|
import "testing"
|
|
|
|
|
|
var (
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
metadataRequestNoTopicsV0 = []byte{
|
|
|
- 0x00, 0x00, 0x00, 0x00}
|
|
|
+ 0x00, 0x00, 0x00, 0x00,
|
|
|
+ }
|
|
|
|
|
|
metadataRequestOneTopicV0 = []byte{
|
|
|
0x00, 0x00, 0x00, 0x01,
|
|
|
- 0x00, 0x06, 't', 'o', 'p', 'i', 'c', '1'}
|
|
|
+ 0x00, 0x06, 't', 'o', 'p', 'i', 'c', '1',
|
|
|
+ }
|
|
|
|
|
|
metadataRequestThreeTopicsV0 = []byte{
|
|
|
0x00, 0x00, 0x00, 0x03,
|
|
|
0x00, 0x03, 'f', 'o', 'o',
|
|
|
0x00, 0x03, 'b', 'a', 'r',
|
|
|
- 0x00, 0x03, 'b', 'a', 'z'}
|
|
|
+ 0x00, 0x03, 'b', 'a', 'z',
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
metadataRequestNoTopicsV1 = []byte{
|
|
|
- 0xff, 0xff, 0xff, 0xff}
|
|
|
+ 0xff, 0xff, 0xff, 0xff,
|
|
|
+ }
|
|
|
+
|
|
|
+ metadataRequestOneTopicV1 = metadataRequestOneTopicV0
|
|
|
+ metadataRequestThreeTopicsV1 = metadataRequestThreeTopicsV0
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ metadataRequestNoTopicsV2 = metadataRequestNoTopicsV1
|
|
|
+ metadataRequestOneTopicV2 = metadataRequestOneTopicV1
|
|
|
+ metadataRequestThreeTopicsV2 = metadataRequestThreeTopicsV1
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ metadataRequestNoTopicsV3 = metadataRequestNoTopicsV2
|
|
|
+ metadataRequestOneTopicV3 = metadataRequestOneTopicV2
|
|
|
+ metadataRequestThreeTopicsV3 = metadataRequestThreeTopicsV2
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- metadataRequestAutoCreateV4 = append(metadataRequestOneTopicV0, byte(1))
|
|
|
- metadataRequestNoAutoCreateV4 = append(metadataRequestOneTopicV0, byte(0))
|
|
|
+ metadataRequestNoTopicsV4 = append(metadataRequestNoTopicsV1, byte(0))
|
|
|
+ metadataRequestAutoCreateV4 = append(metadataRequestOneTopicV3, byte(1))
|
|
|
+ metadataRequestNoAutoCreateV4 = append(metadataRequestOneTopicV3, byte(0))
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ metadataRequestNoTopicsV5 = append(metadataRequestNoTopicsV1, byte(0))
|
|
|
+ metadataRequestAutoCreateV5 = append(metadataRequestOneTopicV3, byte(1))
|
|
|
+ metadataRequestNoAutoCreateV5 = append(metadataRequestOneTopicV3, byte(0))
|
|
|
)
|
|
|
|
|
|
func TestMetadataRequestV0(t *testing.T) {
|
|
@@ -40,37 +79,57 @@ func TestMetadataRequestV1(t *testing.T) {
|
|
|
testRequest(t, "no topics", request, metadataRequestNoTopicsV1)
|
|
|
|
|
|
request.Topics = []string{"topic1"}
|
|
|
- testRequest(t, "one topic", request, metadataRequestOneTopicV0)
|
|
|
+ testRequest(t, "one topic", request, metadataRequestOneTopicV1)
|
|
|
|
|
|
request.Topics = []string{"foo", "bar", "baz"}
|
|
|
- testRequest(t, "three topics", request, metadataRequestThreeTopicsV0)
|
|
|
+ testRequest(t, "three topics", request, metadataRequestThreeTopicsV1)
|
|
|
}
|
|
|
|
|
|
func TestMetadataRequestV2(t *testing.T) {
|
|
|
request := new(MetadataRequest)
|
|
|
request.Version = 2
|
|
|
- testRequest(t, "no topics", request, metadataRequestNoTopicsV1)
|
|
|
+ testRequest(t, "no topics", request, metadataRequestNoTopicsV2)
|
|
|
|
|
|
request.Topics = []string{"topic1"}
|
|
|
- testRequest(t, "one topic", request, metadataRequestOneTopicV0)
|
|
|
+ testRequest(t, "one topic", request, metadataRequestOneTopicV2)
|
|
|
+
|
|
|
+ request.Topics = []string{"foo", "bar", "baz"}
|
|
|
+ testRequest(t, "three topics", request, metadataRequestThreeTopicsV2)
|
|
|
}
|
|
|
|
|
|
func TestMetadataRequestV3(t *testing.T) {
|
|
|
request := new(MetadataRequest)
|
|
|
request.Version = 3
|
|
|
- testRequest(t, "no topics", request, metadataRequestNoTopicsV1)
|
|
|
+ testRequest(t, "no topics", request, metadataRequestNoTopicsV3)
|
|
|
|
|
|
request.Topics = []string{"topic1"}
|
|
|
- testRequest(t, "one topic", request, metadataRequestOneTopicV0)
|
|
|
+ testRequest(t, "one topic", request, metadataRequestOneTopicV3)
|
|
|
}
|
|
|
|
|
|
func TestMetadataRequestV4(t *testing.T) {
|
|
|
request := new(MetadataRequest)
|
|
|
request.Version = 4
|
|
|
+ testRequest(t, "no topics", request, metadataRequestNoTopicsV4)
|
|
|
+
|
|
|
request.Topics = []string{"topic1"}
|
|
|
+
|
|
|
request.AllowAutoTopicCreation = true
|
|
|
testRequest(t, "one topic", request, metadataRequestAutoCreateV4)
|
|
|
|
|
|
request.AllowAutoTopicCreation = false
|
|
|
testRequest(t, "one topic", request, metadataRequestNoAutoCreateV4)
|
|
|
}
|
|
|
+
|
|
|
+func TestMetadataRequestV5(t *testing.T) {
|
|
|
+ request := new(MetadataRequest)
|
|
|
+ request.Version = 5
|
|
|
+ testRequest(t, "no topics", request, metadataRequestNoTopicsV4)
|
|
|
+
|
|
|
+ request.Topics = []string{"topic1"}
|
|
|
+
|
|
|
+ request.AllowAutoTopicCreation = true
|
|
|
+ testRequest(t, "one topic", request, metadataRequestAutoCreateV5)
|
|
|
+
|
|
|
+ request.AllowAutoTopicCreation = false
|
|
|
+ testRequest(t, "one topic", request, metadataRequestNoAutoCreateV5)
|
|
|
+}
|