Commit 1b09f8e1 authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼 Committed by Xavier Thompson

software/powerdns: Fix tests after IPv6 range

parent 1dcaf841
...@@ -37,7 +37,6 @@ import urllib ...@@ -37,7 +37,6 @@ import urllib
from slapos.recipe.librecipe import generateHashFromFiles from slapos.recipe.librecipe import generateHashFromFiles
from slapos.testing.testcase import makeModuleSetUpAndTestCaseClass from slapos.testing.testcase import makeModuleSetUpAndTestCaseClass
skip = unittest.skip('port conflit between powerdns instances') skip = unittest.skip('port conflit between powerdns instances')
setUpModule, SlapOSInstanceTestCase = makeModuleSetUpAndTestCaseClass( setUpModule, SlapOSInstanceTestCase = makeModuleSetUpAndTestCaseClass(
...@@ -93,9 +92,10 @@ class PowerDNSTestCase(SlapOSInstanceTestCase): ...@@ -93,9 +92,10 @@ class PowerDNSTestCase(SlapOSInstanceTestCase):
ns_record = [] ns_record = []
for replicate_nb in range(1, dns_quantity + 1): for replicate_nb in range(1, dns_quantity + 1):
ns_id = 'ns%s' % replicate_nb ns_id = 'ns%s' % replicate_nb
partition_id = self.getPartitionId(ns_id)
ns_record.append(ns_id + '.' + self.default_supported_zone) ns_record.append(ns_id + '.' + self.default_supported_zone)
expected_dict[ns_id + '-port'] = str(DNS_PORT) expected_dict[ns_id + '-port'] = str(DNS_PORT)
expected_dict[ns_id + '-ipv6'] = self.computer_partition_ipv6_address expected_dict[ns_id + '-ipv6'] = self.getPartitionIPv6(partition_id)
expected_dict['ns-record'] = ','.join(ns_record) expected_dict['ns-record'] = ','.join(ns_record)
expected_dict['slave-amount'] = str(slave_amount) expected_dict['slave-amount'] = str(slave_amount)
...@@ -199,11 +199,11 @@ class PowerDNSSlaveTestCase(PowerDNSTestCase): ...@@ -199,11 +199,11 @@ class PowerDNSSlaveTestCase(PowerDNSTestCase):
).getConnectionParameterDict()) ).getConnectionParameterDict())
return parameter_dict_list return parameter_dict_list
def dns_query(self, domain_name, subnet): def dns_query(self, domain_name, subnet, ipv6, port):
message = dns.message.make_query(domain_name, 'A') message = dns.message.make_query(domain_name, 'A')
client_subnet_option = dns.edns.ECSOption(subnet) client_subnet_option = dns.edns.ECSOption(subnet)
message.use_edns(options=[client_subnet_option]) message.use_edns(options=[client_subnet_option])
answer = dns.query.udp(message, self.computer_partition_ipv6_address, port=DNS_PORT) answer = dns.query.udp(message, ipv6, port=port)
return answer.get_rrset( return answer.get_rrset(
dns.message.ANSWER, dns.message.ANSWER,
dns.name.from_text(domain_name), dns.name.from_text(domain_name),
...@@ -211,8 +211,9 @@ class PowerDNSSlaveTestCase(PowerDNSTestCase): ...@@ -211,8 +211,9 @@ class PowerDNSSlaveTestCase(PowerDNSTestCase):
dns.rdatatype.CNAME dns.rdatatype.CNAME
).to_text().split()[-1] ).to_text().split()[-1]
def _test_dns_resolver(self): def _test_dns_resolver(self, dns_quantity):
slave_parameter_dict_dict = self.getSlaveParameterDictDict() slave_parameter_dict_dict = self.getSlaveParameterDictDict()
connection_dict = self.computer_partition.getConnectionParameterDict()
subnet_dict = { subnet_dict = {
'africa': AFRICAN_SUBNET, 'africa': AFRICAN_SUBNET,
'china-telecom': CHINA_TELECOM_SUBNET, 'china-telecom': CHINA_TELECOM_SUBNET,
...@@ -248,21 +249,27 @@ class PowerDNSSlaveTestCase(PowerDNSTestCase): ...@@ -248,21 +249,27 @@ class PowerDNSSlaveTestCase(PowerDNSTestCase):
slave_parameter_dict['record'], slave_parameter_dict['applicable-zone'] slave_parameter_dict['record'], slave_parameter_dict['applicable-zone']
) )
for region in subnet_dict: for region in subnet_dict:
self.assertEqual( for replicate_nb in range(1, dns_quantity + 1):
slave_parameter_dict.get( ns_id = 'ns%s' % replicate_nb
region, self.assertEqual(
'%s.%s.' % ( slave_parameter_dict.get(
default_rr_dict[region], slave_parameter_dict['origin']) region,
), '%s.%s.' % (
self.dns_query(domain_name, subnet_dict[region]) default_rr_dict[region], slave_parameter_dict['origin'])
) ),
self.dns_query(
domain_name,
subnet_dict[region],
connection_dict[ns_id + '-ipv6'],
int(connection_dict[ns_id + '-port']))
)
def _test_slaves(self, dns_quantity=1): def _test_slaves(self, dns_quantity=1):
self._test_parameter_dict( self._test_parameter_dict(
dns_quantity=dns_quantity, dns_quantity=dns_quantity,
slave_amount=len(self.getSlaveParameterDictDict()) slave_amount=len(self.getSlaveParameterDictDict())
) )
self._test_dns_resolver() self._test_dns_resolver(dns_quantity)
class TestSlaveRequest(PowerDNSSlaveTestCase): class TestSlaveRequest(PowerDNSSlaveTestCase):
...@@ -421,7 +428,7 @@ class TestSlaveRequestDomains(TestSlaveRequest): ...@@ -421,7 +428,7 @@ class TestSlaveRequestDomains(TestSlaveRequest):
} }
# Because all powerdns instances run under the same ip address during tests, # Because all powerdns instances run under the same ipv4 address during tests,
# there is a port conflict between these instances # there is a port conflict between these instances
@skip @skip
class TestMultipleInstances(TestSlaveRequestDomains): class TestMultipleInstances(TestSlaveRequestDomains):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment