[Designate] Modified reverse dns lookup test
Incorporated changes to work for devstack, VIO + NSXV setup Change-Id: Ide5fe03b9409316cc0b3bcc8ba65987335820415
This commit is contained in:
parent
c401e6bac7
commit
938014c712
@ -1002,6 +1002,19 @@ class FeatureManager(traffic_manager.IperfManager,
|
|||||||
self.assertGreater(len(body), 0)
|
self.assertGreater(len(body), 0)
|
||||||
return body
|
return body
|
||||||
|
|
||||||
|
def set_ptr_record(self, region, fip_id, ptrd_name):
|
||||||
|
"""list ptr recordsets associated with floating ip.
|
||||||
|
:param fip_id: Unique FloatingIP ID.
|
||||||
|
"""
|
||||||
|
ptr_id = region + ":" + fip_id
|
||||||
|
ptrd = {
|
||||||
|
"ptrdname": ptrd_name,
|
||||||
|
"description": "This is a floating ip PTR Domain Name",
|
||||||
|
"ttl": 600
|
||||||
|
}
|
||||||
|
_, body = self.ptr_client.set_fip_ptr_record(ptr_id, **ptrd)
|
||||||
|
return body
|
||||||
|
|
||||||
def show_ptr_record(self, region, fip_id, user=None):
|
def show_ptr_record(self, region, fip_id, user=None):
|
||||||
"""list ptr recordsets associated with floating ip.
|
"""list ptr recordsets associated with floating ip.
|
||||||
:param fip_id: Unique FloatingIP ID.
|
:param fip_id: Unique FloatingIP ID.
|
||||||
|
@ -490,3 +490,10 @@ class DesignatePtrClient(designate_base.DnsClientBase):
|
|||||||
Show FloatingIP PTR record
|
Show FloatingIP PTR record
|
||||||
"""
|
"""
|
||||||
return self._show_request(self.path, ptr_id)
|
return self._show_request(self.path, ptr_id)
|
||||||
|
|
||||||
|
def set_fip_ptr_record(self, ptr_id, **ptrd):
|
||||||
|
"""
|
||||||
|
Set FloatingIP PTR record
|
||||||
|
"""
|
||||||
|
resp, body = self._update_request(self.path, ptr_id, ptrd)
|
||||||
|
return resp, body
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
import dns.resolver
|
import dns.resolver
|
||||||
|
|
||||||
|
import subprocess
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
@ -396,52 +398,38 @@ class TestZonesScenario(TestZonesV2Ops):
|
|||||||
'for the instance')
|
'for the instance')
|
||||||
|
|
||||||
@decorators.idempotent_id('2c3c0f63-c557-458f-a8f4-3b0e3065ed97')
|
@decorators.idempotent_id('2c3c0f63-c557-458f-a8f4-3b0e3065ed97')
|
||||||
def test_zone_reverse_nslookup_from_extvm(self):
|
def test_zone_reverse_dnslookup_from_extvm(self):
|
||||||
"""
|
"""
|
||||||
Create a zone
|
Create a floating ip
|
||||||
Update network with zone
|
set a ptr record for the floating ip
|
||||||
Boot an instance and associate fip
|
Perform nslookup for the floating ip from ext vm
|
||||||
Perform nslookup for the dns name from ext vm
|
|
||||||
"""
|
"""
|
||||||
image_id = self.get_glance_image_id(['cirros', 'esx'])
|
fip = self.create_floatingip(client=self.os_admin.floating_ips_client)
|
||||||
zone = self.create_zone()
|
ptr_rev_name = '.'.join(reversed(
|
||||||
network_designate = self.create_zone_topology(zone['name'])
|
fip['floating_ip_address'].split("."))) + ".in-addr.arpa."
|
||||||
self.assertEqual(network_designate['dns_domain'], zone['name'])
|
if CONF.network.region != "":
|
||||||
dns_vm = self.create_topology_instance(
|
region = CONF.network.region
|
||||||
"dns_vm", [network_designate],
|
else:
|
||||||
security_groups=[{'name': self.designate_sg['name']}],
|
region = const.REGION_NAME
|
||||||
clients=self.os_adm,
|
self.set_ptr_record(region, fip['id'], ptr_rev_name)
|
||||||
create_floating_ip=True, image_id=image_id)
|
ptr_record = self.show_ptr_record(region, fip['id'])
|
||||||
fip = dns_vm['floating_ips'][0]['floating_ip_address']
|
self.assertEqual(fip['floating_ip_address'],
|
||||||
fip_id = dns_vm['floating_ips'][0]['id']
|
ptr_record[1]['address'])
|
||||||
ptr_rev_name = '.'.join(reversed(fip.split("."))) + ".in-addr.arpa"
|
|
||||||
LOG.info('Show recordset of the zone')
|
|
||||||
recordset = self.list_record_set_zone(zone['id'])
|
|
||||||
self.verify_recordset(recordset, 3)
|
|
||||||
record = self.verify_recordset_floatingip(recordset, fip)
|
|
||||||
if record is None:
|
|
||||||
raise Exception('fip is missing in the recordset')
|
|
||||||
my_resolver = dns.resolver.Resolver()
|
|
||||||
if type(CONF.dns.nameservers) is list:
|
if type(CONF.dns.nameservers) is list:
|
||||||
nameserver = CONF.dns.nameservers[0][:-3]
|
nameserver = CONF.dns.nameservers[0][:-3]
|
||||||
else:
|
else:
|
||||||
nameserver = CONF.dns.nameservers.split(":")[0]
|
nameserver = CONF.dns.nameservers.split(":")[0]
|
||||||
my_resolver.nameservers = [nameserver]
|
nslookup_cmd = "nslookup %s %s" % (fip['floating_ip_address'],
|
||||||
# wait for status to change from pending to active
|
nameserver)
|
||||||
time.sleep(const.ZONE_WAIT_TIME)
|
|
||||||
region = const.REGION_NAME
|
|
||||||
# check PTR record
|
|
||||||
ptr_record = self.show_ptr_record(region, fip_id)
|
|
||||||
self.assertEqual(fip, ptr_record[1]['address'])
|
|
||||||
try:
|
try:
|
||||||
answer = my_resolver.query(ptr_rev_name, "PTR")
|
output = subprocess.check_output(
|
||||||
|
nslookup_cmd, shell=True)
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.error('ns lookup failed on ext-vm')
|
LOG.error('Reverse dns lookup failed on ext-vm')
|
||||||
if (ptr_rev_name not in answer.response.to_text()
|
if ptr_rev_name not in output:
|
||||||
or record['name'] not in answer.response.to_text()):
|
LOG.error('failed to perform reverse dns for the floating ip')
|
||||||
LOG.error('failed to perform reverse dns for the instance')
|
|
||||||
raise Exception('Reverse DNS response does not have entry '
|
raise Exception('Reverse DNS response does not have entry '
|
||||||
'for the instance')
|
'for the floating ip')
|
||||||
|
|
||||||
@decorators.idempotent_id('6286cbd5-b0e4-4daa-9d8f-f27802c95925')
|
@decorators.idempotent_id('6286cbd5-b0e4-4daa-9d8f-f27802c95925')
|
||||||
def test_zone_deletion_post_fip_association(self):
|
def test_zone_deletion_post_fip_association(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user