Fix TLD issues for test concurrency
Currently there are intermittent test failures due to inconsistent
management of TLDs across the test classes. This is due to some test
classes using the same TLD and cleaning them up or cases where a TLD is
expected to exist, but may not have been created yet.
This patch established a dedicated TLD for each test class that creates
zones. Inside each test case, a zone name will be created with the test
name and the test class TLD. This creates the required TLD isolation to
allow successful test concurrency.
The patch also changes the base TLD from 'org' to the RFC 2606 reserved 'test'.
This should allow for easier identification of test related resources.
Change-Id: I3509767ec0ce6be6b6f15a1bc15a730a4a144b09
diff --git a/designate_tempest_plugin/config.py b/designate_tempest_plugin/config.py
index 989acb8..c244b12 100644
--- a/designate_tempest_plugin/config.py
+++ b/designate_tempest_plugin/config.py
@@ -53,8 +53,8 @@
help="The target zone to test the dns recordsets "
"If it is not specified, a new zone will be created "),
cfg.StrOpt('tld_suffix',
- default='com',
- help="TLD suffix that used in all tests (if not overridden)")
+ default='test',
+ help="TLD suffix that used in all tests (if not overridden).")
]
dns_feature_group = cfg.OptGroup(name='dns_feature_enabled',
diff --git a/designate_tempest_plugin/services/dns/v2/json/transfer_accepts_client.py b/designate_tempest_plugin/services/dns/v2/json/transfer_accepts_client.py
index e09f775..753ffc2 100644
--- a/designate_tempest_plugin/services/dns/v2/json/transfer_accepts_client.py
+++ b/designate_tempest_plugin/services/dns/v2/json/transfer_accepts_client.py
@@ -19,20 +19,25 @@
@base.handle_errors
def create_transfer_accept(self, transfer_accept_data,
- params=None, headers=None):
+ params=None, headers=None, extra_headers=None):
"""Create a zone transfer_accept.
:param transfer_accept_data: A python dictionary representing
data for the zone transfer accept.
:param params: A Python dict that represents the query paramaters to
include in the accept URI.
:param headers (dict): The headers to use for the request.
+ :param extra_headers (bool): Boolean value than indicates if the
+ headers returned by the get_headers()
+ method are to be used but additional
+ headers are needed in the request
+ pass them in as a dict.
:return: Serialized accepted zone transfer as a dictionary.
"""
transfer_accept_uri = 'zones/tasks/transfer_accepts'
resp, body = self._create_request(
transfer_accept_uri, transfer_accept_data,
- params=params, headers=headers)
+ params=params, headers=headers, extra_headers=extra_headers)
# Create Transfer accept should Return a HTTP 201
self.expected_success(201, resp.status)
diff --git a/designate_tempest_plugin/tests/api/v2/test_ptrs.py b/designate_tempest_plugin/tests/api/v2/test_ptrs.py
index 0b0cddf..a72b61a 100644
--- a/designate_tempest_plugin/tests/api/v2/test_ptrs.py
+++ b/designate_tempest_plugin/tests/api/v2/test_ptrs.py
@@ -28,13 +28,34 @@
CONF = config.CONF
LOG = logging.getLogger(__name__)
-TLD = dns_data_utils.rand_string(3)
-
class BasePtrTest(base.BaseDnsV2Test):
excluded_keys = ['created_at', 'updated_at', 'version', 'links',
'status', 'action']
+ @classmethod
+ def setup_clients(cls):
+ super(BasePtrTest, cls).setup_clients()
+
+ if CONF.enforce_scope.designate:
+ cls.admin_tld_client = cls.os_system_admin.dns_v2.TldClient()
+ else:
+ cls.admin_tld_client = cls.os_admin.dns_v2.TldClient()
+
+ @classmethod
+ def resource_setup(cls):
+ super(BasePtrTest, cls).resource_setup()
+
+ # Make sure we have an allowed TLD available
+ tld_name = dns_data_utils.rand_zone_name(name='BasePtrTest')
+ cls.tld_name = tld_name[:-1]
+ cls.class_tld = cls.admin_tld_client.create_tld(tld_name=tld_name[:-1])
+
+ @classmethod
+ def resource_cleanup(cls):
+ cls.admin_tld_client.delete_tld(cls.class_tld[1]['id'])
+ super(BasePtrTest, cls).resource_cleanup()
+
class DesignatePtrRecord(BasePtrTest, tempest.test.BaseTestCase):
@@ -56,8 +77,24 @@
cls.primary_ptr_client = cls.os_primary.dns_v2.PtrClient()
cls.primary_floating_ip_client = cls.os_primary.floating_ips_client
+ @classmethod
+ def resource_setup(cls):
+ super(DesignatePtrRecord, cls).resource_setup()
+
+ # The 'arpa' TLD is a special case as the negative test class also
+ # needs to use this space. To stop test class concurrency conflicts,
+ # let each class manage different TLDs for the reverse namespace.
+ cls.arpa_tld = cls.admin_tld_client.create_tld(tld_name='arpa')
+
+ @classmethod
+ def resource_cleanup(cls):
+ cls.admin_tld_client.delete_tld(cls.arpa_tld[1]['id'])
+ super(DesignatePtrRecord, cls).resource_cleanup()
+
def _set_ptr(self, ptr_name=None, ttl=None, description=None,
- headers=None, tld=TLD, fip_id=None):
+ headers=None, tld=None, fip_id=None):
+ if not tld:
+ tld = self.tld_name
if not fip_id:
fip = self.primary_floating_ip_client.create_floatingip(
floating_network_id=CONF.network.public_network_id)[
@@ -148,7 +185,7 @@
class DesignatePtrRecordNegative(BasePtrTest, tempest.test.BaseTestCase):
- credentials = ['primary', 'admin']
+ credentials = ['primary', 'admin', 'system_admin']
@classmethod
def setup_credentials(cls):
@@ -163,8 +200,25 @@
cls.primary_floating_ip_client = cls.os_primary.floating_ips_client
cls.admin_ptr_client = cls.os_admin.dns_v2.PtrClient()
+ @classmethod
+ def resource_setup(cls):
+ super(DesignatePtrRecordNegative, cls).resource_setup()
+
+ # The 'arpa' TLD is a special case as the positive test class also
+ # needs to use this space. To stop test class concurrency conflicts,
+ # let each class manage different TLDs for the reverse namespace.
+ cls.in_addr_arpa_tld = cls.admin_tld_client.create_tld(
+ tld_name='in-addr.arpa')
+
+ @classmethod
+ def resource_cleanup(cls):
+ cls.admin_tld_client.delete_tld(cls.in_addr_arpa_tld[1]['id'])
+ super(DesignatePtrRecordNegative, cls).resource_cleanup()
+
def _set_ptr(self, ptr_name=None, ttl=None, description=None,
- headers=None, tld=TLD, fip_id=None):
+ headers=None, tld=None, fip_id=None):
+ if not tld:
+ tld = self.tld_name
if not fip_id:
fip = self.primary_floating_ip_client.create_floatingip(
floating_network_id=CONF.network.public_network_id)[
diff --git a/designate_tempest_plugin/tests/api/v2/test_quotas.py b/designate_tempest_plugin/tests/api/v2/test_quotas.py
index 0264dd3..d7b86fa 100644
--- a/designate_tempest_plugin/tests/api/v2/test_quotas.py
+++ b/designate_tempest_plugin/tests/api/v2/test_quotas.py
@@ -15,7 +15,7 @@
from tempest import config
from tempest.lib import decorators
from tempest.lib import exceptions as lib_exc
-from tempest.lib.common.utils import data_utils as tempest_data_utils
+from tempest.lib.common.utils import data_utils
from designate_tempest_plugin.tests import base
from designate_tempest_plugin import data_utils as dns_data_utils
@@ -285,7 +285,7 @@
for item in quotas_types:
quota = dns_data_utils.rand_quotas()
- quota[item] = tempest_data_utils.rand_name()
+ quota[item] = data_utils.rand_name()
self.assertRaises(
lib_exc.BadRequest, self.admin_client.set_quotas,
project_id=primary_project_id,
@@ -299,7 +299,7 @@
LOG.info('Try to set quota using not existing quota type in its body')
primary_project_id = self.quotas_client.project_id
quota = dns_data_utils.rand_quotas()
- quota[tempest_data_utils.rand_name()] = 777
+ quota[data_utils.rand_name()] = 777
with self.assertRaisesDns(
lib_exc.ServerFault, 'quota_resource_unknown', 500):
diff --git a/designate_tempest_plugin/tests/api/v2/test_recordset.py b/designate_tempest_plugin/tests/api/v2/test_recordset.py
index f6e9a4a..079782f 100644
--- a/designate_tempest_plugin/tests/api/v2/test_recordset.py
+++ b/designate_tempest_plugin/tests/api/v2/test_recordset.py
@@ -15,14 +15,14 @@
from tempest import config
from tempest.lib import decorators
from tempest.lib import exceptions as lib_exc
-from tempest.lib.common.utils import data_utils as lib_data_utils
+from tempest.lib.common.utils import data_utils
import ddt
from designate_tempest_plugin.tests import base
from designate_tempest_plugin.common import constants as const
from designate_tempest_plugin.common import waiters
-from designate_tempest_plugin import data_utils
+from designate_tempest_plugin import data_utils as dns_data_utils
CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -33,18 +33,33 @@
'type']
@classmethod
+ def setup_clients(cls):
+ super(BaseRecordsetsTest, cls).setup_clients()
+ if CONF.enforce_scope.designate:
+ cls.admin_tld_client = cls.os_system_admin.dns_v2.TldClient()
+ else:
+ cls.admin_tld_client = cls.os_admin.dns_v2.TldClient()
+
+ @classmethod
def resource_setup(cls):
super(BaseRecordsetsTest, cls).resource_setup()
+ # Make sure we have an allowed TLD available
+ tld_name = dns_data_utils.rand_zone_name(name="BaseRecordsetsTest")
+ cls.tld_name = f".{tld_name}"
+ cls.class_tld = cls.admin_tld_client.create_tld(tld_name=tld_name[:-1])
+
# All the recordset tests need a zone, create one to share
- LOG.info('Create a zone')
- cls.zone = cls.zone_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(name="TestZone",
+ suffix=cls.tld_name)
+ LOG.info('Create a zone: %s', zone_name)
+ cls.zone = cls.zone_client.create_zone(name=zone_name)[1]
@classmethod
def resource_cleanup(cls):
cls.zone_client.delete_zone(
cls.zone['id'], ignore_errors=lib_exc.NotFound)
-
+ cls.admin_tld_client.delete_tld(cls.class_tld[1]['id'])
super(BaseRecordsetsTest, cls).resource_cleanup()
@@ -76,7 +91,7 @@
@decorators.attr(type='smoke')
@decorators.idempotent_id('631d74fd-6909-4684-a61b-5c4d2f92c3e7')
def test_create_recordset(self):
- recordset_data = data_utils.rand_recordset_data(
+ recordset_data = dns_data_utils.rand_recordset_data(
record_type='A', zone_name=self.zone['name'])
LOG.info('Create a Recordset')
@@ -128,17 +143,17 @@
def test_create_recordset_type_SRV_TCP(self):
self._test_create_recordset_type(
"_sip._tcp", "SRV", [
- "10 60 5060 server1.example.{}.".format(self.tld_suffix),
- "20 60 5060 server2.example.{}.".format(self.tld_suffix),
- "20 30 5060 server3.example.{}.".format(self.tld_suffix)])
+ "10 60 5060 server1.example{}".format(self.tld_name),
+ "20 60 5060 server2.example{}".format(self.tld_name),
+ "20 30 5060 server3.example{}".format(self.tld_name)])
@decorators.idempotent_id('59c1aa42-278e-4f7b-a6a1-4320d5daf1fd')
def test_create_recordset_type_SRV_UDP(self):
self._test_create_recordset_type(
"_sip._udp", "SRV", [
- "10 60 5060 server1.example.{}.".format(self.tld_suffix),
- "10 60 5060 server2.example.{}.".format(self.tld_suffix),
- "20 30 5060 server3.example.{}.".format(self.tld_suffix)])
+ "10 60 5060 server1.example{}".format(self.tld_name),
+ "10 60 5060 server2.example{}".format(self.tld_name),
+ "20 30 5060 server3.example{}".format(self.tld_name)])
@decorators.idempotent_id('1ac46f94-f03a-4f85-b84f-826a2660b927')
def test_create_recordset_type_CNAME(self):
@@ -192,7 +207,7 @@
@decorators.idempotent_id('5964f730-5546-46e6-9105-5030e9c492b2')
def test_list_recordsets(self):
- recordset_data = data_utils.rand_recordset_data(
+ recordset_data = dns_data_utils.rand_recordset_data(
record_type='A', zone_name=self.zone['name'])
LOG.info('Create a Recordset')
@@ -209,7 +224,7 @@
@decorators.idempotent_id('84c13cb2-9020-4c1e-aeb0-c348d9a70caa')
def test_show_recordsets(self):
- recordset_data = data_utils.rand_recordset_data(
+ recordset_data = dns_data_utils.rand_recordset_data(
record_type='A', zone_name=self.zone['name'])
LOG.info('Create a Recordset')
@@ -227,7 +242,7 @@
@decorators.idempotent_id('855399c1-8806-4ae5-aa31-cb8a6f35e218')
def test_delete_recordset(self):
- recordset_data = data_utils.rand_recordset_data(
+ recordset_data = dns_data_utils.rand_recordset_data(
record_type='A', zone_name=self.zone['name'])
LOG.info('Create a Recordset')
@@ -246,7 +261,7 @@
@decorators.idempotent_id('8d41c85f-09f9-48be-a202-92d1bdf5c796')
def test_update_recordset(self):
- recordset_data = data_utils.rand_recordset_data(
+ recordset_data = dns_data_utils.rand_recordset_data(
record_type='A', zone_name=self.zone['name'])
LOG.info('Create a recordset')
@@ -256,7 +271,7 @@
self.wait_recordset_delete, self.client,
self.zone['id'], record['id'])
- recordset_data = data_utils.rand_recordset_data(
+ recordset_data = dns_data_utils.rand_recordset_data(
record_type='A', zone_name=self.zone['name'], name=record['name'])
LOG.info('Update the recordset')
@@ -268,7 +283,7 @@
@decorators.idempotent_id('60904cc5-148b-4e3b-a0c6-35656dc8d44c')
def test_update_recordset_one_field(self):
- recordset_data = data_utils.rand_recordset_data(
+ recordset_data = dns_data_utils.rand_recordset_data(
record_type='A', zone_name=self.zone['name'])
LOG.info('Create a recordset')
@@ -279,7 +294,7 @@
self.zone['id'], record['id'])
recordset_data = {
- 'ttl': data_utils.rand_ttl(start=record['ttl'] + 1)
+ 'ttl': dns_data_utils.rand_ttl(start=record['ttl'] + 1)
}
LOG.info('Update the recordset')
@@ -295,7 +310,7 @@
def test_show_recordsets_impersonate_another_project(self):
LOG.info('Create a Recordset')
- recordset_data = data_utils.rand_recordset_data(
+ recordset_data = dns_data_utils.rand_recordset_data(
record_type='A', zone_name=self.zone['name'])
resp, body = self.client.create_recordset(
self.zone['id'], recordset_data)
@@ -335,7 +350,7 @@
def test_admin_list_all_recordsets_for_a_project(self):
LOG.info('Create a Recordset as Primary tenant')
- recordset_data_primary_1 = data_utils.rand_recordset_data(
+ recordset_data_primary_1 = dns_data_utils.rand_recordset_data(
record_type='A', zone_name=self.zone['name'])
body_pr_1 = self.client.create_recordset(
self.zone['id'], recordset_data_primary_1)[1]
@@ -344,7 +359,7 @@
self.zone['id'], body_pr_1['id'])
self.assertEqual(const.PENDING, body_pr_1['status'],
'Failed, expected status is PENDING')
- recordset_data_primary_2 = data_utils.rand_recordset_data(
+ recordset_data_primary_2 = dns_data_utils.rand_recordset_data(
record_type='A', zone_name=self.zone['name'])
body_pr_2 = self.client.create_recordset(
self.zone['id'], recordset_data_primary_2)[1]
@@ -387,9 +402,9 @@
@decorators.idempotent_id('48013b7c-f526-11eb-b04f-74e5f9e2a801')
def test_create_A_recordset_multiply_ips(self):
LOG.info('Create A type Recordset using a list of random IPs')
- recordset_data = data_utils.rand_a_recordset(
+ recordset_data = dns_data_utils.rand_a_recordset(
zone_name=self.zone['name'],
- ips=[data_utils.rand_ip() for _ in range(10)])
+ ips=[dns_data_utils.rand_ip() for _ in range(10)])
resp, body = self.client.create_recordset(
self.zone['id'], recordset_data)
self.addCleanup(
@@ -406,11 +421,14 @@
def test_delete_zone_with_existing_recordset(self):
LOG.info('Create a Zone')
- zone = self.zone_client.create_zone(wait_until=const.ACTIVE)[1]
+ zone_name = dns_data_utils.rand_zone_name(name="TestZone",
+ suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name,
+ wait_until=const.ACTIVE)[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
LOG.info('Create a Recordset')
- recordset_data = data_utils.rand_recordset_data(
+ recordset_data = dns_data_utils.rand_recordset_data(
record_type='A', zone_name=zone['name'])
record = self.client.create_recordset(
zone['id'], recordset_data, wait_until=const.ACTIVE)[1]
@@ -432,7 +450,7 @@
@ddt.ddt
class RecordsetsNegativeTest(BaseRecordsetsTest):
- credentials = ["primary", "alt"]
+ credentials = ["admin", "system_admin", "primary", "alt"]
@classmethod
def setup_credentials(cls):
@@ -469,79 +487,58 @@
@decorators.idempotent_id('b6dad57e-5ce9-4fa5-8d66-aebbcd23b4ad')
def test_get_nonexistent_recordset(self):
- LOG.info('Create a zone')
- zone = self.zone_client.create_zone()[1]
- self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
-
LOG.info('Attempt to get an invalid Recordset')
with self.assertRaisesDns(
lib_exc.NotFound, 'recordset_not_found', 404):
- self.client.show_recordset(zone['id'], lib_data_utils.rand_uuid())
+ self.client.show_recordset(self.zone['id'],
+ data_utils.rand_uuid())
@decorators.idempotent_id('93d744a8-0dfd-4650-bcef-1e6ad632ad72')
def test_get_nonexistent_recordset_invalid_id(self):
- LOG.info('Create a zone')
- zone = self.zone_client.create_zone()[1]
- self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
-
LOG.info('Attempt to get an invalid Recordset')
with self.assertRaisesDns(lib_exc.BadRequest, 'invalid_uuid', 400):
- self.client.show_recordset(zone['id'], 'invalid')
+ self.client.show_recordset(self.zone['id'], 'invalid')
@decorators.idempotent_id('da08f19a-7f10-47cc-8b41-994507190812')
def test_update_nonexistent_recordset(self):
- LOG.info('Create a zone')
- zone = self.zone_client.create_zone()[1]
- self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
-
- recordset_data = data_utils.rand_recordset_data('A', zone['name'])
+ recordset_data = dns_data_utils.rand_recordset_data(
+ 'A', self.zone['name'])
LOG.info('Attempt to update an invalid Recordset')
with self.assertRaisesDns(
lib_exc.NotFound, 'recordset_not_found', 404):
self.client.update_recordset(
- zone['id'], lib_data_utils.rand_uuid(), recordset_data)
+ self.zone['id'], data_utils.rand_uuid(), recordset_data)
@decorators.idempotent_id('158340a1-3f69-4aaa-9968-956190563768')
def test_update_nonexistent_recordset_invalid_id(self):
- LOG.info('Create a zone')
- zone = self.zone_client.create_zone()[1]
- self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
-
- recordset_data = data_utils.rand_recordset_data('A', zone['name'])
+ recordset_data = dns_data_utils.rand_recordset_data(
+ 'A', self.zone['name'])
LOG.info('Attempt to update an invalid Recordset')
with self.assertRaisesDns(lib_exc.BadRequest, 'invalid_uuid', 400):
self.client.update_recordset(
- zone['id'], 'invalid', recordset_data)
+ self.zone['id'], 'invalid', recordset_data)
@decorators.idempotent_id('64bd94d4-54bd-4bee-b6fd-92ede063234e')
def test_delete_nonexistent_recordset(self):
- LOG.info('Create a zone')
- zone = self.zone_client.create_zone()[1]
- self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
-
LOG.info('Attempt to delete an invalid Recordset')
with self.assertRaisesDns(
lib_exc.NotFound, 'recordset_not_found', 404):
self.client.delete_recordset(
- zone['id'], lib_data_utils.rand_uuid())
+ self.zone['id'], data_utils.rand_uuid())
@decorators.idempotent_id('5948b599-a332-4dcb-840b-afc825075ba3')
def test_delete_nonexistent_recordset_invalid_id(self):
- LOG.info('Create a zone')
- zone = self.zone_client.create_zone()[1]
- self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
-
LOG.info('Attempt to get an invalid Recordset')
with self.assertRaisesDns(lib_exc.BadRequest, 'invalid_uuid', 400):
- self.client.delete_recordset(zone['id'], 'invalid')
+ self.client.delete_recordset(self.zone['id'], 'invalid')
@decorators.idempotent_id('64e01dc4-a2a8-11eb-aad4-74e5f9e2a801')
def test_show_recordsets_invalid_ids(self):
LOG.info('Create a Recordset')
- recordset_data = data_utils.rand_recordset_data(
+ recordset_data = dns_data_utils.rand_recordset_data(
record_type='A', zone_name=self.zone['name'])
resp, body = self.client.create_recordset(
self.zone['id'], recordset_data)
@@ -560,18 +557,18 @@
self.assertRaises(
lib_exc.NotFound, lambda: self.client.show_recordset(
zone_uuid=self.zone['id'],
- recordset_uuid=lib_data_utils.rand_uuid()))
+ recordset_uuid=data_utils.rand_uuid()))
LOG.info('Ensure 404 NotFound status code is received if '
'zone ID is invalid.')
self.assertRaises(
lib_exc.NotFound, lambda: self.client.show_recordset(
- zone_uuid=lib_data_utils.rand_uuid(),
+ zone_uuid=data_utils.rand_uuid(),
recordset_uuid=body['id']))
@decorators.idempotent_id('c1d9f046-a2b1-11eb-aad4-74e5f9e2a801')
def test_create_recordset_for_other_tenant(self):
- recordset_data = data_utils.rand_recordset_data(
+ recordset_data = dns_data_utils.rand_recordset_data(
record_type='A', zone_name=self.zone['name'])
LOG.info('Create a Recordset as Alt tenant for a zone created by '
@@ -582,6 +579,8 @@
class RootRecordsetsTests(BaseRecordsetsTest):
+ credentials = ["admin", "primary", "system_admin", "alt"]
+
@classmethod
def setup_credentials(cls):
# Do not create network resources for these test.
@@ -612,7 +611,7 @@
@decorators.idempotent_id('65ec0495-81d9-4cfb-8007-9d93b32ae883')
def test_get_single_zones_recordsets(self):
- recordset_data = data_utils.rand_recordset_data(
+ recordset_data = dns_data_utils.rand_recordset_data(
record_type='A', zone_name=self.zone['name'], records=['10.1.0.2'])
LOG.info('Create a Recordset')
@@ -626,7 +625,7 @@
@decorators.idempotent_id('a8e41020-65be-453b-a8c1-2497d539c345')
def test_list_filter_zones_recordsets(self):
- recordset_data = data_utils.rand_recordset_data(
+ recordset_data = dns_data_utils.rand_recordset_data(
record_type='A', zone_name=self.zone['name'], records=['10.0.1.2'])
LOG.info('Create a Recordset')
@@ -637,11 +636,13 @@
self.zone['id'], zone_recordset['id'])
LOG.info('Create another zone')
- zone2 = self.zone_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(name="list-filter",
+ suffix=self.tld_name)
+ zone2 = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone2['id'])
LOG.info('Create another Recordset')
- recordset_data = data_utils.rand_recordset_data(
+ recordset_data = dns_data_utils.rand_recordset_data(
record_type='A', zone_name=zone2['name'],
records=['10.0.1.3'])
resp, zone_recordset2 = self.client.create_recordset(
@@ -668,11 +669,15 @@
@decorators.idempotent_id('7f4970bf-9aeb-4a3c-9afd-02f5a7178d35')
def test_list_zones_recordsets_zone_names(self):
- LOG.info('Create another zone')
- zone2 = self.zone_client.create_zone()[1]
- self.addCleanup(self.wait_zone_delete, self.zone_client, zone2['id'])
-
LOG.info('List recordsets')
+ zone_name = dns_data_utils.rand_zone_name(name="zone_names",
+ suffix=self.tld_name)
+ alt_zone = self.zone_client.create_zone(
+ name=zone_name, wait_until=const.ACTIVE)[1]
+ self.addCleanup(self.wait_zone_delete,
+ self.zone_client,
+ alt_zone['id'])
+
body = self.client.list_zones_recordsets()[1]
recordsets = body['recordsets']
@@ -714,7 +719,9 @@
for client in clients_list:
if client == 'primary':
# Create a zone and wait till it's ACTIVE
- zone = self.zone_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(name="primary",
+ suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete,
self.zone_client,
zone['id'])
@@ -722,7 +729,7 @@
self.zone_client, zone['id'], const.ACTIVE)
# Create a recordset and wait till it's ACTIVE
- recordset_data = data_utils.rand_recordset_data(
+ recordset_data = dns_data_utils.rand_recordset_data(
record_type='A', zone_name=zone['name'])
resp, body = self.client.create_recordset(
zone['id'], recordset_data)
@@ -744,7 +751,9 @@
if client == 'alt':
# Create a zone and wait till it's ACTIVE
- alt_zone = self.alt_zone_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(name="alt",
+ suffix=self.tld_name)
+ alt_zone = self.alt_zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete,
self.alt_zone_client,
alt_zone['id'])
@@ -752,7 +761,7 @@
self.alt_zone_client, alt_zone['id'], const.ACTIVE)
# Create a recordset and wait till it's ACTIVE
- recordset_data = data_utils.rand_recordset_data(
+ recordset_data = dns_data_utils.rand_recordset_data(
record_type='A', zone_name=alt_zone['name'])
resp, body = self.alt_client.create_recordset(
alt_zone['id'], recordset_data)
@@ -778,7 +787,7 @@
@decorators.idempotent_id('9c0f58ad-1b31-4899-b184-5380720604e5')
def test_no_create_recordset_by_alt_tenant(self):
# try with name=A123456.zone.com.
- recordset_data = data_utils.rand_recordset_data(
+ recordset_data = dns_data_utils.rand_recordset_data(
record_type='A', zone_name=self.zone['name'])
resp, rrset = self.client.create_recordset(
self.zone['id'], recordset_data)
@@ -793,13 +802,13 @@
@decorators.idempotent_id('d4a9aad9-c778-429b-9a0c-4cd2b61a0a01')
def test_no_create_super_recordsets(self):
- zone_name = data_utils.rand_zone_name()
+ zone_name = dns_data_utils.rand_zone_name(suffix=self.tld_name)
LOG.info('Create a zone as a default user')
zone = self.zone_client.create_zone(name='a.b.' + zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
- rrset_data = data_utils.rand_recordset_data(
+ rrset_data = dns_data_utils.rand_recordset_data(
record_type='A', zone_name=zone_name)
LOG.info('Create a zone as an alt user with existing superdomain')
@@ -810,23 +819,21 @@
@decorators.idempotent_id('3dbe244d-fa85-4afc-869b-0306388d8746')
def test_no_create_recordset_via_alt_domain(self):
- zone = self.zone_client.create_zone()[1]
- alt_zone = self.alt_zone_client.create_zone()[1]
- self.addCleanup(self.wait_zone_delete,
- self.zone_client,
- zone['id'])
+ zone_name = dns_data_utils.rand_zone_name(name="alt-domain",
+ suffix=self.tld_name)
+ alt_zone = self.alt_zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete,
self.alt_zone_client,
alt_zone['id'])
# alt attempts to create record with name A12345.{zone}
- recordset_data = data_utils.rand_recordset_data(
- record_type='A', zone_name=zone['name'])
+ recordset_data = dns_data_utils.rand_recordset_data(
+ record_type='A', zone_name=self.zone['name'])
self.assertRaises(
lib_exc.RestClientException,
lambda: self.alt_client.create_recordset(
- zone['id'],
+ self.zone['id'],
recordset_data
)
)
@@ -924,7 +931,10 @@
sudo_managed_headers.update(managed_records_header)
LOG.info('Primary user creates a Zone')
+ zone_name = dns_data_utils.rand_zone_name(name="update_soa_ns",
+ suffix=self.tld_name)
zone = self.zone_client.create_zone(
+ name=zone_name,
description='Zone for "managed recordsets update" test',
wait_until=const.ACTIVE)[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
@@ -939,7 +949,7 @@
lib_exc.BadRequest, 'bad_request', 400,
self.admin_client.update_recordset,
zone['id'], recordset['id'],
- recordet_data=data_utils.rand_ns_records(),
+ recordet_data=dns_data_utils.rand_ns_records(),
headers=sudo_managed_headers, extra_headers=True)
if recordset['type'] == 'SOA':
@@ -947,5 +957,6 @@
lib_exc.BadRequest, 'bad_request', 400,
self.admin_client.update_recordset,
zone['id'], recordset['id'],
- recordet_data=data_utils.rand_soa_recordset(zone['name']),
+ recordet_data=dns_data_utils.rand_soa_recordset(
+ zone['name']),
headers=sudo_managed_headers, extra_headers=True)
diff --git a/designate_tempest_plugin/tests/api/v2/test_recordset_validation.py b/designate_tempest_plugin/tests/api/v2/test_recordset_validation.py
index a7efe31..a708f6d 100644
--- a/designate_tempest_plugin/tests/api/v2/test_recordset_validation.py
+++ b/designate_tempest_plugin/tests/api/v2/test_recordset_validation.py
@@ -14,14 +14,17 @@
limitations under the License.
"""
import ddt
-from tempest.lib import exceptions
+
+from tempest import config
from tempest.lib import decorators
+from tempest.lib import exceptions
from designate_tempest_plugin.tests import base
from designate_tempest_plugin.common import waiters
-from designate_tempest_plugin import data_utils
+from designate_tempest_plugin import data_utils as dns_data_utils
+CONF = config.CONF
RECORDSETS_DATASET = [
'A',
'AAAA',
@@ -37,6 +40,8 @@
@ddt.ddt
class RecordsetValidationTest(base.BaseDnsV2Test):
+ credentials = ["admin", "primary", "system_admin"]
+
def setUp(self):
super(RecordsetValidationTest, self).setUp()
self._zone = None
@@ -51,13 +56,23 @@
def setup_clients(cls):
super(RecordsetValidationTest, cls).setup_clients()
+ if CONF.enforce_scope.designate:
+ cls.admin_tld_client = cls.os_system_admin.dns_v2.TldClient()
+ else:
+ cls.admin_tld_client = cls.os_admin.dns_v2.TldClient()
cls.recordset_client = cls.os_primary.dns_v2.RecordsetClient()
cls.zones_client = cls.os_primary.dns_v2.ZonesClient()
@property
def zone(self):
if self._zone is None:
- zone_data = data_utils.rand_zone_data()
+ tld_name = dns_data_utils.rand_zone_name(
+ name="recordsetvalidation")
+ self.class_tld = self.admin_tld_client.create_tld(
+ tld_name=tld_name[:-1])
+ zone_name = dns_data_utils.rand_zone_name(name="TestZone",
+ suffix=f'.{tld_name}')
+ zone_data = dns_data_utils.rand_zone_data(name=zone_name)
resp, body = self.zones_client.create_zone(**zone_data)
self._zone = body
self.addCleanup(self.wait_zone_delete,
@@ -77,7 +92,8 @@
data = ["b0rk"]
for i in data:
- model = data_utils.make_rand_recordset(self.zone['name'], rtype)
+ model = dns_data_utils.make_rand_recordset(
+ self.zone['name'], rtype)
model['data'] = i
self.assertRaisesDns(
@@ -91,11 +107,13 @@
def test_update_invalid(self, rtype):
data = ["b0rk"]
- post_model = data_utils.make_rand_recordset(self.zone['name'], rtype)
+ post_model = dns_data_utils.make_rand_recordset(
+ self.zone['name'], rtype)
recordset = self.create_recordset(post_model)
for i in data:
- model = data_utils.make_rand_recordset(self.zone['name'], rtype)
+ model = dns_data_utils.make_rand_recordset(
+ self.zone['name'], rtype)
model['data'] = i
self.assertRaisesDns(
exceptions.BadRequest, 'invalid_object', 400,
@@ -105,7 +123,7 @@
@decorators.idempotent_id('61da1015-291f-43d1-a1a8-345cff12d201')
def test_cannot_create_wildcard_NS_recordset(self):
- model = data_utils.wildcard_ns_recordset(self.zone['name'])
+ model = dns_data_utils.wildcard_ns_recordset(self.zone['name'])
self.assertRaisesDns(
exceptions.BadRequest, 'invalid_object', 400,
self.recordset_client.create_recordset, self.zone['id'], model
@@ -113,7 +131,7 @@
@decorators.idempotent_id('92f681aa-d953-4d18-b12e-81a9149ccfd9')
def test_cname_recordsets_cannot_have_more_than_one_record(self):
- post_model = data_utils.rand_cname_recordset(
+ post_model = dns_data_utils.rand_cname_recordset(
zone_name=self.zone['name'])
post_model['records'] = [
@@ -130,7 +148,7 @@
@decorators.idempotent_id('22a9544b-2382-4ed2-ba12-4dbaedb8e880')
@ddt.file_data("invalid_txt_dataset.json")
def test_cannot_create_TXT_with(self, data):
- post_model = data_utils.rand_txt_recordset(self.zone['name'], data)
+ post_model = dns_data_utils.rand_txt_recordset(self.zone['name'], data)
self.assertRaisesDns(
exceptions.BadRequest, 'invalid_object', 400,
self.recordset_client.create_recordset,
@@ -140,7 +158,7 @@
@decorators.idempotent_id('03e4f811-0c37-4ce2-8b16-662c824f8f18')
@ddt.file_data("valid_txt_dataset.json")
def test_create_TXT_with(self, data):
- post_model = data_utils.rand_txt_recordset(self.zone['name'], data)
+ post_model = dns_data_utils.rand_txt_recordset(self.zone['name'], data)
recordset = self.create_recordset(post_model)
waiters.wait_for_recordset_status(
@@ -149,7 +167,7 @@
@decorators.idempotent_id('775b3db5-ec60-4dd7-85d2-f05a9c544978')
@ddt.file_data("valid_txt_dataset.json")
def test_create_SPF_with(self, data):
- post_model = data_utils.rand_spf_recordset(self.zone['name'], data)
+ post_model = dns_data_utils.rand_spf_recordset(self.zone['name'], data)
recordset = self.create_recordset(post_model)
waiters.wait_for_recordset_status(
@@ -158,7 +176,7 @@
@decorators.idempotent_id('7fa7783f-1624-4122-bfb2-6cfbf7a5b49b')
@ddt.file_data("invalid_mx_dataset.json")
def test_cannot_create_MX_with(self, pref):
- post_model = data_utils.rand_mx_recordset(
+ post_model = dns_data_utils.rand_mx_recordset(
self.zone['name'], pref=pref
)
@@ -171,7 +189,7 @@
@decorators.idempotent_id('3016f998-4e4a-4712-b15a-4e8dfbc5a60b')
@ddt.data("invalid_sshfp_dataset.json")
def test_cannot_create_SSHFP_with(self, algo=None, finger=None):
- post_model = data_utils.rand_sshfp_recordset(
+ post_model = dns_data_utils.rand_sshfp_recordset(
zone_name=self.zone['name'],
algorithm_number=algo,
fingerprint_type=finger,
diff --git a/designate_tempest_plugin/tests/api/v2/test_tld.py b/designate_tempest_plugin/tests/api/v2/test_tld.py
index 11882a3..d5d584c 100644
--- a/designate_tempest_plugin/tests/api/v2/test_tld.py
+++ b/designate_tempest_plugin/tests/api/v2/test_tld.py
@@ -31,6 +31,9 @@
class TldAdminTest(BaseTldTest):
credentials = ["admin", "system_admin", "primary"]
+ # Use a TLD suffix unique to this test class.
+ local_tld_suffix = '.'.join(["tldadmintest", CONF.dns.tld_suffix])
+
@classmethod
def setup_credentials(cls):
# Do not create network resources for these test.
@@ -48,40 +51,33 @@
cls.primary_zone_client = cls.os_primary.dns_v2.ZonesClient()
@classmethod
- def resource_setup(cls):
- super(TldAdminTest, cls).resource_setup()
- cls.tld = cls.admin_client.create_tld(
- tld_name=cls.tld_suffix, ignore_errors=lib_exc.Conflict
- )
-
- @classmethod
- def resource_cleanup(cls):
- cls.admin_client.delete_tld(cls.tld[1]['id'])
- super(TldAdminTest, cls).resource_cleanup()
+ def _generate_tld_name(cls, test_name):
+ return '.'.join([data_utils.rand_name(name=test_name),
+ cls.local_tld_suffix])
@decorators.idempotent_id('52a4bb4b-4eff-4591-9dd3-ad98316806c3')
def test_create_tld(self):
- tld_data = {
- "name": "org",
- "description": "sample tld"}
+ tld_name = self._generate_tld_name("test_create_tld")
+ tld_data = {"name": tld_name, "description": "sample tld"}
LOG.info('Create a tld')
tld = self.admin_client.create_tld(tld_data['name'],
- tld_data['description'])[1]
+ tld_data['description'])[1]
self.addCleanup(self.admin_client.delete_tld, tld['id'])
- self.assertEqual(tld_data["name"], tld['name'])
+ self.assertEqual(tld_name, tld['name'])
@decorators.idempotent_id('961bd2e8-d4d0-11eb-b8ee-74e5f9e2a801')
def test_create_duplicated_tlds(self):
- tld_data = {
- "name": "org", "description": "test_create_duplicated_tlds"}
+ tld_name = self._generate_tld_name("test_create_duplicated_tlds")
+ tld_data = {"name": tld_name,
+ "description": "test_create_duplicated_tlds"}
LOG.info('Create a first "org" TLD')
tld = self.admin_client.create_tld(
tld_data['name'], tld_data['description'])[1]
self.addCleanup(self.admin_client.delete_tld, tld['id'])
- self.assertEqual(tld_data["name"], tld['name'])
+ self.assertEqual(tld_name, tld['name'])
LOG.info('Try to create a second "org" TLD')
self.assertRaises(
@@ -91,15 +87,15 @@
@decorators.idempotent_id('0c0ab92e-d4db-11eb-b8ee-74e5f9e2a801')
def test_create_multiply_tlds(self):
- tlds = ['abc', 'def', 'gih']
- for tld_name in tlds:
- tld_data = {
- "name": tld_name, "description": "test_create_multiply_tlds"}
+ for _dummy in range(0, 2):
+ tld_name = self._generate_tld_name("test_create_multiply_tlds")
+ tld_data = {"name": tld_name,
+ "description": "test_create_multiply_tlds"}
LOG.info('Create a "{}" TLD'.format(tld_name))
tld = self.admin_client.create_tld(
tld_data['name'], tld_data['description'])[1]
self.addCleanup(self.admin_client.delete_tld, tld['id'])
- self.assertEqual(tld_data["name"], tld['name'])
+ self.assertEqual(tld_name, tld['name'])
@decorators.idempotent_id('52a4bb4b-4eff-4591-9dd3-ad98316806c3')
def test_create_invalid_tld(self):
@@ -127,13 +123,14 @@
@decorators.idempotent_id('271af08c-2603-4f61-8eb1-05887b74e25a')
def test_show_tld(self):
+ tld_name = self._generate_tld_name("test_show_tld")
tld_data = {
- "name": "org",
+ "name": tld_name,
"description": "sample tld"}
LOG.info('Create a tld')
tld = self.admin_client.create_tld(tld_data['name'],
- tld_data['description'])[1]
+ tld_data['description'])[1]
self.addCleanup(self.admin_client.delete_tld, tld['id'])
LOG.info('Fetch the tld')
@@ -145,7 +142,8 @@
@decorators.idempotent_id('26708cb8-7126-48a7-9424-1c225e56e609')
def test_delete_tld(self):
LOG.info('Create a tld')
- tld = self.admin_client.create_tld()[1]
+ tld_name = self._generate_tld_name("test_delete_tld")
+ tld = self.admin_client.create_tld(tld_name)[1]
self.addCleanup(self.admin_client.delete_tld, tld['id'],
ignore_errors=lib_exc.NotFound)
@@ -158,17 +156,25 @@
@decorators.idempotent_id('95b13759-c85c-4791-829b-9591ca15779d')
def test_list_tlds(self):
LOG.info('List tlds')
+ tld_name = self._generate_tld_name("test_list_tlds")
+ tld = self.admin_client.create_tld(tld_name)[1]
+ self.addCleanup(self.admin_client.delete_tld, tld['id'],
+ ignore_errors=lib_exc.NotFound)
+
body = self.admin_client.list_tlds()[1]
self.assertGreater(len(body['tlds']), 0)
@decorators.idempotent_id('1a233812-48d9-4d15-af5e-9961744286ff')
def test_update_tld(self):
- tld = self.admin_client.create_tld()[1]
+ tld_name = self._generate_tld_name("test_update_tld")
+ tld = self.admin_client.create_tld(tld_name)[1]
self.addCleanup(self.admin_client.delete_tld, tld['id'])
+ tld_name_2 = self._generate_tld_name("test_update_tld")
+
tld_data = {
- "name": "org",
+ "name": tld_name_2,
"description": "Updated description"
}
@@ -176,7 +182,7 @@
patch_tld = self.admin_client.update_tld(tld['id'],
tld_data['name'], tld_data['description'])[1]
- self.assertEqual(tld_data["name"], patch_tld["name"])
+ self.assertEqual(tld_name_2, patch_tld["name"])
self.assertEqual(tld_data["description"], patch_tld["description"])
@decorators.idempotent_id('8116dcf5-a329-47d1-90be-5ff32f299c53')
diff --git a/designate_tempest_plugin/tests/api/v2/test_transfer_accepts.py b/designate_tempest_plugin/tests/api/v2/test_transfer_accepts.py
index 616431c..87f359d 100644
--- a/designate_tempest_plugin/tests/api/v2/test_transfer_accepts.py
+++ b/designate_tempest_plugin/tests/api/v2/test_transfer_accepts.py
@@ -18,6 +18,7 @@
from tempest.lib import exceptions as lib_exc
from designate_tempest_plugin.tests import base
+from designate_tempest_plugin import data_utils as dns_data_utils
CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -27,6 +28,29 @@
excluded_keys = ['created_at', 'updated_at', 'key', 'links',
'zone_name']
+ @classmethod
+ def setup_clients(cls):
+ super(BaseTransferAcceptTest, cls).setup_clients()
+
+ if CONF.enforce_scope.designate:
+ cls.admin_tld_client = cls.os_system_admin.dns_v2.TldClient()
+ else:
+ cls.admin_tld_client = cls.os_admin.dns_v2.TldClient()
+
+ @classmethod
+ def resource_setup(cls):
+ super(BaseTransferAcceptTest, cls).resource_setup()
+
+ # Make sure we have an allowed TLD available
+ tld_name = dns_data_utils.rand_zone_name(name="BaseTransferAcceptTest")
+ cls.tld_name = f".{tld_name}"
+ cls.class_tld = cls.admin_tld_client.create_tld(tld_name=tld_name[:-1])
+
+ @classmethod
+ def resource_cleanup(cls):
+ cls.admin_tld_client.delete_tld(cls.class_tld[1]['id'])
+ super(BaseTransferAcceptTest, cls).resource_cleanup()
+
class TransferAcceptTest(BaseTransferAcceptTest):
credentials = ["primary", "alt", "admin", "system_admin"]
@@ -68,7 +92,10 @@
@decorators.idempotent_id('1c6baf97-a83e-4d2e-a5d8-9d37fb7808f3')
def test_create_transfer_accept(self):
LOG.info('Create a zone')
- _, zone = self.prm_zone_client.create_zone(wait_until='ACTIVE')
+ zone_name = dns_data_utils.rand_zone_name(
+ name="create_transfer_accept", suffix=self.tld_name)
+ zone = self.prm_zone_client.create_zone(name=zone_name,
+ wait_until='ACTIVE')[1]
self.addCleanup(
self.wait_zone_delete, self.admin_zone_client, zone['id'],
headers=self.all_projects_header,
@@ -97,7 +124,10 @@
@decorators.idempotent_id('37c6afbb-3ea3-4fd8-94ea-a426244f019a')
def test_show_transfer_accept(self):
LOG.info('Create a zone')
- _, zone = self.prm_zone_client.create_zone(wait_until='ACTIVE')
+ zone_name = dns_data_utils.rand_zone_name(name="show_transfer_accept",
+ suffix=self.tld_name)
+ zone = self.prm_zone_client.create_zone(name=zone_name,
+ wait_until='ACTIVE')[1]
self.addCleanup(
self.wait_zone_delete, self.admin_zone_client, zone['id'],
headers=self.all_projects_header,
@@ -133,7 +163,10 @@
def test_ownership_transferred_zone(self):
LOG.info('Create a Primary zone')
- zone = self.prm_zone_client.create_zone(wait_until='ACTIVE')[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="ownership_transferred_zone", suffix=self.tld_name)
+ zone = self.prm_zone_client.create_zone(name=zone_name,
+ wait_until='ACTIVE')[1]
self.addCleanup(
self.wait_zone_delete, self.admin_zone_client, zone['id'],
headers=self.all_projects_header,
@@ -178,7 +211,10 @@
for _ in range(number_of_zones_to_transfer):
LOG.info('Create a Primary zone')
- zone = self.prm_zone_client.create_zone(wait_until='ACTIVE')[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="list_transfer_accepts", suffix=self.tld_name)
+ zone = self.prm_zone_client.create_zone(name=zone_name,
+ wait_until='ACTIVE')[1]
self.addCleanup(
self.wait_zone_delete, self.admin_zone_client, zone['id'],
headers=self.all_projects_header,
@@ -255,7 +291,10 @@
@decorators.idempotent_id('b6ac770e-a1d3-11eb-b534-74e5f9e2a801')
def test_show_transfer_accept_impersonate_another_project(self):
LOG.info('Create a zone as primary tenant')
- zone = self.prm_zone_client.create_zone(wait_until='ACTIVE')[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="show_transfer_accept_impersonate", suffix=self.tld_name)
+ zone = self.prm_zone_client.create_zone(name=zone_name,
+ wait_until='ACTIVE')[1]
# In case when something goes wrong with the test and E2E
# scenario fails for some reason, we'll use Admin tenant
@@ -323,7 +362,10 @@
@decorators.idempotent_id('324a3e80-a1cc-11eb-b534-74e5f9e2a801')
def test_create_transfer_accept_using_invalid_key(self):
LOG.info('Create a zone')
- zone = self.zone_client.create_zone(wait_until='ACTIVE')[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="create_transfer_accept_invalid_key", suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name,
+ wait_until='ACTIVE')[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
LOG.info('Create a zone transfer_request')
@@ -335,7 +377,8 @@
transfer_request['id']
)
- data = {"key": data_utils.rand_password(len(transfer_request['key'])),
+ data = {"key": data_utils.rand_password(
+ len(transfer_request['key'])),
"zone_transfer_request_id": transfer_request['id']}
LOG.info('Create a zone transfer_accept using invalid key')
@@ -346,7 +389,10 @@
@decorators.idempotent_id('23afb948-a1ce-11eb-b534-74e5f9e2a801')
def test_create_transfer_accept_using_deleted_transfer_request_id(self):
LOG.info('Create a zone')
- zone = self.zone_client.create_zone(wait_until='ACTIVE')[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="create_transfer_accept_deleted_id", suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name,
+ wait_until='ACTIVE')[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
LOG.info('Create a zone transfer_request')
diff --git a/designate_tempest_plugin/tests/api/v2/test_transfer_request.py b/designate_tempest_plugin/tests/api/v2/test_transfer_request.py
index 6c8ed07..c53d6d9 100644
--- a/designate_tempest_plugin/tests/api/v2/test_transfer_request.py
+++ b/designate_tempest_plugin/tests/api/v2/test_transfer_request.py
@@ -27,6 +27,30 @@
class BaseTransferRequestTest(base.BaseDnsV2Test):
excluded_keys = ['created_at', 'updated_at', 'key', 'links']
+ @classmethod
+ def setup_clients(cls):
+ super(BaseTransferRequestTest, cls).setup_clients()
+
+ if CONF.enforce_scope.designate:
+ cls.admin_tld_client = cls.os_system_admin.dns_v2.TldClient()
+ else:
+ cls.admin_tld_client = cls.os_admin.dns_v2.TldClient()
+
+ @classmethod
+ def resource_setup(cls):
+ super(BaseTransferRequestTest, cls).resource_setup()
+
+ # Make sure we have an allowed TLD available
+ tld_name = dns_data_utils.rand_zone_name(
+ name="BaseTransferRequestTest")
+ cls.tld_name = f".{tld_name}"
+ cls.class_tld = cls.admin_tld_client.create_tld(tld_name=tld_name[:-1])
+
+ @classmethod
+ def resource_cleanup(cls):
+ cls.admin_tld_client.delete_tld(cls.class_tld[1]['id'])
+ super(BaseTransferRequestTest, cls).resource_cleanup()
+
class TransferRequestTest(BaseTransferRequestTest):
credentials = ["primary", "alt", "admin", "system_admin"]
@@ -54,11 +78,13 @@
@decorators.idempotent_id('2381d489-ad84-403d-b0a2-8b77e4e966bf')
def test_create_transfer_request(self):
LOG.info('Create a zone')
- _, zone = self.zone_client.create_zone()
+ zone_name = dns_data_utils.rand_zone_name(
+ name="create_transfer_request", suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
LOG.info('Create a zone transfer_request')
- _, transfer_request = self.client.create_transfer_request(zone['id'])
+ transfer_request = self.client.create_transfer_request(zone['id'])[1]
self.addCleanup(self.client.delete_transfer_request,
transfer_request['id'])
@@ -68,15 +94,17 @@
@decorators.idempotent_id('5deae1ac-7c14-42dc-b14e-4e4b2725beb7')
def test_create_transfer_request_scoped(self):
LOG.info('Create a zone')
- _, zone = self.zone_client.create_zone()
+ zone_name = dns_data_utils.rand_zone_name(
+ name="create_transfer_request_scoped", suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
transfer_request_data = dns_data_utils.rand_transfer_request_data(
target_project_id=self.os_alt.credentials.project_id)
LOG.info('Create a scoped zone transfer_request')
- _, transfer_request = self.client.create_transfer_request(
- zone['id'], transfer_request_data)
+ transfer_request = self.client.create_transfer_request(
+ zone['id'], transfer_request_data)[1]
self.addCleanup(self.client.delete_transfer_request,
transfer_request['id'])
@@ -86,11 +114,13 @@
@decorators.idempotent_id('4505152f-0a9c-4f02-b385-2216c914a0be')
def test_create_transfer_request_empty_body(self):
LOG.info('Create a zone')
- _, zone = self.zone_client.create_zone()
+ zone_name = dns_data_utils.rand_zone_name(
+ name="create_transfer_request_empty", suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
LOG.info('Create a zone transfer_request')
- _, transfer_request = self.client.create_transfer_request_empty_body(
- zone['id'])
+ transfer_request = self.client.create_transfer_request_empty_body(
+ zone['id'])[1]
self.addCleanup(self.client.delete_transfer_request,
transfer_request['id'])
@@ -100,16 +130,18 @@
@decorators.idempotent_id('64a7be9f-8371-4ce1-a242-c1190de7c985')
def test_show_transfer_request(self):
LOG.info('Create a zone')
- _, zone = self.zone_client.create_zone()
+ zone_name = dns_data_utils.rand_zone_name(
+ name="show_transfer_request", suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
LOG.info('Create a zone transfer_request')
- _, transfer_request = self.client.create_transfer_request(zone['id'])
+ transfer_request = self.client.create_transfer_request(zone['id'])[1]
self.addCleanup(self.client.delete_transfer_request,
transfer_request['id'])
LOG.info('Fetch the transfer_request')
- _, body = self.client.show_transfer_request(transfer_request['id'])
+ body = self.client.show_transfer_request(transfer_request['id'])[1]
LOG.info('Ensure the fetched response matches the '
'created transfer_request')
@@ -119,7 +151,9 @@
@decorators.skip_because(bug="1926572")
def test_show_transfer_request_impersonate_another_project(self):
LOG.info('Create a zone')
- zone = self.zone_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="show_transfer_request_impersonate", suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
LOG.info('Create a zone transfer_request')
@@ -148,20 +182,22 @@
# Checks the target of a scoped transfer request can see
# the request.
LOG.info('Create a zone')
- _, zone = self.zone_client.create_zone()
+ zone_name = dns_data_utils.rand_zone_name(
+ name="create_transfer_request_as_target", suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
transfer_request_data = dns_data_utils.rand_transfer_request_data(
target_project_id=self.os_alt.credentials.project_id)
LOG.info('Create a scoped zone transfer_request')
- _, transfer_request = self.client.create_transfer_request(
- zone['id'], transfer_request_data)
+ transfer_request = self.client.create_transfer_request(
+ zone['id'], transfer_request_data)[1]
self.addCleanup(self.client.delete_transfer_request,
transfer_request['id'])
LOG.info('Fetch the transfer_request as the target')
- _, body = self.alt_client.show_transfer_request(transfer_request['id'])
+ body = self.alt_client.show_transfer_request(transfer_request['id'])[1]
LOG.info('Ensure the fetched response matches the '
'created transfer_request')
@@ -172,24 +208,28 @@
@decorators.idempotent_id('7d81c487-aa15-44c4-b3e5-424ab9e6a3e5')
def test_delete_transfer_request(self):
LOG.info('Create a zone')
- _, zone = self.zone_client.create_zone()
+ zone_name = dns_data_utils.rand_zone_name(
+ name="delete_transfer_request", suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
LOG.info('Create a transfer_request')
- _, transfer_request = self.client.create_transfer_request(zone['id'])
+ transfer_request = self.client.create_transfer_request(zone['id'])[1]
self.addCleanup(self.client.delete_transfer_request,
transfer_request['id'],
ignore_errors=lib_exc.NotFound)
LOG.info('Delete the transfer_request')
- _, body = self.client.delete_transfer_request(transfer_request['id'])
+ self.client.delete_transfer_request(transfer_request['id'])
self.assertRaises(lib_exc.NotFound,
lambda: self.client.show_transfer_request(transfer_request['id']))
@decorators.idempotent_id('ddd42a19-1768-428c-846e-32f9d6493011')
def test_list_transfer_requests(self):
LOG.info('Create a zone')
- _, zone = self.zone_client.create_zone()
+ zone_name = dns_data_utils.rand_zone_name(
+ name="list_transfer_request", suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
LOG.info('Create a zone transfer_request')
@@ -205,12 +245,17 @@
@decorators.idempotent_id('db985892-9d02-11eb-a160-74e5f9e2a801')
def test_list_transfer_requests_all_projects(self):
LOG.info('Create a Primary zone')
- primary_zone = self.zone_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="list_transfer_request_all_projects", suffix=self.tld_name)
+ primary_zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete,
self.zone_client, primary_zone['id'])
LOG.info('Create an Alt zone')
- alt_zone = self.alt_zone_client.create_zone()[1]
+ alt_zone_name = dns_data_utils.rand_zone_name(
+ name="list_transfer_request_all_projects_alt",
+ suffix=self.tld_name)
+ alt_zone = self.alt_zone_client.create_zone(name=alt_zone_name)[1]
self.addCleanup(self.wait_zone_delete,
self.alt_zone_client, alt_zone['id'])
@@ -251,12 +296,16 @@
@decorators.idempotent_id('bee42f38-e666-4b85-a710-01f40ea1e56a')
def test_list_transfer_requests_impersonate_another_project(self):
LOG.info('Create a Primary zone')
- primary_zone = self.zone_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="list_transfer_request_impersonate", suffix=self.tld_name)
+ primary_zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete,
self.zone_client, primary_zone['id'])
LOG.info('Create an Alt zone')
- alt_zone = self.alt_zone_client.create_zone()[1]
+ alt_zone_name = dns_data_utils.rand_zone_name(
+ name="list_transfer_request_impersonate_alt", suffix=self.tld_name)
+ alt_zone = self.alt_zone_client.create_zone(name=alt_zone_name)[1]
self.addCleanup(self.wait_zone_delete,
self.alt_zone_client, alt_zone['id'])
@@ -282,7 +331,9 @@
@decorators.idempotent_id('de5e9d32-c723-4518-84e5-58da9722cc13')
def test_update_transfer_request(self):
LOG.info('Create a zone')
- _, zone = self.zone_client.create_zone()
+ zone_name = dns_data_utils.rand_zone_name(
+ name="update_transfer_request", suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
LOG.info('Create a zone transfer_request')
@@ -309,6 +360,7 @@
class TestTransferRequestNotFound(BaseTransferRequestTest):
+ credentials = ["admin", "primary", "system_admin"]
@classmethod
def setup_credentials(cls):
@@ -351,6 +403,7 @@
class TestTransferRequestInvalidId(BaseTransferRequestTest):
+ credentials = ["admin", "primary", "system_admin"]
@classmethod
def setup_credentials(cls):
diff --git a/designate_tempest_plugin/tests/api/v2/test_tsigkey.py b/designate_tempest_plugin/tests/api/v2/test_tsigkey.py
index 69e537f..ceba12e 100644
--- a/designate_tempest_plugin/tests/api/v2/test_tsigkey.py
+++ b/designate_tempest_plugin/tests/api/v2/test_tsigkey.py
@@ -28,6 +28,29 @@
class BaseTsigkeyTest(base.BaseDnsV2Test):
excluded_keys = ['created_at', 'updated_at', 'links']
+ @classmethod
+ def setup_clients(cls):
+ super(BaseTsigkeyTest, cls).setup_clients()
+
+ if CONF.enforce_scope.designate:
+ cls.admin_tld_client = cls.os_system_admin.dns_v2.TldClient()
+ else:
+ cls.admin_tld_client = cls.os_admin.dns_v2.TldClient()
+
+ @classmethod
+ def resource_setup(cls):
+ super(BaseTsigkeyTest, cls).resource_setup()
+
+ # Make sure we have an allowed TLD available
+ tld_name = dns_data_utils.rand_zone_name(name="BaseTsigkeyTest")
+ cls.tld_name = f".{tld_name}"
+ cls.class_tld = cls.admin_tld_client.create_tld(tld_name=tld_name[:-1])
+
+ @classmethod
+ def resource_cleanup(cls):
+ cls.admin_tld_client.delete_tld(cls.class_tld[1]['id'])
+ super(BaseTsigkeyTest, cls).resource_cleanup()
+
class TsigkeyAdminTest(BaseTsigkeyTest):
credentials = ["primary", "admin", "system_admin"]
@@ -54,7 +77,9 @@
@decorators.idempotent_id('e7b484e3-7ed5-4840-89d7-1e696986f8e4')
def test_create_tsigkey_for_zone(self):
LOG.info('Create a resource')
- zone = self.zone_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="create_tsigkey_for_zone", suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
tsigkey_data = {
@@ -98,7 +123,9 @@
@decorators.idempotent_id('d46e5e86-a18c-4315-aa0c-95a00e816fbf')
def test_list_tsigkey(self):
LOG.info('Create a resource')
- zone = self.zone_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="list_tsigkey", suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
LOG.info('Create a tsigkey')
tsigkey = self.admin_client.create_tsigkey(resource_id=zone['id'])[1]
@@ -110,7 +137,9 @@
def test_list_tsigkeys_limit_results(self):
for i in range(3):
LOG.info('As Primary user create a zone: {} '.format(i))
- zone = self.zone_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="list_tsigkey_limit", suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(
self.wait_zone_delete, self.zone_client, zone['id'])
LOG.info('As Admin user create a tsigkey: {} '.format(i))
@@ -132,7 +161,9 @@
for name in test_tsigkeys_names:
LOG.info('As Primary user create a zone to be used '
'for {}'.format(name))
- zone = self.zone_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="list_tsigkey_marker", suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(
self.wait_zone_delete, self.zone_client, zone['id'])
LOG.info('As Admin user create "{}" tsigkey'.format(name))
@@ -180,7 +211,9 @@
created_tsigkey_ids = []
for name in names_to_create:
LOG.info('As Primary user create a zone for: {} '.format(name))
- zone = self.zone_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="list_tsigkey_sort", suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(
self.wait_zone_delete, self.zone_client, zone['id'])
LOG.info('As Admin user create a tsigkey: {} '.format(name))
@@ -234,7 +267,9 @@
def test_list_tsigkey_filter_by_name(self):
tsigkey_name = data_utils.rand_name('ddd_tsgikey')
LOG.info('As Primary user create a zone for: {} '.format(tsigkey_name))
- zone = self.zone_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="list_tsigkey_filter_name", suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
LOG.info('As Admin user create a tsigkey: {} '.format(tsigkey_name))
tsigkey = self.admin_client.create_tsigkey(
@@ -271,7 +306,9 @@
self.addCleanup(self.admin_client.delete_tsigkey, pool_tsigkey['id'])
LOG.info('Create tsigkey for a zone')
- zone = self.zone_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="list_tsigkey_filter_scope", suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
zone_tsigkey = self.admin_client.create_tsigkey(
resource_id=zone['id'], scope='ZONE')[1]
@@ -337,7 +374,9 @@
@decorators.idempotent_id('c5d7facf-0f05-47a2-a4fb-87f203860880')
def test_show_tsigkey(self):
LOG.info('Create a resource')
- zone = self.zone_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="show_tsigkey", suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
LOG.info('Create a tsigkey')
@@ -353,7 +392,9 @@
@decorators.idempotent_id('d09dc0dd-dd72-41ee-9085-2afb2bf35459')
def test_update_tsigkey(self):
LOG.info('Create a resource')
- zone = self.zone_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="update_tsigkey", suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
LOG.info('Create a tsigkey')
@@ -375,7 +416,9 @@
@decorators.idempotent_id('9cdffbd2-bc67-4a25-8eb7-4be8635c88a3')
def test_delete_tsigkey(self):
LOG.info('Create a resource')
- zone = self.zone_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="delete_tsigkey", suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
LOG.info('Create a tsigkey')
@@ -492,7 +535,9 @@
@decorators.idempotent_id('f94af13a-d743-11eb-beba-74e5f9e2a801')
def test_create_tsigkey_for_zone_invalid_algorithm(self):
- zone = self.zone_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="create_tsigkey_invalid_algo", suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
tsigkey_data = {
"name": dns_data_utils.rand_zone_name('Example_Key'),
@@ -510,7 +555,9 @@
@decorators.idempotent_id('4df903d8-d745-11eb-beba-74e5f9e2a801')
def test_create_tsigkey_for_zone_invalid_name(self):
LOG.info('Create a zone resource')
- zone = self.zone_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="create_tsigkey_invalid_name", suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
tsigkey_data = {
"name": dns_data_utils.rand_zone_name(
@@ -530,7 +577,9 @@
@decorators.skip_because(bug="1933760")
def test_create_tsigkey_for_zone_empty_secret(self):
LOG.info('Create a zone resource')
- zone = self.zone_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="create_tsigkey_empty_secret", suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
tsigkey_data = {
"name": dns_data_utils.rand_zone_name('Example_Key'),
@@ -548,7 +597,9 @@
@decorators.idempotent_id('dfca9268-d745-11eb-beba-74e5f9e2a801')
def test_create_tsigkey_for_zone_invalid_scope(self):
LOG.info('Create a zone resource')
- zone = self.zone_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="create_tsigkey_invalid_scope", suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
tsigkey_data = {
"name": dns_data_utils.rand_zone_name('Example_Key'),
@@ -566,7 +617,9 @@
@decorators.idempotent_id('57255858-d74a-11eb-beba-74e5f9e2a801')
def test_create_tsigkey_for_zone_invalid_zone_id(self):
LOG.info('Create a resource')
- zone = self.zone_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="create_tsigkey_invalide_zone_id", suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
tsigkey_data = {
"name": dns_data_utils.rand_zone_name('Example_Key'),
diff --git a/designate_tempest_plugin/tests/api/v2/test_zone_tasks.py b/designate_tempest_plugin/tests/api/v2/test_zone_tasks.py
index bbeea75..db6541e 100644
--- a/designate_tempest_plugin/tests/api/v2/test_zone_tasks.py
+++ b/designate_tempest_plugin/tests/api/v2/test_zone_tasks.py
@@ -22,6 +22,7 @@
from designate_tempest_plugin.common import constants as const
from designate_tempest_plugin.common import waiters
+from designate_tempest_plugin import data_utils as dns_data_utils
from designate_tempest_plugin.tests import base
from designate_tempest_plugin.services.dns.query.query_client \
@@ -35,6 +36,29 @@
excluded_keys = ['created_at', 'updated_at', 'version', 'links',
'status', 'action']
+ @classmethod
+ def setup_clients(cls):
+ super(BaseZonesTest, cls).setup_clients()
+
+ if CONF.enforce_scope.designate:
+ cls.admin_tld_client = cls.os_system_admin.dns_v2.TldClient()
+ else:
+ cls.admin_tld_client = cls.os_admin.dns_v2.TldClient()
+
+ @classmethod
+ def resource_setup(cls):
+ super(BaseZonesTest, cls).resource_setup()
+
+ # Make sure we have an allowed TLD available
+ tld_name = dns_data_utils.rand_zone_name(name="BaseZonesTest")
+ cls.tld_name = f".{tld_name}"
+ cls.class_tld = cls.admin_tld_client.create_tld(tld_name=tld_name[:-1])
+
+ @classmethod
+ def resource_cleanup(cls):
+ cls.admin_tld_client.delete_tld(cls.class_tld[1]['id'])
+ super(BaseZonesTest, cls).resource_cleanup()
+
class ZoneTasks(BaseZonesTest):
credentials = ["primary", "alt", "admin", "system_admin"]
@@ -58,7 +82,9 @@
@decorators.idempotent_id('287e2cd0-a0e7-11eb-b962-74e5f9e2a801')
def test_zone_abandon(self):
LOG.info('Create a PRIMARY zone')
- pr_zone = self.client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="zone_abandon", suffix=self.tld_name)
+ pr_zone = self.client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.client, pr_zone['id'])
waiters.wait_for_zone_status(self.client, pr_zone['id'], 'ACTIVE')
@@ -88,7 +114,9 @@
def test_zone_abandon_forbidden(self):
LOG.info('Create a PRIMARY zone and add to the cleanup')
- pr_zone = self.client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="zone_abandon_forbidden", suffix=self.tld_name)
+ pr_zone = self.client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.client, pr_zone['id'])
waiters.wait_for_zone_status(self.client, pr_zone['id'], 'ACTIVE')
@@ -144,7 +172,9 @@
def test_manually_trigger_update_secondary_zone_negative(self):
# Create a PRIMARY zone
LOG.info('Create a PRIMARY zone')
- pr_zone = self.client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="manually_trigger_update_primary", suffix=self.tld_name)
+ pr_zone = self.client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.client, pr_zone['id'])
waiters.wait_for_zone_status(self.client, pr_zone['id'], 'ACTIVE')
@@ -170,7 +200,9 @@
# Create a SECONDARY zone
LOG.info('Create a SECONDARY zone')
- sec_zone = self.client.create_zone(
+ zone_name = dns_data_utils.rand_zone_name(
+ name="manually_trigger_update_secondary", suffix=self.tld_name)
+ sec_zone = self.client.create_zone(name=zone_name,
zone_type=const.SECONDARY_ZONE_TYPE, primaries=nameservers)[1]
self.addCleanup(self.wait_zone_delete, self.client, sec_zone['id'])
LOG.info('Ensure we respond with CREATE+PENDING')
diff --git a/designate_tempest_plugin/tests/api/v2/test_zones.py b/designate_tempest_plugin/tests/api/v2/test_zones.py
index f2faa88..aac3bda 100644
--- a/designate_tempest_plugin/tests/api/v2/test_zones.py
+++ b/designate_tempest_plugin/tests/api/v2/test_zones.py
@@ -32,6 +32,29 @@
excluded_keys = ['created_at', 'updated_at', 'version', 'links',
'status', 'action']
+ @classmethod
+ def setup_clients(cls):
+ super(BaseZonesTest, cls).setup_clients()
+
+ if CONF.enforce_scope.designate:
+ cls.admin_tld_client = cls.os_system_admin.dns_v2.TldClient()
+ else:
+ cls.admin_tld_client = cls.os_admin.dns_v2.TldClient()
+
+ @classmethod
+ def resource_setup(cls):
+ super(BaseZonesTest, cls).resource_setup()
+
+ # Make sure we have an allowed TLD available
+ tld_name = dns_data_utils.rand_zone_name(name="BaseZonesTest")
+ cls.tld_name = f".{tld_name}"
+ cls.class_tld = cls.admin_tld_client.create_tld(tld_name=tld_name[:-1])
+
+ @classmethod
+ def resource_cleanup(cls):
+ cls.admin_tld_client.delete_tld(cls.class_tld[1]['id'])
+ super(BaseZonesTest, cls).resource_cleanup()
+
class ZonesTest(BaseZonesTest):
credentials = ["admin", "system_admin", "primary"]
@@ -56,7 +79,9 @@
def test_create_zones(self):
# Create a PRIMARY zone
LOG.info('Create a PRIMARY zone')
- zone = self.client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="create_zones_primary", suffix=self.tld_name)
+ zone = self.client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.client, zone['id'])
LOG.info('Ensure we respond with CREATE+PENDING')
@@ -69,8 +94,11 @@
# Create a SECONDARY zone
LOG.info('Create a SECONDARY zone')
+ zone_name = dns_data_utils.rand_zone_name(
+ name="create_zones_secondary", suffix=self.tld_name)
zone = self.client.create_zone(
- zone_type=const.SECONDARY_ZONE_TYPE, primaries=nameservers)[1]
+ name=zone_name, zone_type=const.SECONDARY_ZONE_TYPE,
+ primaries=nameservers)[1]
self.addCleanup(self.wait_zone_delete, self.client, zone['id'])
LOG.info('Ensure we respond with CREATE+PENDING')
@@ -81,7 +109,10 @@
def test_create_zone_validate_recordsets_created(self):
# Create a PRIMARY zone and wait till it's Active
LOG.info('Create a PRIMARY zone')
- zone = self.client.create_zone(wait_until=const.ACTIVE)[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="create_zone_validate_recordsets", suffix=self.tld_name)
+ zone = self.client.create_zone(name=zone_name,
+ wait_until=const.ACTIVE)[1]
self.addCleanup(self.wait_zone_delete, self.client, zone['id'])
LOG.info('Ensure we respond with CREATE+PENDING')
@@ -102,11 +133,13 @@
@decorators.idempotent_id('02ca5d6a-86ce-4f02-9d94-9e5db55c3055')
def test_show_zone(self):
LOG.info('Create a zone')
- _, zone = self.client.create_zone()
+ zone_name = dns_data_utils.rand_zone_name(
+ name="show_zones", suffix=self.tld_name)
+ zone = self.client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.client, zone['id'])
LOG.info('Fetch the zone')
- _, body = self.client.show_zone(zone['id'])
+ body = self.client.show_zone(zone['id'])[1]
LOG.info('Ensure the fetched response matches the created zone')
self.assertExpected(zone, body, self.excluded_keys)
@@ -127,12 +160,14 @@
@decorators.idempotent_id('a4791906-6cd6-4d27-9f15-32273db8bb3d')
def test_delete_zone(self):
LOG.info('Create a zone')
- _, zone = self.client.create_zone()
+ zone_name = dns_data_utils.rand_zone_name(
+ name="delete_zones", suffix=self.tld_name)
+ zone = self.client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.client, zone['id'],
ignore_errors=lib_exc.NotFound)
LOG.info('Delete the zone')
- _, body = self.client.delete_zone(zone['id'])
+ body = self.client.delete_zone(zone['id'])[1]
LOG.info('Ensure we respond with DELETE+PENDING')
self.assertEqual(const.DELETE, body['action'])
@@ -147,7 +182,9 @@
@decorators.idempotent_id('5bfa3cfe-5bc8-443b-bf48-cfba44cbb247')
def test_list_zones(self):
LOG.info('Create a zone')
- _, zone = self.client.create_zone()
+ zone_name = dns_data_utils.rand_zone_name(
+ name="list_zones", suffix=self.tld_name)
+ zone = self.client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.client, zone['id'])
LOG.info('List zones')
@@ -160,15 +197,17 @@
@decorators.idempotent_id('123f51cb-19d5-48a9-aacc-476742c02141')
def test_update_zone(self):
LOG.info('Create a zone')
- _, zone = self.client.create_zone()
+ zone_name = dns_data_utils.rand_zone_name(
+ name="update_zone", suffix=self.tld_name)
+ zone = self.client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.client, zone['id'])
# Generate a random description
description = data_utils.rand_name()
LOG.info('Update the zone')
- _, zone = self.client.update_zone(
- zone['id'], description=description)
+ zone = self.client.update_zone(
+ zone['id'], description=description)[1]
LOG.info('Ensure we respond with UPDATE+PENDING')
self.assertEqual(const.UPDATE, zone['action'])
@@ -181,7 +220,10 @@
@decorators.skip_because(bug="1960487")
def test_serial_changes_on_update(self):
LOG.info('Create a zone')
- zone = self.client.create_zone(wait_until=const.ACTIVE)[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="serial_changes_on_update", suffix=self.tld_name)
+ zone = self.client.create_zone(name=zone_name,
+ wait_until=const.ACTIVE)[1]
self.addCleanup(self.wait_zone_delete, self.client, zone['id'])
LOG.info("Update Zone's email")
@@ -236,7 +278,9 @@
def test_get_primary_zone_nameservers(self):
# Create a zone and get the associated "pool_id"
LOG.info('Create a zone')
- zone = self.client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="get_primary_nameservers", suffix=self.tld_name)
+ zone = self.client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.client, zone['id'])
zone_pool_id = zone['pool_id']
@@ -281,7 +325,9 @@
@decorators.idempotent_id('f6fe8cce-8b04-11eb-a861-74e5f9e2a801')
def test_show_zone_impersonate_another_project(self):
LOG.info('Create zone "A" using primary client')
- zone = self.client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="show_zone_impersonate", suffix=self.tld_name)
+ zone = self.client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.client, zone['id'])
LOG.info('As Alt tenant show zone created by Primary tenant. '
@@ -316,18 +362,27 @@
def test_list_all_projects_zones(self):
LOG.info('Create zone "A" using Primary client')
- primary_zone = self.client.create_zone(wait_until=const.ACTIVE)[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="list_zone_all_projects_A", suffix=self.tld_name)
+ primary_zone = self.client.create_zone(name=zone_name,
+ wait_until=const.ACTIVE)[1]
self.addCleanup(
self.wait_zone_delete, self.client, primary_zone['id'])
LOG.info('Create zone "B" using Alt client')
- alt_zone = self.alt_client.create_zone(wait_until=const.ACTIVE)[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="list_zone_all_projects_B", suffix=self.tld_name)
+ alt_zone = self.alt_client.create_zone(name=zone_name,
+ wait_until=const.ACTIVE)[1]
self.addCleanup(
self.wait_zone_delete, self.alt_client, alt_zone['id'])
LOG.info('Create zone "C" using Admin client')
+ zone_name = dns_data_utils.rand_zone_name(
+ name="list_zone_all_projects_C", suffix=self.tld_name)
admin_zone = self.admin_client.create_zone(
- project_id="FakeProjectID", wait_until=const.ACTIVE)[1]
+ name=zone_name, project_id="FakeProjectID",
+ wait_until=const.ACTIVE)[1]
self.addCleanup(
self.wait_zone_delete, self.admin_client, admin_zone['id'],
headers=self.all_projects_header)
@@ -352,7 +407,7 @@
class ZoneOwnershipTest(BaseZonesTest):
- credentials = ["primary", "alt"]
+ credentials = ["primary", "alt", "admin", "system_admin"]
@classmethod
def setup_credentials(cls):
@@ -369,7 +424,9 @@
@decorators.idempotent_id('5d28580a-a012-4b57-b211-e077b1a01340')
def test_no_create_duplicate_domain(self):
LOG.info('Create a zone as a default user')
- _, zone = self.client.create_zone()
+ zone_name = dns_data_utils.rand_zone_name(
+ name="no_create_duplicate", suffix=self.tld_name)
+ zone = self.client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.client, zone['id'])
LOG.info('Create a zone as an default with existing domain')
@@ -383,7 +440,9 @@
@decorators.idempotent_id('a48776fd-b1aa-4a25-9f09-d1d34cfbb175')
def test_no_create_subdomain_by_alt_user(self):
LOG.info('Create a zone as a default user')
- _, zone = self.client.create_zone()
+ zone_name = dns_data_utils.rand_zone_name(
+ name="no_create_subdomain_by_alt", suffix=self.tld_name)
+ zone = self.client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.client, zone['id'])
LOG.info('Create a zone as an alt user with existing subdomain')
@@ -394,10 +453,11 @@
@decorators.idempotent_id('f1723d48-c082-43cd-94bf-ebeb5b8c9458')
def test_no_create_superdomain_by_alt_user(self):
- zone_name = dns_data_utils.rand_zone_name()
+ zone_name = dns_data_utils.rand_zone_name(
+ name="no_create_superdomain_by_alt", suffix=self.tld_name)
LOG.info('Create a zone as a default user')
- _, zone = self.client.create_zone(name='a.b.' + zone_name)
+ zone = self.client.create_zone(name='a.b.' + zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.client, zone['id'])
LOG.info('Create a zone as an alt user with existing superdomain')
@@ -406,6 +466,8 @@
class ZonesNegativeTest(BaseZonesTest):
+ credentials = ["admin", "primary", "system_admin"]
+
@classmethod
def setup_credentials(cls):
# Do not create network resources for these test.
diff --git a/designate_tempest_plugin/tests/api/v2/test_zones_exports.py b/designate_tempest_plugin/tests/api/v2/test_zones_exports.py
index 31da506..4dab500 100644
--- a/designate_tempest_plugin/tests/api/v2/test_zones_exports.py
+++ b/designate_tempest_plugin/tests/api/v2/test_zones_exports.py
@@ -21,6 +21,7 @@
from designate_tempest_plugin.tests import base
from designate_tempest_plugin.common import waiters
from designate_tempest_plugin.common import constants as const
+from designate_tempest_plugin import data_utils as dns_data_utils
CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -30,6 +31,29 @@
excluded_keys = ['created_at', 'updated_at', 'version', 'links',
'status', 'location']
+ @classmethod
+ def setup_clients(cls):
+ super(BaseZoneExportsTest, cls).setup_clients()
+
+ if CONF.enforce_scope.designate:
+ cls.admin_tld_client = cls.os_system_admin.dns_v2.TldClient()
+ else:
+ cls.admin_tld_client = cls.os_admin.dns_v2.TldClient()
+
+ @classmethod
+ def resource_setup(cls):
+ super(BaseZoneExportsTest, cls).resource_setup()
+
+ # Make sure we have an allowed TLD available
+ tld_name = dns_data_utils.rand_zone_name(name="BaseZoneExportsTest")
+ cls.tld_name = f".{tld_name}"
+ cls.class_tld = cls.admin_tld_client.create_tld(tld_name=tld_name[:-1])
+
+ @classmethod
+ def resource_cleanup(cls):
+ cls.admin_tld_client.delete_tld(cls.class_tld[1]['id'])
+ super(BaseZoneExportsTest, cls).resource_cleanup()
+
class ZonesExportTest(BaseZoneExportsTest):
credentials = ["primary", "admin", "system_admin", "alt"]
@@ -52,9 +76,11 @@
cls.client = cls.os_primary.dns_v2.ZoneExportsClient()
cls.alt_client = cls.os_alt.dns_v2.ZoneExportsClient()
- def _create_zone_export(self):
+ def _create_zone_export(self, test_name):
LOG.info('Create a zone')
- zone = self.zone_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name=test_name, suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
LOG.info('Create a zone export')
@@ -66,7 +92,7 @@
@decorators.idempotent_id('2dd8a9a0-98a2-4bf6-bb51-286583b30f40')
def test_create_zone_export(self):
- zone_export = self._create_zone_export()[1]
+ zone_export = self._create_zone_export('create_zone_export')[1]
LOG.info('Ensure we respond with PENDING')
self.assertEqual(const.PENDING, zone_export['status'])
@@ -74,7 +100,7 @@
@decorators.attr(type='smoke')
@decorators.idempotent_id('2d29a2a9-1941-4b7e-9d8a-ad6c2140ea68')
def test_show_zone_export(self):
- zone_export = self._create_zone_export()[1]
+ zone_export = self._create_zone_export('show_zone_export')[1]
LOG.info('Re-Fetch the zone export')
body = self.client.show_zone_export(zone_export['id'])[1]
@@ -85,7 +111,9 @@
@decorators.idempotent_id('fb04507c-9600-11eb-b1cd-74e5f9e2a801')
def test_show_zone_export_impersonate_another_project(self):
LOG.info('Create a zone')
- zone = self.zone_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name='show_zone_export_impersonate', suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
LOG.info('Create a zone export using primary client')
@@ -108,7 +136,9 @@
@decorators.idempotent_id('97234f00-8bcb-43f8-84dd-874f8bc4a80e')
def test_delete_zone_export(self):
LOG.info('Create a zone')
- _, zone = self.zone_client.create_zone()
+ zone_name = dns_data_utils.rand_zone_name(
+ name='delete_zone_export', suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'],
ignore_errors=lib_exc.NotFound)
@@ -125,7 +155,7 @@
@decorators.idempotent_id('476bfdfe-58c8-46e2-b376-8403c0fff440')
def test_list_zone_exports(self):
- self._create_zone_export()[1]
+ self._create_zone_export('list_zone_exports')[1]
LOG.info('List zone exports')
body = self.client.list_zone_exports()[1]
@@ -135,14 +165,18 @@
@decorators.idempotent_id('f34e7f34-9613-11eb-b1cd-74e5f9e2a801')
def test_list_zone_exports_all_projects(self):
LOG.info('Create a primary zone and its export')
- primary_zone = self.zone_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name='list_zone_exports_all_projects', suffix=self.tld_name)
+ primary_zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(
self.wait_zone_delete, self.zone_client, primary_zone['id'])
primary_export = self.client.create_zone_export(primary_zone['id'])[1]
self.addCleanup(self.client.delete_zone_export, primary_export['id'])
LOG.info('Create an alt zone and its export')
- alt_zone = self.alt_zone_client.create_zone()[1]
+ alt_zone_name = dns_data_utils.rand_zone_name(
+ name='list_zone_exports_all_projects_alt', suffix=self.tld_name)
+ alt_zone = self.alt_zone_client.create_zone(name=alt_zone_name)[1]
self.addCleanup(
self.wait_zone_delete, self.alt_zone_client, alt_zone['id'])
alt_export = self.alt_client.create_zone_export(alt_zone['id'])[1]
@@ -169,14 +203,18 @@
def test_list_zone_exports_filter_results(self):
LOG.info('Create a primary zone and its export')
- primary_zone = self.zone_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name='list_zone_exports_filter', suffix=self.tld_name)
+ primary_zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(
self.wait_zone_delete, self.zone_client, primary_zone['id'])
primary_export = self.client.create_zone_export(primary_zone['id'])[1]
self.addCleanup(self.client.delete_zone_export, primary_export['id'])
LOG.info('Create an alt zone, its export and delete it')
- alt_zone = self.alt_zone_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name='list_zone_exports_filter_alt', suffix=self.tld_name)
+ alt_zone = self.alt_zone_client.create_zone(name=zone_name)[1]
self.addCleanup(
self.wait_zone_delete, self.alt_zone_client, alt_zone['id'])
alt_export = self.alt_client.create_zone_export(alt_zone['id'])[1]
@@ -222,7 +260,7 @@
class ZonesExportTestNegative(BaseZoneExportsTest):
- credentials = ["primary", "alt"]
+ credentials = ["primary", "alt", "admin", "system_admin"]
@classmethod
def setup_credentials(cls):
@@ -237,9 +275,11 @@
cls.client = cls.os_primary.dns_v2.ZoneExportsClient()
cls.alt_client = cls.os_alt.dns_v2.ZoneExportsClient()
- def _create_zone_export(self):
+ def _create_zone_export(self, test_name):
LOG.info('Create a zone')
- zone = self.zone_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(name=test_name,
+ suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'])
LOG.info('Create a zone export')
@@ -258,7 +298,9 @@
@decorators.idempotent_id('943dad4a-9617-11eb-b1cd-74e5f9e2a801')
def test_export_not_your_zone(self):
LOG.info('Create a primary zone.')
- primary_zone = self.zone_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(name='export_not_your_zone',
+ suffix=self.tld_name)
+ primary_zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(
self.wait_zone_delete, self.zone_client, primary_zone['id'])
@@ -270,7 +312,9 @@
@decorators.idempotent_id('518dc308-9604-11eb-b1cd-74e5f9e2a801')
def test_create_zone_export_using_deleted_zone(self):
LOG.info('Create a zone')
- zone = self.zone_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(name='export_deleted_zone',
+ suffix=self.tld_name)
+ zone = self.zone_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.zone_client, zone['id'],
ignore_errors=lib_exc.NotFound)
LOG.info("Delete the zone and wait till it's done.")
@@ -290,7 +334,8 @@
@decorators.idempotent_id('52a1fee0-c338-4ed9-b9f9-41ee7fd73375')
def test_show_zonefile_not_supported_accept_value(self):
- zone, zone_export = self._create_zone_export()
+ zone, zone_export = self._create_zone_export(
+ 'show_zonefile_bad_accept')
# Tempest-lib _error_checker will raise UnexpectedResponseCode
e = self.assertRaises(
lib_exc.UnexpectedResponseCode, self.client.show_exported_zonefile,
diff --git a/designate_tempest_plugin/tests/api/v2/test_zones_imports.py b/designate_tempest_plugin/tests/api/v2/test_zones_imports.py
index 510708d..09ff4af 100644
--- a/designate_tempest_plugin/tests/api/v2/test_zones_imports.py
+++ b/designate_tempest_plugin/tests/api/v2/test_zones_imports.py
@@ -30,6 +30,29 @@
excluded_keys = ['created_at', 'updated_at', 'version', 'links',
'status', 'message', 'zone_id']
+ @classmethod
+ def setup_clients(cls):
+ super(BaseZonesImportTest, cls).setup_clients()
+
+ if CONF.enforce_scope.designate:
+ cls.admin_tld_client = cls.os_system_admin.dns_v2.TldClient()
+ else:
+ cls.admin_tld_client = cls.os_admin.dns_v2.TldClient()
+
+ @classmethod
+ def resource_setup(cls):
+ super(BaseZonesImportTest, cls).resource_setup()
+
+ # Make sure we have an allowed TLD available
+ tld_name = dns_data_utils.rand_zone_name(name="BaseZonesImportTest")
+ cls.tld_name = f".{tld_name}"
+ cls.class_tld = cls.admin_tld_client.create_tld(tld_name=tld_name[:-1])
+
+ @classmethod
+ def resource_cleanup(cls):
+ cls.admin_tld_client.delete_tld(cls.class_tld[1]['id'])
+ super(BaseZonesImportTest, cls).resource_cleanup()
+
class ZonesImportTest(BaseZonesImportTest):
credentials = ["primary", "admin", "system_admin", "alt"]
@@ -64,7 +87,11 @@
@decorators.idempotent_id('2e2d907d-0609-405b-9c96-3cb2b87e3dce')
def test_create_zone_import(self):
LOG.info('Create a zone import')
- _, zone_import = self.client.create_zone_import()
+ zone_name = dns_data_utils.rand_zone_name(
+ name="create_zone_import", suffix=self.tld_name)
+ zone_data = dns_data_utils.rand_zonefile_data(name=zone_name)
+ zone_import = self.client.create_zone_import(
+ zonefile_data=zone_data)[1]
self.addCleanup(self.clean_up_resources, zone_import['id'])
# Make sure we complete the import and have the zone_id for cleanup
waiters.wait_for_zone_import_status(
@@ -73,8 +100,12 @@
@decorators.idempotent_id('31eaf25a-9532-11eb-a55d-74e5f9e2a801')
def test_create_zone_import_invalid_ttl(self):
LOG.info('Try to create a zone import using invalid TTL value')
+ zone_name = dns_data_utils.rand_zone_name(
+ name="create_zone_import_invalid_ttl", suffix=self.tld_name)
+ zone_data = dns_data_utils.rand_zonefile_data(name=zone_name,
+ ttl='zahlabut')
zone_import = self.client.create_zone_import(
- zonefile_data=dns_data_utils.rand_zonefile_data(ttl='zahlabut'))[1]
+ zonefile_data=zone_data)[1]
self.addCleanup(self.clean_up_resources, zone_import['id'])
waiters.wait_for_zone_import_status(
self.client, zone_import['id'], "ERROR")
@@ -92,7 +123,11 @@
@decorators.idempotent_id('c8909558-0dc6-478a-9e91-eb97b52e59e0')
def test_show_zone_import(self):
LOG.info('Create a zone import')
- _, zone_import = self.client.create_zone_import()
+ zone_name = dns_data_utils.rand_zone_name(
+ name="show_zone_import", suffix=self.tld_name)
+ zone_data = dns_data_utils.rand_zonefile_data(name=zone_name)
+ zone_import = self.client.create_zone_import(
+ zonefile_data=zone_data)[1]
self.addCleanup(self.clean_up_resources, zone_import['id'])
# Make sure we complete the import and have the zone_id for cleanup
waiters.wait_for_zone_import_status(
@@ -107,10 +142,14 @@
@decorators.idempotent_id('56a16e68-b241-4e41-bc5c-c40747fa68e3')
def test_delete_zone_import(self):
LOG.info('Create a zone import')
- _, zone_import = self.client.create_zone_import()
+ zone_name = dns_data_utils.rand_zone_name(
+ name="delete_zone_import", suffix=self.tld_name)
+ zone_data = dns_data_utils.rand_zonefile_data(name=zone_name)
+ zone_import = self.client.create_zone_import(
+ zonefile_data=zone_data)[1]
waiters.wait_for_zone_import_status(self.client, zone_import['id'],
const.COMPLETE)
- _, zone_import = self.client.show_zone_import(zone_import['id'])
+ zone_import = self.client.show_zone_import(zone_import['id'])[1]
self.addCleanup(self.wait_zone_delete,
self.zone_client,
zone_import['zone_id'])
@@ -125,14 +164,18 @@
@decorators.idempotent_id('9eab76af-1995-485f-a2ef-8290c1863aba')
def test_list_zones_imports(self):
LOG.info('Create a zone import')
- _, zone_import = self.client.create_zone_import()
+ zone_name = dns_data_utils.rand_zone_name(
+ name="list_zone_imports", suffix=self.tld_name)
+ zone_data = dns_data_utils.rand_zonefile_data(name=zone_name)
+ zone_import = self.client.create_zone_import(
+ zonefile_data=zone_data)[1]
self.addCleanup(self.clean_up_resources, zone_import['id'])
# Make sure we complete the import and have the zone_id for cleanup
waiters.wait_for_zone_import_status(
self.client, zone_import['id'], const.COMPLETE)
LOG.info('List zones imports')
- _, body = self.client.list_zone_imports()
+ body = self.client.list_zone_imports()[1]
self.assertGreater(len(body['imports']), 0)
@@ -140,7 +183,11 @@
def test_show_import_impersonate_another_project(self):
LOG.info('Import zone "A" using primary client')
- zone_import = self.client.create_zone_import()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="show_zone_import_impersonate", suffix=self.tld_name)
+ zone_data = dns_data_utils.rand_zonefile_data(name=zone_name)
+ zone_import = self.client.create_zone_import(
+ zonefile_data=zone_data)[1]
self.addCleanup(self.clean_up_resources, zone_import['id'])
# Make sure we complete the import and have the zone_id for cleanup
@@ -182,7 +229,11 @@
@decorators.idempotent_id('7bd06ec6-9556-11eb-a55d-74e5f9e2a801')
def test_list_import_zones_all_projects(self):
LOG.info('Create import zone "A" using primary client')
- zone_import = self.client.create_zone_import()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="_zone_imports_all_projects", suffix=self.tld_name)
+ zone_data = dns_data_utils.rand_zonefile_data(name=zone_name)
+ zone_import = self.client.create_zone_import(
+ zonefile_data=zone_data)[1]
self.addCleanup(self.clean_up_resources, zone_import['id'])
# Make sure we complete the import and have the zone_id for cleanup
waiters.wait_for_zone_import_status(
diff --git a/designate_tempest_plugin/tests/base.py b/designate_tempest_plugin/tests/base.py
index 28b43cb..e251ac8 100644
--- a/designate_tempest_plugin/tests/base.py
+++ b/designate_tempest_plugin/tests/base.py
@@ -163,7 +163,6 @@
"""Base class for DNS V2 API tests."""
all_projects_header = {'X-Auth-All-Projects': True}
- tld_suffix = CONF.dns.tld_suffix
@classmethod
def skip_checks(cls):
diff --git a/designate_tempest_plugin/tests/scenario/v2/test_blacklists.py b/designate_tempest_plugin/tests/scenario/v2/test_blacklists.py
index 27b3f7f..a7455de 100644
--- a/designate_tempest_plugin/tests/scenario/v2/test_blacklists.py
+++ b/designate_tempest_plugin/tests/scenario/v2/test_blacklists.py
@@ -27,6 +27,29 @@
class BaseBlacklistsTest(base.BaseDnsV2Test):
excluded_keys = ['created_at', 'updated_at', 'links']
+ @classmethod
+ def setup_clients(cls):
+ super(BaseBlacklistsTest, cls).setup_clients()
+
+ if CONF.enforce_scope.designate:
+ cls.admin_tld_client = cls.os_system_admin.dns_v2.TldClient()
+ else:
+ cls.admin_tld_client = cls.os_admin.dns_v2.TldClient()
+
+ @classmethod
+ def resource_setup(cls):
+ super(BaseBlacklistsTest, cls).resource_setup()
+
+ # Make sure we have an allowed TLD available
+ tld_name = dns_data_utils.rand_zone_name(name="BaseBlacklistsTest")
+ cls.tld_name = f".{tld_name}"
+ cls.class_tld = cls.admin_tld_client.create_tld(tld_name=tld_name[:-1])
+
+ @classmethod
+ def resource_cleanup(cls):
+ cls.admin_tld_client.delete_tld(cls.class_tld[1]['id'])
+ super(BaseBlacklistsTest, cls).resource_cleanup()
+
class BlacklistE2E(BaseBlacklistsTest):
@@ -86,7 +109,8 @@
@decorators.idempotent_id('de030088-d97e-11eb-8ab8-74e5f9e2a801')
def test_admin_creates_zone_matches_blacklist_name_or_regex(self):
LOG.info('Create a blacklists using: regex and exact string(name)')
- zone_name = 'blacklistnameregextest1' + dns_data_utils.rand_zone_name()
+ zone_name = dns_data_utils.rand_zone_name(
+ name="admin_creates_zone_matches_blacklist1", suffix=self.tld_name)
blacklists = [
{'pattern': '^blacklistnameregextest2.*',
'description': 'Zone starts with "a" char'},
@@ -99,9 +123,10 @@
LOG.info('As Admin user try to create zones that are '
'supposed to be blocked')
+ zone_name2 = dns_data_utils.rand_zone_name(
+ name="admin_creates_zone_matches_blacklist2", suffix=self.tld_name)
zone = self.admin_zone_client.create_zone(
- name='blacklistnameregextest2' +
- dns_data_utils.rand_zone_name(),
+ name=zone_name2,
project_id=self.primary_zone_client.project_id)[1]
self.addCleanup(
self.wait_zone_delete, self.admin_zone_client, zone['id'])
diff --git a/designate_tempest_plugin/tests/scenario/v2/test_quotas.py b/designate_tempest_plugin/tests/scenario/v2/test_quotas.py
index 0c20b3d..c5725ed 100644
--- a/designate_tempest_plugin/tests/scenario/v2/test_quotas.py
+++ b/designate_tempest_plugin/tests/scenario/v2/test_quotas.py
@@ -49,12 +49,28 @@
super(QuotasV2Test, cls).setup_clients()
if CONF.enforce_scope.designate:
cls.admin_client = cls.os_system_admin.dns_v2.QuotasClient()
+ cls.admin_tld_client = cls.os_system_admin.dns_v2.TldClient()
else:
cls.admin_client = cls.os_admin.dns_v2.QuotasClient()
+ cls.admin_tld_client = cls.os_admin.dns_v2.TldClient()
cls.quotas_client = cls.os_primary.dns_v2.QuotasClient()
cls.alt_client = cls.os_alt.dns_v2.QuotasClient()
cls.alt_zone_client = cls.os_alt.dns_v2.ZonesClient()
+ @classmethod
+ def resource_setup(cls):
+ super(QuotasV2Test, cls).resource_setup()
+
+ # Make sure we have an allowed TLD available
+ tld_name = dns_data_utils.rand_zone_name(name="QuotasV2Test")
+ cls.tld_name = f".{tld_name}"
+ cls.class_tld = cls.admin_tld_client.create_tld(tld_name=tld_name[:-1])
+
+ @classmethod
+ def resource_cleanup(cls):
+ cls.admin_tld_client.delete_tld(cls.class_tld[1]['id'])
+ super(QuotasV2Test, cls).resource_cleanup()
+
@decorators.idempotent_id('6987953a-dccf-11eb-903e-74e5f9e2a801')
def test_alt_reaches_zones_quota(self):
@@ -78,7 +94,9 @@
attempt_number += 1
LOG.info('Attempt No:{} '.format(attempt_number))
try:
- zone = self.alt_zone_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="alt_reaches_zones_quota", suffix=self.tld_name)
+ zone = self.alt_zone_client.create_zone(name=zone_name)[1]
self.addCleanup(
self.wait_zone_delete, self.alt_zone_client, zone['id'])
except Exception as err:
diff --git a/designate_tempest_plugin/tests/scenario/v2/test_recordsets.py b/designate_tempest_plugin/tests/scenario/v2/test_recordsets.py
index 4c40c28..e58a54c 100644
--- a/designate_tempest_plugin/tests/scenario/v2/test_recordsets.py
+++ b/designate_tempest_plugin/tests/scenario/v2/test_recordsets.py
@@ -17,6 +17,7 @@
import ddt
from designate_tempest_plugin.tests import base
+from designate_tempest_plugin import data_utils as dns_data_utils
from designate_tempest_plugin.common import waiters
@@ -35,8 +36,10 @@
super(RecordsetsTest, cls).setup_clients()
if CONF.enforce_scope.designate:
cls.admin_client = cls.os_system_admin.dns_v2.RecordsetClient()
+ cls.admin_tld_client = cls.os_system_admin.dns_v2.TldClient()
else:
cls.admin_client = cls.os_admin.dns_v2.RecordsetClient()
+ cls.admin_tld_client = cls.os_admin.dns_v2.TldClient()
cls.client = cls.os_primary.dns_v2.ZonesClient()
cls.recordset_client = cls.os_primary.dns_v2.RecordsetClient()
@@ -49,8 +52,15 @@
LOG.info('Retrieve info from a zone')
_, zone = cls.client.show_zone(zone_id)
else:
+ # Make sure we have an allowed TLD available
+ tld_name = dns_data_utils.rand_zone_name(name="RecordsetsTest")
+ cls.tld_name = f".{tld_name}"
+ cls.class_tld = cls.admin_tld_client.create_tld(
+ tld_name=tld_name[:-1])
LOG.info('Create a new zone')
- _, zone = cls.client.create_zone()
+ zone_name = dns_data_utils.rand_zone_name(
+ name="recordsets_test_setup", suffix=cls.tld_name)
+ zone = cls.client.create_zone(name=zone_name)[1]
cls.addClassResourceCleanup(
test_utils.call_and_ignore_notfound_exc,
cls.client.delete_zone, zone['id'])
@@ -60,6 +70,11 @@
cls.zone = zone
+ @classmethod
+ def resource_cleanup(cls):
+ cls.admin_tld_client.delete_tld(cls.class_tld[1]['id'])
+ super(RecordsetsTest, cls).resource_cleanup()
+
@decorators.attr(type='slow')
@decorators.idempotent_id('4664ed66-9ff1-45f2-9e60-d4913195c505')
@ddt.file_data("recordset_data.json")
diff --git a/designate_tempest_plugin/tests/scenario/v2/test_tld.py b/designate_tempest_plugin/tests/scenario/v2/test_tld.py
index 9c048a1..8dc6d70 100644
--- a/designate_tempest_plugin/tests/scenario/v2/test_tld.py
+++ b/designate_tempest_plugin/tests/scenario/v2/test_tld.py
@@ -27,6 +27,7 @@
class TldZoneTest(base.BaseDnsV2Test):
credentials = ["admin", "system_admin", "primary"]
+ tld_suffix = '.'.join(["TldZoneTest", CONF.dns.tld_suffix])
@classmethod
def setup_credentials(cls):
@@ -47,13 +48,12 @@
@classmethod
def resource_setup(cls):
super(TldZoneTest, cls).resource_setup()
- cls.tld = cls.admin_tld_client.create_tld(
- tld_name=cls.tld_suffix, ignore_errors=lib_exc.Conflict
- )
+ cls.class_tld = cls.admin_tld_client.create_tld(
+ tld_name=cls.tld_suffix)
@classmethod
def resource_cleanup(cls):
- cls.admin_tld_client.delete_tld(cls.tld[1]['id'])
+ cls.admin_tld_client.delete_tld(cls.class_tld[1]['id'])
super(TldZoneTest, cls).resource_cleanup()
@decorators.idempotent_id('68b3e7cc-bf0e-11ec-b803-201e8823901f')
diff --git a/designate_tempest_plugin/tests/scenario/v2/test_zones.py b/designate_tempest_plugin/tests/scenario/v2/test_zones.py
index 7b8d68a..2c89c20 100644
--- a/designate_tempest_plugin/tests/scenario/v2/test_zones.py
+++ b/designate_tempest_plugin/tests/scenario/v2/test_zones.py
@@ -22,21 +22,44 @@
from designate_tempest_plugin.common import constants as const
from designate_tempest_plugin.common import waiters
+CONF = config.CONF
LOG = logging.getLogger(__name__)
class ZonesTest(base.BaseDnsV2Test):
+ credentials = ["primary", "admin", "system_admin"]
+
@classmethod
def setup_clients(cls):
super(ZonesTest, cls).setup_clients()
+ if CONF.enforce_scope.designate:
+ cls.admin_tld_client = cls.os_system_admin.dns_v2.TldClient()
+ else:
+ cls.admin_tld_client = cls.os_admin.dns_v2.TldClient()
cls.client = cls.os_primary.dns_v2.ZonesClient()
+ @classmethod
+ def resource_setup(cls):
+ super(ZonesTest, cls).resource_setup()
+
+ # Make sure we have an allowed TLD available
+ tld_name = dns_data_utils.rand_zone_name(name="ZonesTest")
+ cls.tld_name = f".{tld_name}"
+ cls.class_tld = cls.admin_tld_client.create_tld(tld_name=tld_name[:-1])
+
+ @classmethod
+ def resource_cleanup(cls):
+ cls.admin_tld_client.delete_tld(cls.class_tld[1]['id'])
+ super(ZonesTest, cls).resource_cleanup()
+
@decorators.attr(type='smoke')
@decorators.attr(type='slow')
@decorators.idempotent_id('d0648f53-4114-45bd-8792-462a82f69d32')
def test_create_and_delete_zone(self):
LOG.info('Create a zone')
- zone = self.client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="create_and_delete_zone", suffix=self.tld_name)
+ zone = self.client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.client, zone['id'],
ignore_errors=lib_exc.NotFound)
@@ -70,7 +93,10 @@
LOG.info('Create a zone and wait until it becomes ACTIVE')
orig_ttl = 666
orig_description = 'test_create_and_update_zone: org description'
+ zone_name = dns_data_utils.rand_zone_name(
+ name="create_and_update_zone", suffix=self.tld_name)
zone = self.client.create_zone(
+ name=zone_name,
ttl=orig_ttl, description=orig_description,
wait_until=const.ACTIVE)[1]
self.addCleanup(self.wait_zone_delete, self.client, zone['id'],
@@ -100,7 +126,9 @@
@decorators.idempotent_id('c9838adf-14dc-4097-9130-e5cea3727abb')
def test_delete_zone_pending_create(self):
LOG.info('Create a zone')
- zone = self.client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="delete_zone_pending_create", suffix=self.tld_name)
+ zone = self.client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.client, zone['id'],
ignore_errors=lib_exc.NotFound)
@@ -125,7 +153,9 @@
"Config option dns.nameservers is missing or empty")
def test_zone_create_propagates_to_nameservers(self):
LOG.info('Create a zone')
- zone = self.client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="zone_create_propagates", suffix=self.tld_name)
+ zone = self.client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.client, zone['id'])
waiters.wait_for_zone_status(self.client, zone['id'], const.ACTIVE)
@@ -138,7 +168,9 @@
"Config option dns.nameservers is missing or empty")
def test_zone_delete_propagates_to_nameservers(self):
LOG.info('Create a zone')
- zone = self.client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="zone_delete_propagates", suffix=self.tld_name)
+ zone = self.client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.client, zone['id'],
ignore_errors=lib_exc.NotFound)
diff --git a/designate_tempest_plugin/tests/scenario/v2/test_zones_export.py b/designate_tempest_plugin/tests/scenario/v2/test_zones_export.py
index f094498..565461d 100644
--- a/designate_tempest_plugin/tests/scenario/v2/test_zones_export.py
+++ b/designate_tempest_plugin/tests/scenario/v2/test_zones_export.py
@@ -14,13 +14,16 @@
import json
import os
+
from oslo_log import log as logging
from tempest import config
from tempest.lib import decorators
+
+from designate_tempest_plugin.common import constants as const
from designate_tempest_plugin.common import waiters
+from designate_tempest_plugin import data_utils as dns_data_utils
from designate_tempest_plugin.tests.api.v2.test_zones_exports import \
BaseZoneExportsTest
-from designate_tempest_plugin.common import constants as const
CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -46,9 +49,11 @@
cls.zones_client = cls.os_primary.dns_v2.ZonesClient()
cls.recordset_client = cls.os_primary.dns_v2.RecordsetClient()
- def _create_zone_export(self):
+ def _create_zone_export(self, test_name):
LOG.info('Create a zone')
- zone = self.zones_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name=test_name, suffix=self.tld_name)
+ zone = self.zones_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.zones_client, zone['id'])
LOG.info('Create a zone export')
@@ -60,7 +65,8 @@
@decorators.idempotent_id('0484c3c4-df57-458e-a6e5-6eb63e0475e0')
def test_create_zone_export_and_show_exported_zonefile(self):
- zone, zone_export = self._create_zone_export()
+ zone, zone_export = self._create_zone_export(
+ 'create_zone_export_and_show_exported_zonefile')
self.assertEqual(const.PENDING, zone_export['status'])
self.assertEqual(zone['id'], zone_export['zone_id'])
@@ -82,7 +88,8 @@
@decorators.idempotent_id('56b8f30e-cd45-4c7a-bc0c-bbf92d7dc697')
def test_show_exported_zonefile_impersonate_another_project(self):
- zone, zone_export = self._create_zone_export()
+ zone, zone_export = self._create_zone_export(
+ 'show_exported_zonefile_impersonate')
LOG.info('As Admin impersonate "primary" client,'
' to show exported zone file')
@@ -94,7 +101,8 @@
@decorators.idempotent_id('c2e55514-ff2e-41d9-a3cc-9e78873254c9')
def test_show_exported_zonefile_all_projects(self):
- zone, zone_export = self._create_zone_export()
+ zone, zone_export = self._create_zone_export(
+ 'show_exported_zonefile_all_projects')
resp_headers, resp_data = self.admin_client.show_exported_zonefile(
zone_export['id'], headers={
'x-auth-all-projects': True
@@ -104,7 +112,8 @@
@decorators.idempotent_id('9746b7f2-2df4-448c-8a85-5ab6bf74f1fe')
def test_show_exported_zonefile_any_mime_type(self):
- zone, zone_export = self._create_zone_export()
+ zone, zone_export = self._create_zone_export(
+ 'show_exported_zonefile_any_mime_type')
resp_headers, resp_data = self.client.show_exported_zonefile(
zone_export['id'], headers={'Accept': '*/*'})
@@ -119,7 +128,8 @@
@decorators.idempotent_id('dc7a9dde-d287-4e22-9788-26578f0d3bf0')
def test_missing_accept_headers(self):
- zone, zone_export = self._create_zone_export()
+ zone, zone_export = self._create_zone_export(
+ 'missing_accept_headers')
resp_headers, resp_data = self.client.show_exported_zonefile(
zone_export['id'], headers={})
LOG.info('Ensure Content-Type: text/dns')
@@ -146,7 +156,10 @@
file.close()
LOG.info('Create a zone')
- zone = self.zones_client.create_zone(wait_until=const.ACTIVE)[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="all_recordset_types_exist", suffix=self.tld_name)
+ zone = self.zones_client.create_zone(name=zone_name,
+ wait_until=const.ACTIVE)[1]
self.addCleanup(self.wait_zone_delete, self.zones_client, zone['id'])
created_records = []
diff --git a/designate_tempest_plugin/tests/scenario/v2/test_zones_import.py b/designate_tempest_plugin/tests/scenario/v2/test_zones_import.py
index e92feee..29db239 100644
--- a/designate_tempest_plugin/tests/scenario/v2/test_zones_import.py
+++ b/designate_tempest_plugin/tests/scenario/v2/test_zones_import.py
@@ -24,6 +24,8 @@
class ZonesImportTest(BaseZonesImportTest):
+ credentials = ["primary", "admin", "system_admin"]
+
@classmethod
def setup_clients(cls):
super(ZonesImportTest, cls).setup_clients()
@@ -34,10 +36,11 @@
@decorators.attr(type='slow')
@decorators.idempotent_id('679f38d0-2f2f-49c5-934e-8fe0c452f56e')
def test_create_zone_import_and_wait_for_zone(self):
- name = dns_data_utils.rand_zone_name('testimport')
- zonefile = dns_data_utils.rand_zonefile_data(name=name)
+ zone_name = dns_data_utils.rand_zone_name(
+ name="create_zone_import_and_wait_for_zone", suffix=self.tld_name)
+ zonefile = dns_data_utils.rand_zonefile_data(name=zone_name)
- LOG.info('Import zone %r', name)
+ LOG.info('Import zone %r', zone_name)
_, zone_import = self.client.create_zone_import(zonefile)
self.addCleanup(self.client.delete_zone_import, zone_import['id'])
@@ -63,4 +66,4 @@
_, zone = self.zones_client.show_zone(zone_import['zone_id'])
self.assertEqual('NONE', zone['action'])
self.assertEqual('ACTIVE', zone['status'])
- self.assertEqual(name, zone['name'])
+ self.assertEqual(zone_name, zone['name'])
diff --git a/designate_tempest_plugin/tests/scenario/v2/test_zones_transfer.py b/designate_tempest_plugin/tests/scenario/v2/test_zones_transfer.py
index 3437c33..b29262a 100644
--- a/designate_tempest_plugin/tests/scenario/v2/test_zones_transfer.py
+++ b/designate_tempest_plugin/tests/scenario/v2/test_zones_transfer.py
@@ -12,40 +12,67 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_log import log as logging
+from tempest import config
from tempest.lib import decorators
from tempest.lib import exceptions as lib_exc
from designate_tempest_plugin.tests import base
from designate_tempest_plugin import data_utils as dns_data_utils
+CONF = config.CONF
LOG = logging.getLogger(__name__)
class ZonesTransferTest(base.BaseDnsV2Test):
- credentials = ['primary', 'alt', 'admin']
+ credentials = ['primary', 'alt', 'admin', 'system_admin']
@classmethod
def setup_clients(cls):
super(ZonesTransferTest, cls).setup_clients()
+ if CONF.enforce_scope.designate:
+ cls.admin_zones_client = cls.os_system_admin.dns_v2.ZonesClient()
+ cls.admin_accept_client = (
+ cls.os_system_admin.dns_v2.TransferAcceptClient())
+ cls.admin_tld_client = cls.os_system_admin.dns_v2.TldClient()
+ else:
+ cls.admin_zones_client = cls.os_admin.dns_v2.ZonesClient()
+ cls.admin_accept_client = (
+ cls.os_admin.dns_v2.TransferAcceptClient())
+ cls.admin_tld_client = cls.os_admin.dns_v2.TldClient()
cls.zones_client = cls.os_primary.dns_v2.ZonesClient()
cls.alt_zones_client = cls.os_alt.dns_v2.ZonesClient()
- cls.admin_zones_client = cls.os_admin.dns_v2.ZonesClient()
cls.request_client = cls.os_primary.dns_v2.TransferRequestClient()
cls.alt_request_client = cls.os_alt.dns_v2.TransferRequestClient()
cls.accept_client = cls.os_primary.dns_v2.TransferAcceptClient()
cls.alt_accept_client = cls.os_alt.dns_v2.TransferAcceptClient()
- cls.admin_accept_client = cls.os_admin.dns_v2.TransferAcceptClient()
+
+ @classmethod
+ def resource_setup(cls):
+ super(ZonesTransferTest, cls).resource_setup()
+
+ # Make sure we have an allowed TLD available
+ tld_name = dns_data_utils.rand_zone_name(name="ZonesTransferTest")
+ cls.tld_name = f".{tld_name}"
+ cls.class_tld = cls.admin_tld_client.create_tld(tld_name=tld_name[:-1])
+
+ @classmethod
+ def resource_cleanup(cls):
+ cls.admin_tld_client.delete_tld(cls.class_tld[1]['id'])
+ super(ZonesTransferTest, cls).resource_cleanup()
@decorators.idempotent_id('60bd80ac-c979-4686-9a03-f2f775f272ab')
def test_zone_transfer(self):
LOG.info('Create a zone as primary tenant')
- _, zone = self.zones_client.create_zone()
+ zone_name = dns_data_utils.rand_zone_name(
+ name="zone_transfer", suffix=self.tld_name)
+ zone = self.zones_client.create_zone(name=zone_name)[1]
self.addCleanup(self.wait_zone_delete, self.zones_client, zone['id'],
ignore_errors=lib_exc.NotFound)
LOG.info('Create a zone transfer_request for zone as primary tenant')
- _, transfer_request = \
- self.request_client.create_transfer_request_empty_body(zone['id'])
+ transfer_request = (
+ self.request_client.create_transfer_request_empty_body(
+ zone['id'])[1])
self.addCleanup(self.request_client.delete_transfer_request,
transfer_request['id'])
@@ -58,7 +85,7 @@
self.alt_accept_client.create_transfer_accept(accept_data)
LOG.info('Fetch the zone as alt tenant')
- _, alt_zone = self.alt_zones_client.show_zone(zone['id'])
+ alt_zone = self.alt_zones_client.show_zone(zone['id'])[1]
self.addCleanup(self.wait_zone_delete,
self.alt_zones_client,
alt_zone['id'])
@@ -76,7 +103,9 @@
@decorators.idempotent_id('5855b772-a036-11eb-9973-74e5f9e2a801')
def test_zone_transfer_target_project(self):
LOG.info('Create a zone as "primary" tenant')
- zone = self.zones_client.create_zone()[1]
+ zone_name = dns_data_utils.rand_zone_name(
+ name="zone_transfer_target_project", suffix=self.tld_name)
+ zone = self.zones_client.create_zone(name=zone_name)[1]
LOG.info('Create transfer_request with target project set to '
'"Admin" tenant')
@@ -100,9 +129,14 @@
transfer_accept_data=accept_data)
LOG.info('Accept the request as "Admin" tenant, Expected: should work')
- self.admin_accept_client.create_transfer_accept(accept_data)
+ self.admin_accept_client.create_transfer_accept(
+ accept_data, headers={'x-auth-sudo-project-id':
+ self.os_admin.credentials.project_id},
+ extra_headers=True)
LOG.info('Fetch the zone as "Admin" tenant')
- admin_zone = self.admin_zones_client.show_zone(zone['id'])[1]
+ admin_zone = self.admin_zones_client.show_zone(
+ zone['id'], headers={'x-auth-sudo-project-id':
+ self.os_admin.credentials.project_id})[1]
self.addCleanup(self.wait_zone_delete,
self.admin_zones_client,
admin_zone['id'])