コード例 #1
0
def test_validate_plan_base_replication_factor_changed_allowed():
    # replication-factor of (t1, 0) is 1 in assignment and 2 in base-assignment
    assignment = {
        "version":
        1,
        "partitions": [{
            "partition": 0,
            "topic": u't1',
            "replicas": [1]
        }, {
            "partition": 0,
            "topic": u't2',
            "replicas": [0, 1]
        }]
    }
    base_assignment = {
        "version":
        1,
        "partitions": [{
            "partition": 0,
            "topic": u't1',
            "replicas": [0, 2]
        }, {
            "partition": 0,
            "topic": u't2',
            "replicas": [0, 1]
        }]
    }

    # Verify validation passed
    assert _validate_plan_base(assignment,
                               base_assignment,
                               allow_rf_change=True)
コード例 #2
0
def test_validate_plan_base_invalid_partitions_2():
    # partition: ('t2', 1) not present in base assignment
    assignment = {
        "version":
        1,
        "partitions": [{
            "partition": 0,
            "topic": u't1',
            "replicas": [1, 2]
        }, {
            "partition": 1,
            "topic": u't2',
            "replicas": [0, 1]
        }]
    }
    base_assignment = {
        "version":
        1,
        "partitions": [{
            "partition": 0,
            "topic": u't1',
            "replicas": [0, 2]
        }, {
            "partition": 0,
            "topic": u't2',
            "replicas": [0, 1]
        }]
    }

    # Verify validation failed
    assert _validate_plan_base(assignment, base_assignment) is False
コード例 #3
0
def test_validate_plan_base():
    assignment = {
        "version":
        1,
        "partitions": [{
            "partition": 0,
            "topic": u't1',
            "replicas": [1, 2]
        }, {
            "partition": 1,
            "topic": u't1',
            "replicas": [0, 1]
        }]
    }
    base_assignment = {
        "version":
        1,
        "partitions": [{
            "partition": 0,
            "topic": u't1',
            "replicas": [0, 2]
        }, {
            "partition": 1,
            "topic": u't1',
            "replicas": [1, 2]
        }, {
            "partition": 1,
            "topic": u't2',
            "replicas": [0]
        }]
    }

    # Verify valid assignment compared to base
    assert _validate_plan_base(assignment, base_assignment) is True
コード例 #4
0
ファイル: validation_test.py プロジェクト: Yelp/kafka-utils
def test_validate_plan_base_replication_factor_changed_allowed():
    # replication-factor of (t1, 0) is 1 in assignment and 2 in base-assignment
    assignment = {
        "version": 1,
        "partitions": [
            {"partition": 0, "topic": u't1', "replicas": [1]},
            {"partition": 0, "topic": u't2', "replicas": [0, 1]}
        ]
    }
    base_assignment = {
        "version": 1,
        "partitions": [
            {"partition": 0, "topic": u't1', "replicas": [0, 2]},
            {"partition": 0, "topic": u't2', "replicas": [0, 1]}
        ]
    }

    # Verify validation passed
    assert _validate_plan_base(assignment, base_assignment, allow_rf_change=True)
コード例 #5
0
ファイル: validation_test.py プロジェクト: Yelp/kafka-utils
def test_validate_plan_base_invalid_partitions_2():
    # partition: ('t2', 1) not present in base assignment
    assignment = {
        "version": 1,
        "partitions": [
            {"partition": 0, "topic": u't1', "replicas": [1, 2]},
            {"partition": 1, "topic": u't2', "replicas": [0, 1]}
        ]
    }
    base_assignment = {
        "version": 1,
        "partitions": [
            {"partition": 0, "topic": u't1', "replicas": [0, 2]},
            {"partition": 0, "topic": u't2', "replicas": [0, 1]}
        ]
    }

    # Verify validation failed
    assert _validate_plan_base(assignment, base_assignment) is False
コード例 #6
0
ファイル: validation_test.py プロジェクト: Yelp/kafka-utils
def test_validate_plan_base():
    assignment = {
        "version": 1,
        "partitions": [
            {"partition": 0, "topic": u't1', "replicas": [1, 2]},
            {"partition": 1, "topic": u't1', "replicas": [0, 1]}
        ]
    }
    base_assignment = {
        "version": 1,
        "partitions": [
            {"partition": 0, "topic": u't1', "replicas": [0, 2]},
            {"partition": 1, "topic": u't1', "replicas": [1, 2]},
            {"partition": 1, "topic": u't2', "replicas": [0]}
        ]
    }

    # Verify valid assignment compared to base
    assert _validate_plan_base(assignment, base_assignment) is True