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
|
//go:build !functional
package sarama
import "testing"
var (
alterPartitionReassignmentsRequestNoBlock = []byte{
0, 0, 39, 16, // timeout 10000
1, // 1-1=0 blocks
0, // empty tagged fields
}
alterPartitionReassignmentsRequestOneBlock = []byte{
0, 0, 39, 16, // timeout 10000
2, // 2-1=1 block
6, 116, 111, 112, 105, 99, // topic name "topic" as compact string
2, // 2-1=1 partitions
0, 0, 0, 0, // partitionId
3, // 3-1=2 replica array size
0, 0, 3, 232, // replica 1000
0, 0, 3, 233, // replica 1001
0, 0, 0, // empty tagged fields
}
alterPartitionReassignmentsAbortRequest = []byte{
0, 0, 39, 16, // timeout 10000
2, // 2-1=1 block
6, 116, 111, 112, 105, 99, // topic name "topic" as compact string
2, // 2-1=1 partitions
0, 0, 0, 0, // partitionId
0, // replica array is null (indicates that a pending reassignment should be aborted)
0, 0, 0, // empty tagged fields
}
)
func TestAlterPartitionReassignmentRequest(t *testing.T) {
var request *AlterPartitionReassignmentsRequest
request = &AlterPartitionReassignmentsRequest{
TimeoutMs: int32(10000),
Version: int16(0),
}
testRequest(t, "no block", request, alterPartitionReassignmentsRequestNoBlock)
request.AddBlock("topic", 0, []int32{1000, 1001})
testRequest(t, "one block", request, alterPartitionReassignmentsRequestOneBlock)
request = &AlterPartitionReassignmentsRequest{
TimeoutMs: int32(10000),
Version: int16(0),
}
request.AddBlock("topic", 0, nil)
testRequest(t, "abort assignment", request, alterPartitionReassignmentsAbortRequest)
}
|