def test_find_unique_vi_by_vi_id(placeboify, maybe_sleep):
    client = placeboify.client("directconnect")
    vi_id = aws_direct_connect_virtual_interface.find_unique_vi(client,
                                                                None,
                                                                "dxvif-aaaaaaaaa",
                                                                None)
    assert vi_id == "dxvif-aaaaaaaa"
コード例 #2
0
def test_nonexistent_lag_status(placeboify, maybe_sleep):
    client = placeboify.client("directconnect")
    exists = lag_module.lag_exists(client=client,
                                   lag_id="doesntexist",
                                   lag_name="doesntexist",
                                   verify=True)
    assert not exists
コード例 #3
0
def test_lag_exists_using_name(placeboify, maybe_sleep, dependencies):
    client = placeboify.client("directconnect")
    exists = lag_module.lag_exists(client=client,
                                   lag_id=None,
                                   lag_name=dependencies.lag_1.get("name"),
                                   verify=True)
    assert exists
コード例 #4
0
def test_delete_lag_with_connections_without_force_delete(
        placeboify, maybe_sleep, dependencies):
    client = placeboify.client("directconnect")
    with pytest.raises(Exception) as error_message:
        lag_module.ensure_absent(client, dependencies.lag_1.get("lag_id"),
                                 "ansible_lag_1", False, True, True, 120)
        assert "To force deletion of the LAG use delete_force: True" in error_message
コード例 #5
0
def test_check_dp_status(placeboify, maybe_sleep, dp_setup):
    inactive_states = ['INACTIVE', 'PENDING', 'FINISHED', 'DELETING']
    connection = placeboify.client('datapipeline')
    state = data_pipeline.check_dp_status(connection,
                                          dp_setup.data_pipeline_id,
                                          inactive_states)
    assert state is True
コード例 #6
0
def test_create_pipeline_already_exists(placeboify, maybe_sleep, dp_setup):
    connection = placeboify.client('datapipeline')
    changed, result = data_pipeline.create_pipeline(connection,
                                                    dp_setup.module)
    assert changed is False
    assert "Data Pipeline ansible-test-create-pipeline is present" in result[
        'msg']
コード例 #7
0
def test_pipeline_description_nonexistent(placeboify, maybe_sleep):
    hypothetical_pipeline_id = "df-015440025PF7YGLDK47C"
    connection = placeboify.client('datapipeline')
    with pytest.raises(Exception) as error:
        data_pipeline.pipeline_description(connection,
                                           hypothetical_pipeline_id)
        assert error == data_pipeline.DataPipelineNotFound
コード例 #8
0
def test_define_pipeline(placeboify, maybe_sleep, dp_setup):
    connection = placeboify.client('datapipeline')
    changed, result = data_pipeline.define_pipeline(connection,
                                                    dp_setup.module,
                                                    dp_setup.objects,
                                                    dp_setup.data_pipeline_id)
    assert 'has been updated' in result
コード例 #9
0
def setup_mod_conn(placeboify, params):
    conn = placeboify.client('ec2')
    retry_decorator = aws_retries.AWSRetry.jittered_backoff()
    wrapped_conn = aws_modules._RetryingBotoClientWrapper(
        conn, retry_decorator)
    m = FakeModule(**params)
    return m, wrapped_conn
コード例 #10
0
def test_activate_pipeline(placeboify, maybe_sleep, dp_setup):
    # use objects to define pipeline before activating
    connection = placeboify.client('datapipeline')
    data_pipeline.define_pipeline(connection,
                                  module=dp_setup.module,
                                  objects=dp_setup.objects,
                                  dp_id=dp_setup.data_pipeline_id)
    changed, result = data_pipeline.activate_pipeline(connection, dp_setup.module)
    assert changed is True
コード例 #11
0
def test_find_unique_vi_returns_multiple(placeboify, maybe_sleep):
    client = placeboify.client("directconnect")
    module = FakeModule(state="present",
                        id_to_associate="dxcon-aaaaaaaa",
                        public=False,
                        name=None)
    try:
        aws_direct_connect_virtual_interface.ensure_state(client, module)
    except Exception:
        assert "Multiple virtual interfaces were found" in module.exit_kwargs[
            "msg"]
コード例 #12
0
def test_delete_nonexistent_pipeline(placeboify, maybe_sleep):
    connection = placeboify.client('datapipeline')
    params = {'name': 'ansible-test-nonexistent',
              'description': 'ansible-test-nonexistent',
              'state': 'absent',
              'objects': [],
              'tags': {'ansible': 'test'},
              'timeout': 300}
    m = FakeModule(**params)
    changed, result = data_pipeline.delete_pipeline(connection, m)
    assert changed is False
コード例 #13
0
def test_find_unique_vi_returns_missing_for_vi_id(placeboify, maybe_sleep):
    client = placeboify.client("directconnect")
    module = FakeModule(state="present",
                        id_to_associate=None,
                        public=False,
                        name=None,
                        virtual_interface_id="dxvif-aaaaaaaa")
    try:
        aws_direct_connect_virtual_interface.ensure_state(client, module)
    except Exception:
        assert "The virtual interface dxvif-aaaaaaaa does not exist" in module.exit_kwargs[
            "msg"]
コード例 #14
0
def test_create_pipeline_with_tags(placeboify, maybe_sleep):
    connection = placeboify.client('datapipeline')
    params = {'name': 'ansible-unittest-create-pipeline_tags',
              'description': 'ansible-datapipeline-unit-test',
              'state': 'present',
              'tags': {'ansible': 'test'},
              'timeout': 300}
    m = FakeModule(**params)
    changed, result = data_pipeline.create_pipeline(connection, m)
    assert changed is True
    assert result['msg'] == "Data Pipeline ansible-unittest-create-pipeline_tags created."

    data_pipeline.delete_pipeline(connection, m)
コード例 #15
0
def test_invalid_template_json(placeboify):
    connection = placeboify.client('cloudformation')
    params = {
        'StackName': 'ansible-test-wrong-json',
        'TemplateBody': bad_json_tpl,
    }
    m = FakeModule(disable_rollback=False)
    with pytest.raises(Exception) as exc_info:
        cfn_module.create_stack(m, params, connection, default_events_limit)
        pytest.fail('Expected malformed JSON to have caused the call to fail')

    assert exc_info.match('FAIL')
    assert "ValidationError" in boto_exception(m.exit_args[0])
コード例 #16
0
def test_basic_s3_stack(maybe_sleep, placeboify):
    connection = placeboify.client('cloudformation')
    params = {
        'StackName': 'ansible-test-basic-yaml',
        'TemplateBody': basic_yaml_tpl
    }
    m = FakeModule(disable_rollback=False)
    result = cfn_module.create_stack(m, params, connection,
                                     default_events_limit)
    assert result['changed']
    assert len(result['events']) > 1
    # require that the final recorded stack state was CREATE_COMPLETE
    # events are retrieved newest-first, so 0 is the latest
    assert 'CREATE_COMPLETE' in result['events'][0]
    connection.delete_stack(StackName='ansible-test-basic-yaml')
コード例 #17
0
def test_on_create_failure_delete(maybe_sleep, placeboify):
    m = FakeModule(
        on_create_failure='DELETE',
        disable_rollback=False,
    )
    connection = placeboify.client('cloudformation')
    params = {
        'StackName': 'ansible-test-on-create-failure-delete',
        'TemplateBody': failing_yaml_tpl
    }
    result = cfn_module.create_stack(m, params, connection,
                                     default_events_limit)
    assert result['changed']
    assert result['failed']
    assert len(result['events']) > 1
    # require that the final recorded stack state was DELETE_COMPLETE
    # events are retrieved newest-first, so 0 is the latest
    assert 'DELETE_COMPLETE' in result['events'][0]
コード例 #18
0
def test_update_lag(placeboify, maybe_sleep, dependencies):
    client = placeboify.client("directconnect")
    status_before = lag_module.lag_status(
        client=client, lag_id=dependencies.lag_2.get("lag_id"))
    lag_module.update_lag(client,
                          lag_id=dependencies.lag_2.get("lag_id"),
                          lag_name="ansible_lag_2_update",
                          min_links=0,
                          wait=False,
                          wait_timeout=0,
                          num_connections=1)
    status_after = lag_module.lag_status(
        client=client, lag_id=dependencies.lag_2.get("lag_id"))
    assert status_before != status_after

    # remove the lag name from the statuses and verify it was the only thing changed
    del status_before['lagName']
    del status_after['lagName']
    assert status_before == status_after
def test_delete_vi(placeboify, maybe_sleep):
    client = placeboify.client("directconnect")
    module = FakeModule(state="absent",
                        id_to_associate='dxcon-aaaaaaaa',
                        virtual_interface_id='dxvif-aaaaaaaa',
                        public=False,
                        name="aaaaaaaa",
                        vlan=1,
                        bgp_asn=123,
                        authentication_key="aaaa",
                        customer_address="169.254.0.1/30",
                        amazon_address="169.254.0.2/30",
                        address_type="ipv4",
                        cidr=["10.88.0.0/30"],
                        virtual_gateway_id=None,
                        direct_connect_gateway_id="yyyy")
    changed, latest_state = aws_direct_connect_virtual_interface.ensure_state(client, module)
    assert changed is True
    assert latest_state == {}
コード例 #20
0
def test_delete_nonexistent_lag(placeboify, maybe_sleep):
    client = placeboify.client("directconnect")
    changed = lag_module.ensure_absent(client, "dxlag-XXXXXXXX", "doesntexist",
                                       True, True, True, 120)
    assert not changed
コード例 #21
0
def test_deactivate_pipeline(placeboify, maybe_sleep, dp_setup):
    connection = placeboify.client('datapipeline')
    changed, result = data_pipeline.deactivate_pipeline(connection, dp_setup.module)
    assert "Data Pipeline ansible-test-create-pipeline deactivated" in result['msg']
コード例 #22
0
def test_delete_nonexistent_stack(maybe_sleep, placeboify):
    connection = placeboify.client('cloudformation')
    result = cfn_module.stack_operation(connection, 'ansible-test-nonexist',
                                        'DELETE', default_events_limit)
    assert result['changed']
    assert 'Stack does not exist.' in result['log']
コード例 #23
0
def test_get_nonexistent_stack(placeboify):
    connection = placeboify.client('cloudformation')
    assert cfn_module.get_stack_facts(connection,
                                      'ansible-test-nonexist') is None
コード例 #24
0
def setup_mod_conn(placeboify, params):
    conn = placeboify.client('ec2')
    m = FakeModule(**params)
    return m, conn
コード例 #25
0
def test_delete_lag_with_connections(placeboify, maybe_sleep, dependencies):
    client = placeboify.client("directconnect")
    changed = lag_module.ensure_absent(client,
                                       dependencies.lag_1.get("lag_id"),
                                       "ansible_lag_1", True, True, True, 120)
    assert changed
コード例 #26
0
def test_pipeline_field(placeboify, maybe_sleep, dp_setup):
    connection = placeboify.client('datapipeline')
    pipeline_field_info = data_pipeline.pipeline_field(connection, dp_setup.data_pipeline_id, "@pipelineState")
    assert pipeline_field_info == "PENDING"
コード例 #27
0
def test_activate_without_population(placeboify, maybe_sleep, dp_setup):
    connection = placeboify.client('datapipeline')
    with pytest.raises(Exception) as error_message:
        changed, result = data_pipeline.activate_pipeline(connection, dp_setup.module)
        assert error_message == "You need to populate your pipeline before activation."
コード例 #28
0
def test_check_dp_exists_false(placeboify, maybe_sleep):
    hypothetical_pipeline_id = "df-015440025PF7YGLDK47C"
    connection = placeboify.client('datapipeline')
    exists = data_pipeline.check_dp_exists(connection, hypothetical_pipeline_id)
    assert exists is False
コード例 #29
0
def test_check_dp_exists_true(placeboify, maybe_sleep, dp_setup):
    connection = placeboify.client('datapipeline')
    exists = data_pipeline.check_dp_exists(connection, dp_setup.data_pipeline_id)
    assert exists is True
コード例 #30
0
def test_pipeline_description(placeboify, maybe_sleep, dp_setup):
    connection = placeboify.client('datapipeline')
    dp_id = dp_setup.data_pipeline_id
    pipelines = data_pipeline.pipeline_description(connection, dp_id)
    assert dp_id == pipelines['pipelineDescriptionList'][0]['pipelineId']