-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathtxn_offset_commit_request_test.go
68 lines (61 loc) · 1.5 KB
/
txn_offset_commit_request_test.go
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
package sarama
import "testing"
var (
txnOffsetCommitRequest = []byte{
0, 3, 't', 'x', 'n',
0, 7, 'g', 'r', 'o', 'u', 'p', 'i', 'd',
0, 0, 0, 0, 0, 0, 31, 64, // producer ID
0, 1, // producer epoch
0, 0, 0, 1, // 1 topic
0, 5, 't', 'o', 'p', 'i', 'c',
0, 0, 0, 1, // 1 partition
0, 0, 0, 2, // partition no 2
0, 0, 0, 0, 0, 0, 0, 123,
255, 255, // no meta data
}
txnOffsetCommitRequestV2 = []byte{
0, 3, 't', 'x', 'n',
0, 7, 'g', 'r', 'o', 'u', 'p', 'i', 'd',
0, 0, 0, 0, 0, 0, 31, 64, // producer ID
0, 1, // producer epoch
0, 0, 0, 1, // 1 topic
0, 5, 't', 'o', 'p', 'i', 'c',
0, 0, 0, 1, // 1 partition
0, 0, 0, 2, // partition no 2
0, 0, 0, 0, 0, 0, 0, 123,
0, 0, 0, 9, // leader epoch
255, 255, // no meta data
}
)
func TestTxnOffsetCommitRequest(t *testing.T) {
req := &TxnOffsetCommitRequest{
TransactionalID: "txn",
GroupID: "groupid",
ProducerID: 8000,
ProducerEpoch: 1,
Topics: map[string][]*PartitionOffsetMetadata{
"topic": {{
Offset: 123,
Partition: 2,
}},
},
}
testRequest(t, "V0", req, txnOffsetCommitRequest)
}
func TestTxnOffsetCommitRequestV2(t *testing.T) {
req := &TxnOffsetCommitRequest{
Version: 2,
TransactionalID: "txn",
GroupID: "groupid",
ProducerID: 8000,
ProducerEpoch: 1,
Topics: map[string][]*PartitionOffsetMetadata{
"topic": {{
Offset: 123,
Partition: 2,
LeaderEpoch: 9,
}},
},
}
testRequest(t, "V2", req, txnOffsetCommitRequestV2)
}