Exemplo n.º 1
0
def test_paasta_status(system_paasta_config):
    fake_dict = {
        "git_sha": "fake_git_sha",
        "instance": "fake_instance",
        "service": "fake_service"
    }
    fake_dict2 = {
        "error_message": None,
        "desired_state": "start",
        "app_id": "fake_app_id",
        "app_count": 1,
        "running_instance_count": 2,
        "expected_instance_count": 2,
        "deploy_status": "Running",
        "bounce_method": "crossover",
    }
    fake_status_obj = Struct(**fake_dict)
    fake_status_obj.marathon = Struct(**fake_dict2)

    system_paasta_config = system_paasta_config

    with mock.patch('bravado.http_future.HttpFuture.result',
                    autospec=True) as mock_result:
        mock_result.return_value = fake_status_obj
        paasta_status_on_api_endpoint(
            'fake_cluster',
            'fake_service',
            'fake_instance',
            system_paasta_config,
            verbose=False,
        )
Exemplo n.º 2
0
def test_paasta_status_exception():
    system_paasta_config = SystemPaastaConfig({
        'api_endpoints': {
            'fake_cluster': "http://fake_cluster:5054"
        },
        'cluster': 'fake_cluster'
    }, 'fake_directory')

    with mock.patch('paasta_tools.cli.cmds.status.get_paasta_api_client', autospec=True) as mock_get_paasta_api_client:
        requests_response = mock.Mock(status_code=500, reason='Internal Server Error')
        incoming_response = RequestsResponseAdapter(requests_response)

        mock_swagger_client = mock.Mock()
        mock_swagger_client.service.status_instance.side_effect = HTTPError(incoming_response)
        mock_get_paasta_api_client.return_value = mock_swagger_client
        paasta_status_on_api_endpoint('fake_cluster', 'fake_service', 'fake_instance',
                                      system_paasta_config, verbose=False)
Exemplo n.º 3
0
def test_paasta_status_exception(system_paasta_config):
    system_paasta_config = system_paasta_config

    with mock.patch('paasta_tools.cli.cmds.status.get_paasta_api_client',
                    autospec=True) as mock_get_paasta_api_client:
        requests_response = mock.Mock(status_code=500,
                                      reason='Internal Server Error')
        incoming_response = RequestsResponseAdapter(requests_response)

        mock_swagger_client = mock.Mock()
        mock_swagger_client.service.status_instance.side_effect = HTTPError(
            incoming_response)
        mock_get_paasta_api_client.return_value = mock_swagger_client
        paasta_status_on_api_endpoint(
            'fake_cluster',
            'fake_service',
            'fake_instance',
            system_paasta_config,
            verbose=False,
        )
Exemplo n.º 4
0
def test_paasta_status():
    fake_dict = {"git_sha": "fake_git_sha", "instance": "fake_instance", "service": "fake_service"}
    fake_dict2 = {"error_message": None, "desired_state": "start",
                  "app_id": "fake_app_id", "app_count": 1,
                  "running_instance_count": 2, "expected_instance_count": 2,
                  "deploy_status": "Running", "bounce_method": "crossover"}
    fake_status_obj = Struct(**fake_dict)
    fake_status_obj.marathon = Struct(**fake_dict2)

    system_paasta_config = SystemPaastaConfig({
        'api_endpoints': {
            'fake_cluster': "http://fake_cluster:5054"
        },
        'cluster': 'fake_cluster'
    }, 'fake_directory')

    with mock.patch('bravado.http_future.HttpFuture.result', autospec=True) as mock_result:
        mock_result.return_value = fake_status_obj
        paasta_status_on_api_endpoint('fake_cluster', 'fake_service', 'fake_instance',
                                      system_paasta_config, verbose=False)
Exemplo n.º 5
0
def paasta_status_via_api(context, service, instance):
    output = []
    system_paasta_config = load_system_paasta_config()
    exit_code = paasta_status_on_api_endpoint(
        cluster=system_paasta_config.get_cluster(),
        service=service,
        instance=instance,
        output=output,
        system_paasta_config=system_paasta_config,
        verbose=0,
    )
    print(f"Got exitcode {exit_code} with output:\n{output}")
    print()  # sacrificial line for behave to eat instead of our output

    assert exit_code == 0
    assert len(output) > 0