-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathcreate_partitions_request_test.go
More file actions
78 lines (67 loc) · 1.79 KB
/
Copy pathcreate_partitions_request_test.go
File metadata and controls
78 lines (67 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//go:build !functional
package sarama
import (
"testing"
"time"
)
var (
createPartitionRequestNoAssignment = []byte{
0, 0, 0, 1, // one topic
0, 5, 't', 'o', 'p', 'i', 'c',
0, 0, 0, 3, // 3 partitions
255, 255, 255, 255, // no assignments
0, 0, 0, 100, // timeout
0, // validate only = false
}
createPartitionRequestAssignment = []byte{
0, 0, 0, 1,
0, 5, 't', 'o', 'p', 'i', 'c',
0, 0, 0, 3, // 3 partitions
0, 0, 0, 2,
0, 0, 0, 2,
0, 0, 0, 2, 0, 0, 0, 3,
0, 0, 0, 2,
0, 0, 0, 3, 0, 0, 0, 1,
0, 0, 0, 100,
1, // validate only = true
}
createPartitionRequestAssignmentV2 = []byte{
2,
6, 't', 'o', 'p', 'i', 'c',
0, 0, 0, 3, // 3 partitions
3,
3,
0, 0, 0, 2, 0, 0, 0, 3,
0, // empty tagged fields
3,
0, 0, 0, 3, 0, 0, 0, 1,
0, // empty tagged fields
0, // empty tagged fields
0, 0, 0, 100,
1, // validate only = true
0, // empty tagged fields
}
)
func TestCreatePartitionsRequest(t *testing.T) {
req := &CreatePartitionsRequest{
TopicPartitions: map[string]*TopicPartition{
"topic": {
Count: 3,
},
},
Timeout: 100 * time.Millisecond,
}
buf := testRequestEncode(t, "no assignment", req, createPartitionRequestNoAssignment)
testRequestDecode(t, "no assignment", req, buf)
req.ValidateOnly = true
req.TopicPartitions["topic"].Assignment = [][]int32{{2, 3}, {3, 1}}
buf = testRequestEncode(t, "assignment", req, createPartitionRequestAssignment)
testRequestDecode(t, "assignment", req, buf)
req.Version = 2
buf = testRequestEncode(t, "assignment v2", req, createPartitionRequestAssignmentV2)
testRequestDecode(t, "assignment v2", req, buf)
// v3 wire format is identical to v2
req.Version = 3
buf = testRequestEncode(t, "assignment v3", req, createPartitionRequestAssignmentV2)
testRequestDecode(t, "assignment v3", req, buf)
}