def test_report_status_for_cluster_displays_deployed_service(
    mock_stdout,
    mock_execute_paasta_serviceinit_on_remote_master,
):
    # paasta_status with no args displays deploy info - vanilla case
    service = 'fake_service'
    planned_deployments = ['cluster.instance']
    actual_deployments = {
        'cluster.instance': 'sha'
    }
    fake_status = 'status: SOMETHING FAKE'
    mock_execute_paasta_serviceinit_on_remote_master.return_value = fake_status
    expected_output = (
        "\n"
        "cluster: cluster\n"
        "  instance: %s\n"
        "    Git sha:    sha\n"
        "    %s\n"
        % (
            PaastaColors.blue('instance'),
            fake_status,
        )
    )

    status.report_status_for_cluster(
        service, 'cluster', planned_deployments, actual_deployments)
    output = mock_stdout.getvalue()
    assert expected_output in output
def test_print_cluster_status_missing_deploys_in_red(
    mock_stdout,
    mock_execute_paasta_serviceinit_on_remote_master,
):
    # paasta_status displays missing deploys in red
    service = 'fake_service'
    planned_deployments = [
        'a_cluster.a_instance',
        'a_cluster.b_instance',
    ]
    actual_deployments = {
        'a_cluster.a_instance': '533976a981679d586bed1cfb534fdba4b4e2c815',
    }
    fake_status = 'status: SOMETHING FAKE'
    mock_execute_paasta_serviceinit_on_remote_master.return_value = fake_status
    expected_output = (
        "\n"
        "cluster: a_cluster\n"
        "  instance: %s\n"
        "    Git sha:    533976a9\n"
        "    %s\n"
        "  instance: %s\n"
        "    Git sha:    None\n"
        % (
            PaastaColors.blue('a_instance'),
            fake_status,
            PaastaColors.red('b_instance'),
        )
    )

    status.report_status_for_cluster(
        service, 'a_cluster', planned_deployments, actual_deployments)
    output = mock_stdout.getvalue()
    assert expected_output in output
Beispiel #3
0
def test_report_status_for_cluster_displays_deployed_service(
    mock_stdout,
    mock_report_invalid_whitelist_values,
    mock_execute_paasta_serviceinit_on_remote_master,
):
    # paasta_status with no args displays deploy info - vanilla case
    service = 'fake_service'
    planned_deployments = ['cluster.instance']
    actual_deployments = {
        'cluster.instance': 'sha'
    }
    instance_whitelist = []
    fake_status = 'status: SOMETHING FAKE'
    mock_execute_paasta_serviceinit_on_remote_master.return_value = fake_status
    expected_output = (
        "\n"
        "cluster: cluster\n"
        "  instance: %s\n"
        "    Git sha:    sha\n"
        "    %s\n"
        % (
            PaastaColors.blue('instance'),
            fake_status,
        )
    )

    status.report_status_for_cluster(
        service=service,
        cluster='cluster',
        deploy_pipeline=planned_deployments,
        actual_deployments=actual_deployments,
        instance_whitelist=instance_whitelist,
    )
    output = mock_stdout.getvalue()
    assert expected_output in output
Beispiel #4
0
def test_report_status_for_cluster_instance_sorts_in_deploy_order(
    mock_stdout,
    mock_report_invalid_whitelist_values,
    mock_execute_paasta_serviceinit_on_remote_master,
):
    # paasta_status with no args displays deploy info
    service = 'fake_service'
    planned_deployments = [
        'a_cluster.a_instance',
        'a_cluster.b_instance',
    ]
    actual_deployments = {
        'a_cluster.a_instance': '533976a9',
        'a_cluster.b_instance': '533976a9',
    }
    instance_whitelist = []
    fake_status = 'status: SOMETHING FAKE'
    mock_execute_paasta_serviceinit_on_remote_master.return_value = fake_status
    expected_output = (
        "\n"
        "cluster: a_cluster\n"
        "  instance: %s\n"
        "    Git sha:    533976a9\n"
        "    %s\n"
        "  instance: %s\n"
        "    Git sha:    533976a9\n"
        "    %s\n"
        % (
            PaastaColors.blue('a_instance'),
            fake_status,
            PaastaColors.blue('b_instance'),
            fake_status,
        )
    )

    status.report_status_for_cluster(
        service=service,
        cluster='a_cluster',
        deploy_pipeline=planned_deployments,
        actual_deployments=actual_deployments,
        instance_whitelist=instance_whitelist,
    )
    output = mock_stdout.getvalue()
    assert expected_output in output
Beispiel #5
0
def test_print_cluster_status_missing_deploys_in_red(
    mock_stdout,
    mock_report_invalid_whitelist_values,
    mock_execute_paasta_serviceinit_on_remote_master,
):
    # paasta_status displays missing deploys in red
    service = 'fake_service'
    planned_deployments = [
        'a_cluster.a_instance',
        'a_cluster.b_instance',
    ]
    actual_deployments = {
        'a_cluster.a_instance': '533976a981679d586bed1cfb534fdba4b4e2c815',
    }
    instance_whitelist = []
    fake_status = 'status: SOMETHING FAKE'
    mock_execute_paasta_serviceinit_on_remote_master.return_value = fake_status
    expected_output = (
        "\n"
        "cluster: a_cluster\n"
        "  instance: %s\n"
        "    Git sha:    533976a9\n"
        "    %s\n"
        "  instance: %s\n"
        "    Git sha:    None\n"
        % (
            PaastaColors.blue('a_instance'),
            fake_status,
            PaastaColors.red('b_instance'),
        )
    )

    status.report_status_for_cluster(
        service=service,
        cluster='a_cluster',
        deploy_pipeline=planned_deployments,
        actual_deployments=actual_deployments,
        instance_whitelist=instance_whitelist,
    )
    output = mock_stdout.getvalue()
    assert expected_output in output