Пример #1
0
    def test_count_preferred_replica(self, partition):
        p1 = partition
        b1 = Broker('test-broker', partitions=set([p1]))
        p1.add_replica(b1)
        p2 = Mock(spec=Partition, topic=sentinel.t1, replicas=[sentinel.b2])
        b1.add_partition(p2)

        assert b1.count_preferred_replica() == 1
Пример #2
0
    def test_count_preferred_replica(self, partition):
        p1 = partition
        b1 = Broker('test-broker', partitions=set([p1]))
        p1.add_replica(b1)
        p2 = Mock(spec=Partition, topic=sentinel.t1, replicas=[sentinel.b2])
        b1.add_partition(p2)

        assert b1.count_preferred_replica() == 1
Пример #3
0
    def test_add_partition(self, create_partition):
        p10 = create_partition('t1', 0)
        p20 = create_partition('t2', 0)
        broker = Broker('test-broker', partitions=set([p10]))

        broker.add_partition(p20)

        assert broker.partitions == set([p10, p20])
        assert p20.replicas == [broker]
Пример #4
0
    def test_add_partition(self, create_partition):
        p10 = create_partition('t1', 0)
        p20 = create_partition('t2', 0)
        broker = Broker('test-broker', partitions=set([p10]))

        broker.add_partition(p20)

        assert broker.partitions == set([p10, p20])
        assert p20.replicas == [broker]