MCPcopy
hub / github.com/IBM/sarama / assertPartitioningConsistent

Function assertPartitioningConsistent

partitioner_test.go:14–31  ·  view source on GitHub ↗
(t *testing.T, partitioner Partitioner, message *ProducerMessage, numPartitions int32)

Source from the content-addressed store, hash-verified

12)
13
14func assertPartitioningConsistent(t *testing.T, partitioner Partitioner, message *ProducerMessage, numPartitions int32) {
15 choice, err := partitioner.Partition(message, numPartitions)
16 if err != nil {
17 t.Error(partitioner, err)
18 }
19 if choice < 0 || choice >= numPartitions {
20 t.Error(partitioner, "returned partition", choice, "outside of range for", message)
21 }
22 for i := 1; i < 50; i++ {
23 newChoice, err := partitioner.Partition(message, numPartitions)
24 if err != nil {
25 t.Error(partitioner, err)
26 }
27 if newChoice != choice {
28 t.Error(partitioner, "returned partition", newChoice, "inconsistent with", choice, ".")
29 }
30 }
31}
32
33type partitionerTestCase struct {
34 key string

Callers 4

TestHashPartitionerFunction · 0.85
TestMurmur2PartitionerFunction · 0.85

Calls 2

PartitionMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected