Exemplo n.º 1
0
def test_get_min_isr_empty():
    TOPIC_CONFIG_WITHOUT_MIN_ISR = {'version': 1, 'config': {'retention.ms': '86400000'}}
    attrs = {'get_topic_config.return_value': TOPIC_CONFIG_WITHOUT_MIN_ISR}
    zk_mock = mock.MagicMock(**attrs)

    min_isr = get_min_isr(zk_mock, 'topic_0')

    zk_mock.get_topic_config.assert_called_once_with('topic_0')
    assert min_isr is None
Exemplo n.º 2
0
def test_get_min_isr_empty():
    TOPIC_CONFIG_WITHOUT_MIN_ISR = {'version': 1, 'config': {'retention.ms': '86400000'}}
    attrs = {'get_topic_config.return_value': TOPIC_CONFIG_WITHOUT_MIN_ISR}
    zk_mock = mock.MagicMock(**attrs)

    min_isr = get_min_isr(zk_mock, 'topic_0')

    zk_mock.get_topic_config.assert_called_once_with('topic_0')
    assert min_isr is None
Exemplo n.º 3
0
def test_get_min_isr():
    TOPIC_CONFIG_WITH_MIN_ISR = {
        'version': 1,
        'config': {'retention.ms': '86400000', 'min.insync.replicas': '3'},
    }
    attrs = {'get_topic_config.return_value': TOPIC_CONFIG_WITH_MIN_ISR}
    zk_mock = mock.MagicMock(**attrs)

    min_isr = get_min_isr(zk_mock, 'topic_0')

    zk_mock.get_topic_config.assert_called_once_with('topic_0')
    assert min_isr == 3
Exemplo n.º 4
0
def test_get_min_isr():
    TOPIC_CONFIG_WITH_MIN_ISR = {
        'version': 1,
        'config': {'retention.ms': '86400000', 'min.insync.replicas': '3'},
    }
    attrs = {'get_topic_config.return_value': TOPIC_CONFIG_WITH_MIN_ISR}
    zk_mock = mock.MagicMock(**attrs)

    min_isr = get_min_isr(zk_mock, 'topic_0')

    zk_mock.get_topic_config.assert_called_once_with('topic_0')
    assert min_isr == 3
Exemplo n.º 5
0
def _find_topics_with_wrong_rp(topics, zk, default_min_isr):
    """Returns topics with wrong replication factor."""
    topics_with_wrong_rf = []

    for topic_name, partitions in topics.items():
        min_isr = get_min_isr(zk, topic_name) or default_min_isr
        replication_factor = len(partitions[0].replicas)

        if replication_factor >= min_isr + 1:
            continue

        topics_with_wrong_rf.append({
            'replication_factor': replication_factor,
            'min_isr': min_isr,
            'topic': topic_name,
        })

    return topics_with_wrong_rf
Exemplo n.º 6
0
def _find_topics_with_wrong_rp(topics, zk, default_min_isr):
    """Returns topics with wrong replication factor."""
    topics_with_wrong_rf = []

    for topic_name, partitions in topics.items():
        min_isr = get_min_isr(zk, topic_name) or default_min_isr
        replication_factor = len(partitions[0].replicas)

        if replication_factor >= min_isr + 1:
            continue

        topics_with_wrong_rf.append({
            'replication_factor': replication_factor,
            'min_isr': min_isr,
            'topic': topic_name,
        })

    return topics_with_wrong_rf