alter_partition_reassignments_request_test.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package sarama
  2. import "testing"
  3. var (
  4. alterPartitionReassignmentsRequestNoBlock = []byte{
  5. 0, 0, 39, 16, // timeout 10000
  6. 1, // 1-1=0 blocks
  7. 0, // empty tagged fields
  8. }
  9. alterPartitionReassignmentsRequestOneBlock = []byte{
  10. 0, 0, 39, 16, // timeout 10000
  11. 2, // 2-1=1 block
  12. 6, 116, 111, 112, 105, 99, // topic name "topic" as compact string
  13. 2, // 2-1=1 partitions
  14. 0, 0, 0, 0, // partitionId
  15. 3, // 3-1=2 replica array size
  16. 0, 0, 3, 232, // replica 1000
  17. 0, 0, 3, 233, // replica 1001
  18. 0, 0, 0, // empty tagged fields
  19. }
  20. alterPartitionReassignmentsAbortRequest = []byte{
  21. 0, 0, 39, 16, // timeout 10000
  22. 2, // 2-1=1 block
  23. 6, 116, 111, 112, 105, 99, // topic name "topic" as compact string
  24. 2, // 2-1=1 partitions
  25. 0, 0, 0, 0, // partitionId
  26. 0, // replica array is null (indicates that a pending reassignment should be aborted)
  27. 0, 0, 0, // empty tagged fields
  28. }
  29. )
  30. func TestAlterPartitionReassignmentRequest(t *testing.T) {
  31. var request *AlterPartitionReassignmentsRequest
  32. request = &AlterPartitionReassignmentsRequest{
  33. TimeoutMs: int32(10000),
  34. Version: int16(0),
  35. }
  36. testRequest(t, "no block", request, alterPartitionReassignmentsRequestNoBlock)
  37. request.AddBlock("topic", 0, []int32{1000, 1001})
  38. testRequest(t, "one block", request, alterPartitionReassignmentsRequestOneBlock)
  39. request = &AlterPartitionReassignmentsRequest{
  40. TimeoutMs: int32(10000),
  41. Version: int16(0),
  42. }
  43. request.AddBlock("topic", 0, nil)
  44. testRequest(t, "abort assignment", request, alterPartitionReassignmentsAbortRequest)
  45. }