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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
package listoffsets_test
import (
"testing"
"github.com/segmentio/kafka-go/protocol/listoffsets"
"github.com/segmentio/kafka-go/protocol/prototest"
)
const (
v1 = 1
v4 = 4
)
func TestListOffsetsRequest(t *testing.T) {
prototest.TestRequest(t, v1, &listoffsets.Request{
ReplicaID: 1,
Topics: []listoffsets.RequestTopic{
{
Topic: "topic-1",
Partitions: []listoffsets.RequestPartition{
{Partition: 0, Timestamp: 1e9},
{Partition: 1, Timestamp: 1e9},
{Partition: 2, Timestamp: 1e9},
},
},
},
})
prototest.TestRequest(t, v4, &listoffsets.Request{
ReplicaID: 1,
IsolationLevel: 2,
Topics: []listoffsets.RequestTopic{
{
Topic: "topic-1",
Partitions: []listoffsets.RequestPartition{
{Partition: 0, Timestamp: 1e9},
{Partition: 1, Timestamp: 1e9},
{Partition: 2, Timestamp: 1e9},
},
},
{
Topic: "topic-2",
Partitions: []listoffsets.RequestPartition{
{Partition: 0, CurrentLeaderEpoch: 10, Timestamp: 1e9},
{Partition: 1, CurrentLeaderEpoch: 11, Timestamp: 1e9},
{Partition: 2, CurrentLeaderEpoch: 12, Timestamp: 1e9},
},
},
},
})
}
func TestListOffsetsResponse(t *testing.T) {
prototest.TestResponse(t, v1, &listoffsets.Response{
Topics: []listoffsets.ResponseTopic{
{
Topic: "topic-1",
Partitions: []listoffsets.ResponsePartition{
{
Partition: 0,
ErrorCode: 0,
Timestamp: 1e9,
Offset: 1234567890,
},
},
},
},
})
prototest.TestResponse(t, v4, &listoffsets.Response{
ThrottleTimeMs: 1234,
Topics: []listoffsets.ResponseTopic{
{
Topic: "topic-1",
Partitions: []listoffsets.ResponsePartition{
{
Partition: 0,
ErrorCode: 0,
Timestamp: 1e9,
Offset: 1234567890,
LeaderEpoch: 10,
},
},
},
{
Topic: "topic-2",
Partitions: []listoffsets.ResponsePartition{
{
Partition: 0,
ErrorCode: 0,
Timestamp: 1e9,
Offset: 1234567890,
LeaderEpoch: 10,
},
{
Partition: 1,
ErrorCode: 2,
},
},
},
},
})
}
|