Browse Source

Move measure_latency option to Route53 provider

pull/321/head
Jörg Runkel 7 years ago
parent
commit
54787529d5
5 changed files with 133 additions and 17 deletions
  1. +20
    -2
      docs/records.md
  2. +12
    -5
      octodns/provider/route53.py
  3. +0
    -7
      octodns/record/__init__.py
  4. +101
    -0
      tests/test_octodns_provider_route53.py
  5. +0
    -3
      tests/test_octodns_record.py

+ 20
- 2
docs/records.md View File

@ -89,7 +89,6 @@ test:
octodns: octodns:
healthcheck: healthcheck:
host: my-host-name host: my-host-name
measure_latency: 0
path: /dns-health-check path: /dns-health-check
port: 443 port: 443
protocol: HTTPS protocol: HTTPS
@ -101,7 +100,26 @@ test:
| path | path to check | _dns | | path | path to check | _dns |
| port | port to check | 443 | | port | port to check | 443 |
| protocol | HTTP/HTTPS | HTTPS | | protocol | HTTP/HTTPS | HTTPS |
| measure_latency | Route53 only: Show latency in AWS console | true |
#### Route53 Healtch Check Options
| Key | Description | Default |
|--|--|--|
| measure_latency | Show latency in AWS console | true |
```yaml
---
octodns:
healthcheck:
host: my-host-name
path: /dns-health-check
port: 443
protocol: HTTPS
route53:
healthcheck:
measure_latency: false
```
## Config (`YamlProvider`) ## Config (`YamlProvider`)


+ 12
- 5
octodns/provider/route53.py View File

@ -545,6 +545,13 @@ class Route53Provider(BaseProvider):
# We've got a cached version use it # We've got a cached version use it
return self._health_checks return self._health_checks
def _healthcheck_measure_latency(self, record):
return (
record._octodns.get('route53', {})
.get('healthcheck', {})
.get('measure_latency', True)
)
def _health_check_equivilent(self, host, path, protocol, port, def _health_check_equivilent(self, host, path, protocol, port,
measure_latency, health_check, measure_latency, health_check,
first_value=None): first_value=None):
@ -570,7 +577,7 @@ class Route53Provider(BaseProvider):
healthcheck_path = record.healthcheck_path healthcheck_path = record.healthcheck_path
healthcheck_protocol = record.healthcheck_protocol healthcheck_protocol = record.healthcheck_protocol
healthcheck_port = record.healthcheck_port healthcheck_port = record.healthcheck_port
healthcheck_measure_latency = record.healthcheck_measure_latency
healthcheck_latency = self._healthcheck_measure_latency(record)
# we're looking for a healthcheck with the current version & our record # we're looking for a healthcheck with the current version & our record
# type, we'll ignore anything else # type, we'll ignore anything else
@ -584,7 +591,7 @@ class Route53Provider(BaseProvider):
healthcheck_path, healthcheck_path,
healthcheck_protocol, healthcheck_protocol,
healthcheck_port, healthcheck_port,
healthcheck_measure_latency,
healthcheck_latency,
health_check, health_check,
first_value=first_value): first_value=first_value):
# this is the health check we're looking for # this is the health check we're looking for
@ -602,7 +609,7 @@ class Route53Provider(BaseProvider):
'FailureThreshold': 6, 'FailureThreshold': 6,
'FullyQualifiedDomainName': healthcheck_host, 'FullyQualifiedDomainName': healthcheck_host,
'IPAddress': first_value, 'IPAddress': first_value,
'MeasureLatency': healthcheck_measure_latency,
'MeasureLatency': healthcheck_latency,
'Port': healthcheck_port, 'Port': healthcheck_port,
'RequestInterval': 10, 'RequestInterval': 10,
'ResourcePath': healthcheck_path, 'ResourcePath': healthcheck_path,
@ -622,7 +629,7 @@ class Route53Provider(BaseProvider):
'first_value=%s', 'first_value=%s',
id, healthcheck_host, healthcheck_path, id, healthcheck_host, healthcheck_path,
healthcheck_protocol, healthcheck_port, healthcheck_protocol, healthcheck_port,
healthcheck_measure_latency, first_value)
healthcheck_latency, first_value)
return id return id
def _gc_health_checks(self, record, new): def _gc_health_checks(self, record, new):
@ -735,7 +742,7 @@ class Route53Provider(BaseProvider):
healthcheck_path = record.healthcheck_path healthcheck_path = record.healthcheck_path
healthcheck_protocol = record.healthcheck_protocol healthcheck_protocol = record.healthcheck_protocol
healthcheck_port = record.healthcheck_port healthcheck_port = record.healthcheck_port
healthcheck_latency = record.healthcheck_measure_latency
healthcheck_latency = self._healthcheck_measure_latency(record)
fqdn = record.fqdn fqdn = record.fqdn
# loop through all the r53 rrsets # loop through all the r53 rrsets


+ 0
- 7
octodns/record/__init__.py View File

@ -189,13 +189,6 @@ class Record(object):
except KeyError: except KeyError:
return 443 return 443
@property
def healthcheck_measure_latency(self):
try:
return bool(self._octodns['healthcheck']['measure_latency'])
except KeyError:
return True
def changes(self, other, target): def changes(self, other, target):
# We're assuming we have the same name and type if we're being compared # We're assuming we have the same name and type if we're being compared
if self.ttl != other.ttl: if self.ttl != other.ttl:


+ 101
- 0
tests/test_octodns_provider_route53.py View File

@ -868,6 +868,107 @@ class TestRoute53Provider(TestCase):
self.assertEquals('42', id) self.assertEquals('42', id)
stubber.assert_no_pending_responses() stubber.assert_no_pending_responses()
def test_health_check_measure_latency(self):
provider, stubber = self._get_stubbed_provider()
record_true = Record.new(self.expected, 'a', {
'ttl': 61,
'type': 'A',
'value': '1.2.3.4',
'octodns': {
'healthcheck': {
},
'route53': {
'healthcheck': {
'measure_latency': True
}
}
}
})
measure_latency = provider._healthcheck_measure_latency(record_true)
self.assertEquals(True, measure_latency)
record_default = Record.new(self.expected, 'a', {
'ttl': 61,
'type': 'A',
'value': '1.2.3.4',
})
measure_latency = provider._healthcheck_measure_latency(record_default)
self.assertEquals(True, measure_latency)
record_false = Record.new(self.expected, 'a', {
'ttl': 61,
'type': 'A',
'value': '1.2.3.4',
'octodns': {
'healthcheck': {
},
'route53': {
'healthcheck': {
'measure_latency': False
}
}
}
})
measure_latency = provider._healthcheck_measure_latency(record_false)
self.assertEquals(False, measure_latency)
def test_create_health_checks_measure_latency(self):
provider, stubber = self._get_stubbed_provider()
health_check_config = {
'EnableSNI': True,
'FailureThreshold': 6,
'FullyQualifiedDomainName': 'a.unit.tests',
'IPAddress': '1.2.3.4',
'MeasureLatency': False,
'Port': 443,
'RequestInterval': 10,
'ResourcePath': '/_dns',
'Type': 'HTTPS'
}
stubber.add_response('list_health_checks', {
'HealthChecks': [],
'IsTruncated': False,
'MaxItems': '100',
'Marker': '',
})
stubber.add_response('create_health_check', {
'HealthCheck': {
'Id': '42',
'CallerReference': self.caller_ref,
'HealthCheckConfig': health_check_config,
'HealthCheckVersion': 1,
},
'Location': 'http://url',
}, {
'CallerReference': ANY,
'HealthCheckConfig': health_check_config,
})
record = Record.new(self.expected, 'a', {
'ttl': 61,
'type': 'A',
'value': '2.2.3.4',
'geo': {
'AF': ['1.2.3.4'],
},
'octodns': {
'healthcheck': {
},
'route53': {
'healthcheck': {
'measure_latency': False
}
}
}
})
id = provider.get_health_check_id(record, 'AF', record.geo['AF'], True)
ml = provider.health_checks[id]['HealthCheckConfig']['MeasureLatency']
self.assertEqual(False, ml)
def test_health_check_gc(self): def test_health_check_gc(self):
provider, stubber = self._get_stubbed_provider() provider, stubber = self._get_stubbed_provider()


+ 0
- 3
tests/test_octodns_record.py View File

@ -757,7 +757,6 @@ class TestRecord(TestCase):
'host': 'bleep.bloop', 'host': 'bleep.bloop',
'protocol': 'HTTP', 'protocol': 'HTTP',
'port': 8080, 'port': 8080,
'measure_latency': False
} }
} }
}) })
@ -765,7 +764,6 @@ class TestRecord(TestCase):
self.assertEquals('bleep.bloop', new.healthcheck_host) self.assertEquals('bleep.bloop', new.healthcheck_host)
self.assertEquals('HTTP', new.healthcheck_protocol) self.assertEquals('HTTP', new.healthcheck_protocol)
self.assertEquals(8080, new.healthcheck_port) self.assertEquals(8080, new.healthcheck_port)
self.assertEquals(False, new.healthcheck_measure_latency)
new = Record.new(self.zone, 'a', { new = Record.new(self.zone, 'a', {
'ttl': 44, 'ttl': 44,
@ -776,7 +774,6 @@ class TestRecord(TestCase):
self.assertEquals('a.unit.tests', new.healthcheck_host) self.assertEquals('a.unit.tests', new.healthcheck_host)
self.assertEquals('HTTPS', new.healthcheck_protocol) self.assertEquals('HTTPS', new.healthcheck_protocol)
self.assertEquals(443, new.healthcheck_port) self.assertEquals(443, new.healthcheck_port)
self.assertEquals(True, new.healthcheck_measure_latency)
def test_inored(self): def test_inored(self):
new = Record.new(self.zone, 'txt', { new = Record.new(self.zone, 'txt', {


Loading…
Cancel
Save