Browse Source

Update tests to handle new status related params/data

pull/819/head
Ross McFarland 4 years ago
parent
commit
81ef5f5b89
No known key found for this signature in database GPG Key ID: 943B179E15D3B22A
1 changed files with 85 additions and 20 deletions
  1. +85
    -20
      tests/test_octodns_provider_route53.py

+ 85
- 20
tests/test_octodns_provider_route53.py View File

@ -199,24 +199,24 @@ dynamic_record_data = {
'ap-southeast-1': { 'ap-southeast-1': {
'fallback': 'us-east-1', 'fallback': 'us-east-1',
'values': [{ 'values': [{
'weight': 2, 'value': '1.4.1.1'
'weight': 2, 'value': '1.4.1.1', 'status': 'up',
}, { }, {
'weight': 2, 'value': '1.4.1.2'
'weight': 2, 'value': '1.4.1.2', 'status': 'up',
}] }]
}, },
'eu-central-1': { 'eu-central-1': {
'fallback': 'us-east-1', 'fallback': 'us-east-1',
'values': [{ 'values': [{
'weight': 1, 'value': '1.3.1.1'
'weight': 1, 'value': '1.3.1.1', 'status': 'up',
}, { }, {
'weight': 1, 'value': '1.3.1.2'
'weight': 1, 'value': '1.3.1.2', 'status': 'up',
}], }],
}, },
'us-east-1': { 'us-east-1': {
'values': [{ 'values': [{
'weight': 1, 'value': '1.5.1.1'
'weight': 1, 'value': '1.5.1.1', 'status': 'up',
}, { }, {
'weight': 1, 'value': '1.5.1.2'
'weight': 1, 'value': '1.5.1.2', 'status': 'up',
}], }],
} }
}, },
@ -296,6 +296,9 @@ class TestRoute53Provider(TestCase):
'Id': '42', 'Id': '42',
'CallerReference': caller_ref, 'CallerReference': caller_ref,
'HealthCheckConfig': { 'HealthCheckConfig': {
'Disabled': False,
'EnableSNI': True,
'Inverted': False,
'Type': 'HTTPS', 'Type': 'HTTPS',
'FullyQualifiedDomainName': 'unit.tests', 'FullyQualifiedDomainName': 'unit.tests',
'IPAddress': '4.2.3.4', 'IPAddress': '4.2.3.4',
@ -310,6 +313,9 @@ class TestRoute53Provider(TestCase):
'Id': 'ignored-also', 'Id': 'ignored-also',
'CallerReference': 'something-else', 'CallerReference': 'something-else',
'HealthCheckConfig': { 'HealthCheckConfig': {
'Disabled': False,
'EnableSNI': True,
'Inverted': False,
'Type': 'HTTPS', 'Type': 'HTTPS',
'FullyQualifiedDomainName': 'unit.tests', 'FullyQualifiedDomainName': 'unit.tests',
'IPAddress': '5.2.3.4', 'IPAddress': '5.2.3.4',
@ -324,6 +330,9 @@ class TestRoute53Provider(TestCase):
'Id': '43', 'Id': '43',
'CallerReference': caller_ref, 'CallerReference': caller_ref,
'HealthCheckConfig': { 'HealthCheckConfig': {
'Disabled': False,
'EnableSNI': True,
'Inverted': False,
'Type': 'HTTPS', 'Type': 'HTTPS',
'FullyQualifiedDomainName': 'unit.tests', 'FullyQualifiedDomainName': 'unit.tests',
'IPAddress': '5.2.3.4', 'IPAddress': '5.2.3.4',
@ -338,6 +347,9 @@ class TestRoute53Provider(TestCase):
'Id': '44', 'Id': '44',
'CallerReference': caller_ref, 'CallerReference': caller_ref,
'HealthCheckConfig': { 'HealthCheckConfig': {
'Disabled': False,
'EnableSNI': True,
'Inverted': False,
'Type': 'HTTPS', 'Type': 'HTTPS',
'FullyQualifiedDomainName': 'unit.tests', 'FullyQualifiedDomainName': 'unit.tests',
'IPAddress': '7.2.3.4', 'IPAddress': '7.2.3.4',
@ -353,6 +365,9 @@ class TestRoute53Provider(TestCase):
# won't match anything based on type # won't match anything based on type
'CallerReference': caller_ref.replace(':A:', ':AAAA:'), 'CallerReference': caller_ref.replace(':A:', ':AAAA:'),
'HealthCheckConfig': { 'HealthCheckConfig': {
'Disabled': False,
'EnableSNI': True,
'Inverted': False,
'Type': 'HTTPS', 'Type': 'HTTPS',
'FullyQualifiedDomainName': 'unit.tests', 'FullyQualifiedDomainName': 'unit.tests',
'IPAddress': '7.2.3.4', 'IPAddress': '7.2.3.4',
@ -1161,6 +1176,9 @@ class TestRoute53Provider(TestCase):
'Id': '42', 'Id': '42',
'CallerReference': self.caller_ref, 'CallerReference': self.caller_ref,
'HealthCheckConfig': { 'HealthCheckConfig': {
'Disabled': False,
'EnableSNI': True,
'Inverted': False,
'Type': 'HTTPS', 'Type': 'HTTPS',
'FullyQualifiedDomainName': 'unit.tests', 'FullyQualifiedDomainName': 'unit.tests',
'IPAddress': '4.2.3.4', 'IPAddress': '4.2.3.4',
@ -1175,6 +1193,9 @@ class TestRoute53Provider(TestCase):
'Id': '43', 'Id': '43',
'CallerReference': 'abc123', 'CallerReference': 'abc123',
'HealthCheckConfig': { 'HealthCheckConfig': {
'Disabled': False,
'EnableSNI': True,
'Inverted': False,
'Type': 'HTTPS', 'Type': 'HTTPS',
'FullyQualifiedDomainName': 'unit.tests', 'FullyQualifiedDomainName': 'unit.tests',
'IPAddress': '9.2.3.4', 'IPAddress': '9.2.3.4',
@ -1199,6 +1220,9 @@ class TestRoute53Provider(TestCase):
'Id': '44', 'Id': '44',
'CallerReference': self.caller_ref, 'CallerReference': self.caller_ref,
'HealthCheckConfig': { 'HealthCheckConfig': {
'Disabled': False,
'EnableSNI': True,
'Inverted': False,
'Type': 'HTTPS', 'Type': 'HTTPS',
'FullyQualifiedDomainName': 'unit.tests', 'FullyQualifiedDomainName': 'unit.tests',
'IPAddress': '8.2.3.4', 'IPAddress': '8.2.3.4',
@ -1248,6 +1272,9 @@ class TestRoute53Provider(TestCase):
# No match based on version # No match based on version
'CallerReference': '9999:A:foo1234', 'CallerReference': '9999:A:foo1234',
'HealthCheckConfig': { 'HealthCheckConfig': {
'Disabled': False,
'EnableSNI': True,
'Inverted': False,
'Type': 'HTTPS', 'Type': 'HTTPS',
'FullyQualifiedDomainName': 'unit.tests', 'FullyQualifiedDomainName': 'unit.tests',
'IPAddress': '4.2.3.4', 'IPAddress': '4.2.3.4',
@ -1262,6 +1289,9 @@ class TestRoute53Provider(TestCase):
'Id': '43', 'Id': '43',
'CallerReference': caller_ref, 'CallerReference': caller_ref,
'HealthCheckConfig': { 'HealthCheckConfig': {
'Disabled': False,
'EnableSNI': True,
'Inverted': False,
'Type': 'HTTPS', 'Type': 'HTTPS',
'FullyQualifiedDomainName': 'unit.tests', 'FullyQualifiedDomainName': 'unit.tests',
'IPAddress': '4.2.3.4', 'IPAddress': '4.2.3.4',
@ -1281,7 +1311,9 @@ class TestRoute53Provider(TestCase):
}) })
health_check_config = { health_check_config = {
'Disabled': False,
'EnableSNI': False, 'EnableSNI': False,
'Inverted': False,
'FailureThreshold': 6, 'FailureThreshold': 6,
'FullyQualifiedDomainName': 'foo.bar.com', 'FullyQualifiedDomainName': 'foo.bar.com',
'IPAddress': '4.2.3.4', 'IPAddress': '4.2.3.4',
@ -1306,7 +1338,9 @@ class TestRoute53Provider(TestCase):
stubber.add_response('change_tags_for_resource', {}) stubber.add_response('change_tags_for_resource', {})
health_check_config = { health_check_config = {
'Disabled': False,
'EnableSNI': False, 'EnableSNI': False,
'Inverted': False,
'FailureThreshold': 6, 'FailureThreshold': 6,
'FullyQualifiedDomainName': '4.2.3.4', 'FullyQualifiedDomainName': '4.2.3.4',
'IPAddress': '4.2.3.4', 'IPAddress': '4.2.3.4',
@ -1349,23 +1383,25 @@ class TestRoute53Provider(TestCase):
# if not allowed to create returns none # if not allowed to create returns none
value = record.geo['AF'].values[0] value = record.geo['AF'].values[0]
id = provider.get_health_check_id(record, value, False)
id = provider.get_health_check_id(record, value, 'obey', False)
self.assertFalse(id) self.assertFalse(id)
# when allowed to create we do # when allowed to create we do
id = provider.get_health_check_id(record, value, True)
id = provider.get_health_check_id(record, value, 'obey', True)
self.assertEquals('42', id) self.assertEquals('42', id)
# when allowed to create and when host is None # when allowed to create and when host is None
record._octodns['healthcheck']['host'] = None record._octodns['healthcheck']['host'] = None
id = provider.get_health_check_id(record, value, True)
id = provider.get_health_check_id(record, value, 'obey', True)
self.assertEquals('43', id) self.assertEquals('43', id)
stubber.assert_no_pending_responses() stubber.assert_no_pending_responses()
# A CNAME style healthcheck, without a value # A CNAME style healthcheck, without a value
health_check_config = { health_check_config = {
'Disabled': False,
'EnableSNI': False, 'EnableSNI': False,
'Inverted': False,
'FailureThreshold': 6, 'FailureThreshold': 6,
'FullyQualifiedDomainName': 'target-1.unit.tests.', 'FullyQualifiedDomainName': 'target-1.unit.tests.',
'MeasureLatency': True, 'MeasureLatency': True,
@ -1388,14 +1424,17 @@ class TestRoute53Provider(TestCase):
}) })
stubber.add_response('change_tags_for_resource', {}) stubber.add_response('change_tags_for_resource', {})
id = provider.get_health_check_id(record, 'target-1.unit.tests.', True)
id = provider.get_health_check_id(record, 'target-1.unit.tests.',
'obey', True)
self.assertEquals('42', id) self.assertEquals('42', id)
stubber.assert_no_pending_responses() stubber.assert_no_pending_responses()
# TCP health check # TCP health check
health_check_config = { health_check_config = {
'Disabled': False,
'EnableSNI': False, 'EnableSNI': False,
'Inverted': False,
'FailureThreshold': 6, 'FailureThreshold': 6,
'MeasureLatency': True, 'MeasureLatency': True,
'Port': 8080, 'Port': 8080,
@ -1417,7 +1456,8 @@ class TestRoute53Provider(TestCase):
stubber.add_response('change_tags_for_resource', {}) stubber.add_response('change_tags_for_resource', {})
record._octodns['healthcheck']['protocol'] = 'TCP' record._octodns['healthcheck']['protocol'] = 'TCP'
id = provider.get_health_check_id(record, 'target-1.unit.tests.', True)
id = provider.get_health_check_id(record, 'target-1.unit.tests.',
'obey', True)
self.assertEquals('42', id) self.assertEquals('42', id)
stubber.assert_no_pending_responses() stubber.assert_no_pending_responses()
@ -1494,7 +1534,9 @@ class TestRoute53Provider(TestCase):
provider, stubber = self._get_stubbed_provider() provider, stubber = self._get_stubbed_provider()
health_check_config = { health_check_config = {
'Disabled': False,
'EnableSNI': True, 'EnableSNI': True,
'Inverted': False,
'FailureThreshold': 6, 'FailureThreshold': 6,
'FullyQualifiedDomainName': 'a.unit.tests', 'FullyQualifiedDomainName': 'a.unit.tests',
'IPAddress': '1.2.3.4', 'IPAddress': '1.2.3.4',
@ -1547,7 +1589,7 @@ class TestRoute53Provider(TestCase):
}) })
value = record.geo['AF'].values[0] value = record.geo['AF'].values[0]
id = provider.get_health_check_id(record, value, True)
id = provider.get_health_check_id(record, value, 'obey', True)
ml = provider.health_checks[id]['HealthCheckConfig']['MeasureLatency'] ml = provider.health_checks[id]['HealthCheckConfig']['MeasureLatency']
ri = provider.health_checks[id]['HealthCheckConfig']['RequestInterval'] ri = provider.health_checks[id]['HealthCheckConfig']['RequestInterval']
self.assertFalse(ml) self.assertFalse(ml)
@ -1636,6 +1678,9 @@ class TestRoute53Provider(TestCase):
'Id': '42', 'Id': '42',
'CallerReference': self.caller_ref, 'CallerReference': self.caller_ref,
'HealthCheckConfig': { 'HealthCheckConfig': {
'Disabled': False,
'EnableSNI': True,
'Inverted': False,
'Type': 'HTTPS', 'Type': 'HTTPS',
'FullyQualifiedDomainName': 'unit.tests', 'FullyQualifiedDomainName': 'unit.tests',
'IPAddress': '4.2.3.4', 'IPAddress': '4.2.3.4',
@ -1650,6 +1695,9 @@ class TestRoute53Provider(TestCase):
'Id': '43', 'Id': '43',
'CallerReference': old_caller_ref, 'CallerReference': old_caller_ref,
'HealthCheckConfig': { 'HealthCheckConfig': {
'Disabled': False,
'EnableSNI': True,
'Inverted': False,
'Type': 'HTTPS', 'Type': 'HTTPS',
'FullyQualifiedDomainName': 'unit.tests', 'FullyQualifiedDomainName': 'unit.tests',
'IPAddress': '4.2.3.4', 'IPAddress': '4.2.3.4',
@ -1664,6 +1712,9 @@ class TestRoute53Provider(TestCase):
'Id': '44', 'Id': '44',
'CallerReference': old_caller_ref, 'CallerReference': old_caller_ref,
'HealthCheckConfig': { 'HealthCheckConfig': {
'Disabled': False,
'EnableSNI': True,
'Inverted': False,
'Type': 'HTTPS', 'Type': 'HTTPS',
'FullyQualifiedDomainName': 'other.unit.tests', 'FullyQualifiedDomainName': 'other.unit.tests',
'IPAddress': '4.2.3.4', 'IPAddress': '4.2.3.4',
@ -2105,6 +2156,9 @@ class TestRoute53Provider(TestCase):
'Id': '42', 'Id': '42',
'CallerReference': 'foo', 'CallerReference': 'foo',
'HealthCheckConfig': { 'HealthCheckConfig': {
'Disabled': False,
'EnableSNI': True,
'Inverted': False,
'Type': 'HTTPS', 'Type': 'HTTPS',
'FullyQualifiedDomainName': 'unit.tests', 'FullyQualifiedDomainName': 'unit.tests',
'IPAddress': '2.2.3.4', 'IPAddress': '2.2.3.4',
@ -2210,6 +2264,9 @@ class TestRoute53Provider(TestCase):
'Id': '42', 'Id': '42',
'CallerReference': self.caller_ref, 'CallerReference': self.caller_ref,
'HealthCheckConfig': { 'HealthCheckConfig': {
'Disabled': False,
'EnableSNI': True,
'Inverted': False,
'Type': 'HTTPS', 'Type': 'HTTPS',
'FullyQualifiedDomainName': 'a.unit.tests', 'FullyQualifiedDomainName': 'a.unit.tests',
'IPAddress': '2.2.3.4', 'IPAddress': '2.2.3.4',
@ -2359,6 +2416,9 @@ class TestRoute53Provider(TestCase):
'Id': '42', 'Id': '42',
'CallerReference': self.caller_ref, 'CallerReference': self.caller_ref,
'HealthCheckConfig': { 'HealthCheckConfig': {
'Disabled': False,
'EnableSNI': True,
'Inverted': False,
'Type': 'HTTPS', 'Type': 'HTTPS',
'FullyQualifiedDomainName': 'a.unit.tests', 'FullyQualifiedDomainName': 'a.unit.tests',
'IPAddress': '2.2.3.4', 'IPAddress': '2.2.3.4',
@ -2517,6 +2577,9 @@ class TestRoute53Provider(TestCase):
'Id': '42', 'Id': '42',
'CallerReference': self.caller_ref, 'CallerReference': self.caller_ref,
'HealthCheckConfig': { 'HealthCheckConfig': {
'Disabled': False,
'EnableSNI': True,
'Inverted': False,
'Type': 'HTTPS', 'Type': 'HTTPS',
'FullyQualifiedDomainName': 'one.cname.unit.tests.', 'FullyQualifiedDomainName': 'one.cname.unit.tests.',
'ResourcePath': '/_dns', 'ResourcePath': '/_dns',
@ -2695,6 +2758,7 @@ class TestRoute53Provider(TestCase):
def test_data_for_dynamic(self): def test_data_for_dynamic(self):
provider = Route53Provider('test', 'abc', '123') provider = Route53Provider('test', 'abc', '123')
provider._health_checks = {}
data = provider._data_for_dynamic('', 'A', dynamic_rrsets) data = provider._data_for_dynamic('', 'A', dynamic_rrsets)
self.assertEquals(dynamic_record_data, data) self.assertEquals(dynamic_record_data, data)
@ -2703,6 +2767,7 @@ class TestRoute53Provider(TestCase):
@patch('octodns.provider.route53.Route53Provider._load_records') @patch('octodns.provider.route53.Route53Provider._load_records')
def test_dynamic_populate(self, load_records_mock, get_zone_id_mock): def test_dynamic_populate(self, load_records_mock, get_zone_id_mock):
provider = Route53Provider('test', 'abc', '123') provider = Route53Provider('test', 'abc', '123')
provider._health_checks = {}
get_zone_id_mock.side_effect = ['z44'] get_zone_id_mock.side_effect = ['z44']
load_records_mock.side_effect = [dynamic_rrsets] load_records_mock.side_effect = [dynamic_rrsets]
@ -2724,25 +2789,25 @@ class TestRoute53Provider(TestCase):
'ap-southeast-1': { 'ap-southeast-1': {
'fallback': 'us-east-1', 'fallback': 'us-east-1',
'values': [{ 'values': [{
'weight': 2, 'value': '1.4.1.1', 'status': 'obey',
'weight': 2, 'value': '1.4.1.1', 'status': 'up',
}, { }, {
'weight': 2, 'value': '1.4.1.2', 'status': 'obey',
'weight': 2, 'value': '1.4.1.2', 'status': 'up',
}] }]
}, },
'eu-central-1': { 'eu-central-1': {
'fallback': 'us-east-1', 'fallback': 'us-east-1',
'values': [{ 'values': [{
'weight': 1, 'value': '1.3.1.1', 'status': 'obey',
'weight': 1, 'value': '1.3.1.1', 'status': 'up',
}, { }, {
'weight': 1, 'value': '1.3.1.2', 'status': 'obey',
'weight': 1, 'value': '1.3.1.2', 'status': 'up',
}], }],
}, },
'us-east-1': { 'us-east-1': {
'fallback': None, 'fallback': None,
'values': [{ 'values': [{
'weight': 1, 'value': '1.5.1.1', 'status': 'obey',
'weight': 1, 'value': '1.5.1.1', 'status': 'up',
}, { }, {
'weight': 1, 'value': '1.5.1.2', 'status': 'obey',
'weight': 1, 'value': '1.5.1.2', 'status': 'up',
}], }],
} }
}, {k: v.data for k, v in record.dynamic.pools.items()}) }, {k: v.data for k, v in record.dynamic.pools.items()})
@ -2905,7 +2970,7 @@ class TestRoute53Records(TestCase):
def test_dynamic_value_delete(self): def test_dynamic_value_delete(self):
provider = DummyProvider() provider = DummyProvider()
geo = _Route53DynamicValue(provider, self.record_a, 'iad', '2.2.2.2', geo = _Route53DynamicValue(provider, self.record_a, 'iad', '2.2.2.2',
1, 0, False)
1, 'obey', 0, False)
rrset = { rrset = {
'HealthCheckId': 'x12346z', 'HealthCheckId': 'x12346z',
@ -3008,7 +3073,7 @@ class TestRoute53Records(TestCase):
# thoroughly tested elsewhere # thoroughly tested elsewhere
provider._health_checks = {} provider._health_checks = {}
# When asked for a healthcheck return dummy info # When asked for a healthcheck return dummy info
provider.get_health_check_id = lambda r, v, c: 'hc42'
provider.get_health_check_id = lambda r, v, s, c: 'hc42'
zone = Zone('unit.tests.', []) zone = Zone('unit.tests.', [])
record = Record.new(zone, '', dynamic_record_data) record = Record.new(zone, '', dynamic_record_data)


Loading…
Cancel
Save