File: test_partition_movements.py

package info (click to toggle)
python-kafka 2.0.2-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,740 kB
  • sloc: python: 20,457; makefile: 210; sh: 76
file content (23 lines) | stat: -rw-r--r-- 902 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from kafka.structs import TopicPartition

from kafka.coordinator.assignors.sticky.partition_movements import PartitionMovements


def test_empty_movements_are_sticky():
    partition_movements = PartitionMovements()
    assert partition_movements.are_sticky()


def test_sticky_movements():
    partition_movements = PartitionMovements()
    partition_movements.move_partition(TopicPartition('t', 1), 'C1', 'C2')
    partition_movements.move_partition(TopicPartition('t', 1), 'C2', 'C3')
    partition_movements.move_partition(TopicPartition('t', 1), 'C3', 'C1')
    assert partition_movements.are_sticky()


def test_should_detect_non_sticky_assignment():
    partition_movements = PartitionMovements()
    partition_movements.move_partition(TopicPartition('t', 1), 'C1', 'C2')
    partition_movements.move_partition(TopicPartition('t', 2), 'C2', 'C1')
    assert not partition_movements.are_sticky()