File: elect_leaders_request_test.go

package info (click to toggle)
golang-github-ibm-sarama 1.46.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,072 kB
  • sloc: makefile: 40; sh: 30
file content (42 lines) | stat: -rw-r--r-- 1,107 bytes parent folder | download
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
//go:build !functional

package sarama

import "testing"

var (
	electLeadersRequestOneTopicV1 = []byte{
		0,          // preferred election type
		0, 0, 0, 1, // 1 topic
		0, 5, 116, 111, 112, 105, 99, // topic name "topic" as compact string
		0, 0, 0, 1, // 1 partition
		0, 0, 0, 0, // partition 0
		0, 0, 39, 16, // timeout 10000
	}
	electLeadersRequestOneTopicV2 = []byte{
		0,                         // preferred election type
		2,                         // 2-1=1 topic
		6, 116, 111, 112, 105, 99, // topic name "topic" as compact string
		2,          // 2-1=1 partition
		0, 0, 0, 0, // partition 0
		0,            // empty tagged fields
		0, 0, 39, 16, // timeout 10000
		0, // empty tagged fields
	}
)

func TestElectLeadersRequest(t *testing.T) {
	var request = &ElectLeadersRequest{
		TimeoutMs: int32(10000),
		Version:   int16(1),
		TopicPartitions: map[string][]int32{
			"topic": {0},
		},
		Type: PreferredElection,
	}

	testRequest(t, "one topic V1", request, electLeadersRequestOneTopicV1)

	request.Version = 2
	testRequest(t, "one topic V2", request, electLeadersRequestOneTopicV2)
}