Пример #1
0
def test_get_dns_name_region_in_suffix(mocker):
    get_target_region_mock = mocker.patch('mount_efs.get_target_region')

    for special_region in SPECIAL_REGIONS:
        special_dns_name_suffix = SPECIAL_REGION_DNS_DICT[special_region]
        dns_name_suffix = '%s.%s' % (special_region, special_dns_name_suffix)

        config = _get_mock_config('{fs_id}.efs.{dns_name_suffix}',
                                  dns_name_suffix=dns_name_suffix)

        dns_name = mount_efs.get_dns_name(config, FS_ID, DEFAULT_NFS_OPTIONS)

        utils.assert_not_called(get_target_region_mock)

        assert '%s.efs.%s.%s' % (FS_ID, special_region,
                                 special_dns_name_suffix) == dns_name
Пример #2
0
def test_get_dns_name_special_region(mocker):
    for special_region in SPECIAL_REGIONS:
        mocker.patch('mount_efs.get_target_region',
                     return_value=special_region)

        config_section = 'mount.%s' % special_region
        special_dns_name_suffix = SPECIAL_REGION_DNS_DICT[special_region]

        config = _get_mock_config(dns_name_suffix=special_dns_name_suffix,
                                  config_section=config_section)
        config.has_section.return_value = True

        dns_name = mount_efs.get_dns_name(config, FS_ID, DEFAULT_NFS_OPTIONS)

        assert '%s.efs.%s.%s' % (FS_ID, special_region,
                                 special_dns_name_suffix) == dns_name
Пример #3
0
def test_match_device_fqdn_same_as_dns_name(mocker, capsys):
    dns_name = '%s.efs.us-east-1.amazonaws.com' % FS_ID
    gethostbyname_ex_mock = mocker.patch('socket.gethostbyname_ex',
                                         return_value=(dns_name, [], None))
    efs_fqdn_match = mount_efs.EFS_FQDN_RE.match(dns_name)
    assert efs_fqdn_match
    assert FS_ID == efs_fqdn_match.group('fs_id')

    config = _get_new_mock_config()
    expected_dns_name = mount_efs.get_dns_name(config, FS_ID,
                                               DEFAULT_NFS_OPTIONS)
    assert dns_name == expected_dns_name
    for device, (fs_id, path, az) in CORRECT_DEVICE_DESCRIPTORS_CNAME_DNS:
        assert (fs_id, path,
                az) == mount_efs.match_device(config, device,
                                              DEFAULT_NFS_OPTIONS)
    utils.assert_called(gethostbyname_ex_mock)
Пример #4
0
def test_get_dns_name(mocker):
    config = _get_mock_config()

    dns_name = mount_efs.get_dns_name(config, FS_ID)

    assert '%s.efs.%s.amazonaws.com' % (FS_ID, DEFAULT_REGION) == dns_name
Пример #5
0
def test_get_dns_name_suffix_hardcoded(mocker):
    config = _get_mock_config('{az}.{fs_id}.efs.{region}.amazonaws.com')

    dns_name = mount_efs.get_dns_name(config, FS_ID, DEFAULT_NFS_OPTIONS)

    assert '%s.efs.%s.amazonaws.com' % (FS_ID, DEFAULT_REGION) == dns_name
Пример #6
0
def test_get_dns_name_without_az_in_options(mocker):
    config = _get_mock_config('{az}.{fs_id}.efs.{region}.amazonaws.com')

    dns_name = mount_efs.get_dns_name(config, FS_ID, DEFAULT_NFS_OPTIONS)

    assert '%s.efs.%s.amazonaws.com' % (FS_ID, DEFAULT_REGION) == dns_name
Пример #7
0
def test_get_dns_name_suffix_hardcoded(mocker):
    config = _get_mock_config('{fs_id}.elastic-file-system.{region}.amazonaws.com')

    dns_name = mount_efs.get_dns_name(config, FS_ID)

    assert '%s.elastic-file-system.%s.amazonaws.com' % (FS_ID, DEFAULT_REGION) == dns_name