Remove v1 API tests

The V1 API was removed from Designate in the Queens release. It has now been
eight releases since then, so it is time to remove the tests for it. If these
tests are still needed, please use git tag version 0.11.0 (Wallaby) or older.

Change-Id: I496d02c1be165eeaf721dea2eafe5f6a70279e68
This commit is contained in:
Graham Hayes 2017-10-03 12:00:33 +01:00 committed by Michael Johnson
parent da27a70ae2
commit dcfa7c0372
15 changed files with 8 additions and 693 deletions

View File

@ -15,12 +15,6 @@ from tempest import clients
from tempest import config
from tempest.lib import auth
from designate_tempest_plugin.services.dns.v1.json.domains_client import \
DomainsClient
from designate_tempest_plugin.services.dns.v1.json.records_client import \
RecordsClient
from designate_tempest_plugin.services.dns.v1.json.servers_client import \
ServersClient
from designate_tempest_plugin.services.dns.v2.json.zones_client import \
ZonesClient
from designate_tempest_plugin.services.dns.v2.json.zone_imports_client import \
@ -56,30 +50,6 @@ from designate_tempest_plugin.services.dns.v2.json.ptr_client import PtrClient
CONF = config.CONF
class ManagerV1(clients.Manager):
def __init__(self, credentials=None):
super(ManagerV1, self).__init__(credentials)
self._init_clients(self._get_params())
def _init_clients(self, params):
self.domains_client = DomainsClient(**params)
self.records_client = RecordsClient(**params)
self.servers_client = ServersClient(**params)
def _get_params(self):
params = dict(self.default_params)
params.update({
'auth_provider': self.auth_provider,
'service': CONF.dns.catalog_type,
'region': CONF.identity.region,
'endpoint_type': CONF.dns.endpoint_type,
'build_interval': CONF.dns.build_interval,
'build_timeout': CONF.dns.build_timeout
})
return params
class ManagerV2(clients.Manager):
def __init__(self, credentials=None):

View File

@ -59,18 +59,12 @@ dns_feature_group = cfg.OptGroup(name='dns_feature_enabled',
title='Enabled Designate Features')
DnsFeatureGroup = [
cfg.BoolOpt('api_v1',
default=False,
help="Is the v1 dns API enabled."),
cfg.BoolOpt('api_v2',
default=True,
help="Is the v2 dns API enabled."),
cfg.BoolOpt('api_admin',
default=True,
help="Is the admin dns API enabled."),
cfg.BoolOpt('api_v1_servers',
default=False,
help="Is the v1 dns servers API enabled."),
cfg.BoolOpt('api_v2_root_recordsets',
default=False,
help="Is the v2 root recordsets API enabled."),

View File

@ -13,7 +13,6 @@
# the License.
from designate_tempest_plugin.services.dns import admin
from designate_tempest_plugin.services.dns import v1
from designate_tempest_plugin.services.dns import v2
__all__ = ['admin', 'v1', 'v2']
__all__ = ['admin', 'v2']

View File

@ -1,22 +0,0 @@
# Copyright (c) 2017 Andrea Frittoli
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
from designate_tempest_plugin.services.dns.v1.json.domains_client import \
DomainsClient
from designate_tempest_plugin.services.dns.v1.json.records_client import \
RecordsClient
from designate_tempest_plugin.services.dns.v1.json.servers_client import \
ServersClient
__all__ = ['DomainsClient', 'RecordsClient', 'ServersClient']

View File

@ -1,28 +0,0 @@
# Copyright 2016 Hewlett Packard Enterprise Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from designate_tempest_plugin.services.dns.json import base
handle_errors = base.handle_errors
class DnsClientV1Base(base.DnsClientBase):
"""Base API V1 Tempest REST client for Designate API"""
uri_prefix = 'v1'
CREATE_STATUS_CODES = [200]
SHOW_STATUS_CODES = [200]
LIST_STATUS_CODES = [200]
PUT_STATUS_CODES = [200]
UPDATE_STATUS_CODES = []
DELETE_STATUS_CODES = [200]

View File

@ -1,95 +0,0 @@
# Copyright 2014 Hewlett-Packard Development Company, L.P
# All Rights Reserved.
# Copyright 2016 Hewlett Packard Enterprise Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from tempest import config
from designate_tempest_plugin.schemas.v1 import domains_schema as schema
from designate_tempest_plugin.services.dns.v1.json import base
CONF = config.CONF
class DomainsClient(base.DnsClientV1Base):
@base.handle_errors
def list_domains(self, params=None):
"""List all domains."""
resp, body = self._list_request('domains', params=params)
self.validate_response(schema.list_domains, resp, body)
return resp, body['domains']
@base.handle_errors
def get_domain(self, uuid, params=None):
"""Gets a specific zone.
:param uuid: Unique identifier of the domain in UUID format.
:param params: A Python dict that represents the query paramaters to
include in the request URI.
:return: Serialized domain as a dictionary.
:return: A tuple with the server response and the deserialized domain.
"""
resp, body = self._show_request('domains', uuid, params=params)
self.validate_response(schema.get_domain, resp, body)
return resp, body
@base.handle_errors
def delete_domain(self, uuid, params=None):
"""Delete the given domain."""
resp, body = self._delete_request('domains', uuid, params=params)
self.validate_response(schema.delete_domain, resp, body)
return resp, body
@base.handle_errors
def create_domain(self, name, email, params=None, **kwargs):
"""Creates a domain."""
post_body = {
"name": name,
"email": email
}
for option in ['ttl', 'description']:
post_param = option
value = kwargs.get(option)
if value is not None:
post_body[post_param] = value
resp, body = self._create_request('domains', post_body, params=params)
self.validate_response(schema.create_domain, resp, body)
return resp, body
@base.handle_errors
def update_domain(self, uuid, params=None, **kwargs):
"""Updates a domain."""
post_body = {}
for option in ['email', 'name', 'ttl', 'description']:
post_param = option
value = kwargs.get(option)
if value is not None:
post_body[post_param] = value
resp, body = self._put_request('domains', uuid, post_body,
params=params)
self.validate_response(schema.update_domain, resp, body)
return resp, body

View File

@ -1,102 +0,0 @@
# Copyright 2014 Hewlett-Packard Development Company, L.P
# All Rights Reserved.
# Copyright 2016 Hewlett Packard Enterprise Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from tempest import config
from designate_tempest_plugin.schemas.v1 import records_schema as schema
from designate_tempest_plugin.services.dns.v1.json import base
CONF = config.CONF
class RecordsClient(base.DnsClientV1Base):
@base.handle_errors
def list_records(self, domain_uuid, params=None):
"""List all records."""
base_uri = 'domains/%s/records' % (domain_uuid)
resp, body = self._list_request(base_uri, params=params)
self.validate_response(schema.list_records, resp, body)
return resp, body['records']
@base.handle_errors
def get_record(self, domain_uuid, uuid, params=None):
"""Get the details of a record."""
base_uri = 'domains/%s/records' % (domain_uuid)
resp, body = self._show_request(base_uri, uuid, params=params)
self.validate_response(schema.get_record, resp, body)
return resp, body
@base.handle_errors
def delete_record(self, domain_uuid, uuid, params=None):
"""Delete the given record."""
base_uri = 'domains/%s/records' % (domain_uuid)
resp, body = self._delete_request(base_uri, uuid, params=params)
self.validate_response(schema.delete_record, resp, body)
return resp, body
@base.handle_errors
def create_record(self, domain_uuid, name, type, data, params=None,
**kwargs):
"""Creates a record."""
base_uri = 'domains/%s/records' % (domain_uuid)
post_body = {
"name": name,
"type": type,
"data": data
}
for option in ['ttl', 'priority', 'description']:
post_param = option
value = kwargs.get(option)
if value is not None:
post_body[post_param] = value
resp, body = self._create_request(base_uri, post_body, params=params)
self.validate_response(schema.create_record, resp, body)
return resp, body
@base.handle_errors
def update_record(self, domain_uuid, uuid, params=None, **kwargs):
"""Updates a record."""
base_uri = 'domains/%s/records' % (domain_uuid)
post_body = {}
for option in ['name', 'type', 'data', 'ttl', 'priority',
'description']:
post_param = option
value = kwargs.get(option)
if value is not None:
post_body[post_param] = value
resp, body = self._put_request(base_uri, uuid, post_body,
params=params)
self.validate_response(schema.update_record, resp, body)
return resp, body

View File

@ -1,88 +0,0 @@
# Copyright 2014 Hewlett-Packard Development Company, L.P
# All Rights Reserved.
# Copyright 2016 Hewlett Packard Enterprise Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from tempest import config
from designate_tempest_plugin.schemas.v1 import servers_schema as schema
from designate_tempest_plugin.services.dns.v1.json import base
CONF = config.CONF
class ServersClient(base.DnsClientV1Base):
@base.handle_errors
def list_servers(self, params=None):
"""List all servers."""
resp, body = self._list_request('servers', params=params)
self.validate_response(schema.list_servers, resp, body)
return resp, body['servers']
@base.handle_errors
def get_server(self, uuid, params=None):
"""Get the details of a server."""
resp, body = self._show_request('servers', uuid, params=params)
self.validate_response(schema.get_server, resp, body)
return resp, body
@base.handle_errors
def delete_server(self, uuid, params=None):
"""Delete the given server."""
resp, body = self._delete_request('servers', uuid, params=params)
self.validate_response(schema.delete_server, resp, body)
return resp, body
@base.handle_errors
def create_server(self, name, params=None, **kwargs):
"""Creates a server."""
post_body = {
"name": name,
}
for option in ['name']:
value = kwargs.get(option)
post_param = option
if value is not None:
post_body[post_param] = value
resp, body = self._create_request('servers', post_body, params=params)
self.validate_response(schema.create_server, resp, body)
return resp, body
@base.handle_errors
def update_server(self, uuid, params=None, **kwargs):
"""Updates a server."""
post_body = {}
for option in ['name']:
post_param = option
value = kwargs.get(option)
if value is not None:
post_body[post_param] = value
resp, body = self._put_request('servers', uuid, post_body,
params=params)
self.validate_response(schema.update_server, resp, body)
return resp, body

View File

@ -1,86 +0,0 @@
# Copyright 2014 Hewlett-Packard Development Company, L.P
# All Rights Reserved.
# Copyright 2016 Hewlett Packard Enterprise Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import six
from tempest.lib.common.utils import data_utils
from tempest.lib import exceptions as lib_exc
from tempest.lib import decorators
from designate_tempest_plugin.tests import base
class DnsDomainsTest(base.BaseDnsV1Test):
@classmethod
def setup_credentials(cls):
# Do not create network resources for these test.
cls.set_network_resources()
super(DnsDomainsTest, cls).setup_credentials()
@classmethod
def setup_clients(cls):
super(DnsDomainsTest, cls).setup_clients()
cls.client = cls.os_primary.domains_client
@classmethod
def resource_setup(cls):
super(DnsDomainsTest, cls).resource_setup()
cls.setup_domains = list()
for i in range(2):
name = data_utils.rand_name('domain') + '.com.'
email = data_utils.rand_name('dns') + '@testmail.com'
_, domain = cls.client.create_domain(name, email)
cls.setup_domains.append(domain)
@classmethod
def resource_cleanup(cls):
for domain in cls.setup_domains:
cls.client.delete_domain(domain['id'])
super(DnsDomainsTest, cls).resource_cleanup()
def _delete_domain(self, domain_id):
self.client.delete_domain(domain_id)
self.assertRaises(lib_exc.NotFound,
self.client.get_domain, domain_id)
@decorators.idempotent_id('a78a4a6a-77a6-4dab-a61a-17df9731bca8')
def test_list_domains(self):
# Get a list of domains
_, domains = self.client.list_domains()
# Verify domains created in setup class are in the list
for domain in self.setup_domains:
self.assertIn(domain['id'],
six.moves.map(lambda x: x['id'], domains))
@decorators.idempotent_id('29f76dd4-2456-4e42-b0ca-bbffcc6bbf59')
def test_create_update_get_domain(self):
# Create Domain
d_name = data_utils.rand_name('domain') + '.com.'
d_email = data_utils.rand_name('dns') + '@testmail.com'
_, domain = self.client.create_domain(name=d_name, email=d_email)
self.addCleanup(self._delete_domain, domain['id'])
self.assertEqual(d_name, domain['name'])
self.assertEqual(d_email, domain['email'])
# Update Domain with ttl
d_ttl = 3600
_, update_domain = self.client.update_domain(domain['id'],
ttl=d_ttl)
self.assertEqual(d_ttl, update_domain['ttl'])
# Get the details of Domain
_, get_domain = self.client.get_domain(domain['id'])
self.assertEqual(update_domain['name'], get_domain['name'])
self.assertEqual(update_domain['email'], get_domain['email'])
self.assertEqual(update_domain['ttl'], get_domain['ttl'])

View File

@ -1,117 +0,0 @@
# Copyright 2014 Hewlett-Packard Development Company, L.P
# All Rights Reserved.
# Copyright 2016 Hewlett Packard Enterprise Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import six
from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
from designate_tempest_plugin.tests import base
class RecordsTest(base.BaseDnsV1Test):
@classmethod
def setup_credentials(cls):
# Do not create network resources for these test.
cls.set_network_resources()
super(RecordsTest, cls).setup_credentials()
@classmethod
def setup_clients(cls):
super(RecordsTest, cls).setup_clients()
cls.client = cls.os_primary.records_client
@classmethod
def resource_setup(cls):
super(RecordsTest, cls).resource_setup()
# Creates domains and Records for testcase
cls.setup_records = list()
name = data_utils.rand_name('domain') + '.com.'
email = data_utils.rand_name('dns') + '@testmail.com'
_, cls.domain = cls.os_primary.domains_client.create_domain(
name, email)
# Creates a record with type as A
r_name = 'www.' + name
data1 = "192.0.2.3"
_, record = cls.client.create_record(
cls.domain['id'], name=r_name, data=data1,
type='A')
cls.setup_records.append(record)
# Creates a record with type AAAA
data2 = "2001:db8:0:1234:0:5678:9:12"
_, record = cls.client.create_record(
cls.domain['id'], name=r_name,
data=data2, type='AAAA')
cls.setup_records.append(record)
@classmethod
def resource_cleanup(cls):
for record in cls.setup_records:
cls.client.delete_record(cls.domain['id'], record['id'])
cls.os_primary.domains_client.delete_domain(cls.domain['id'])
super(RecordsTest, cls).resource_cleanup()
def _delete_record(self, domain_id, record_id):
self.client.delete_record(domain_id, record_id)
# TODO(kiall): Records in v1 should 404 immediatly after deletion.
# self.assertRaises(lib_exc.NotFound,
# self.client.get_record, domain_id, record_id)
@decorators.idempotent_id('4c7bee47-68a4-4668-81f9-fa973ddfa1f1')
def test_list_records_for_domain(self):
# Get a list of records for a domain
_, records = self.client.list_records(self.domain['id'])
# Verify records created in setup class are in the list
for record in self.setup_records:
self.assertIn(record['id'],
six.moves.map(lambda x: x['id'], records))
@decorators.idempotent_id('1714fe3a-8a29-420e-a7dc-8209c7c174de')
def test_create_update_get_delete_record(self):
# Create Domain
name = data_utils.rand_name('domain') + '.com.'
email = data_utils.rand_name('dns') + '@testmail.com'
_, domain = self.os.domains_client.create_domain(name, email)
self.addCleanup(self.os.domains_client.delete_domain, domain['id'])
# Create Record
r_name = 'www.' + name
r_data = "192.0.2.4"
_, record = self.client.create_record(domain['id'],
name=r_name, data=r_data,
type='A')
self.addCleanup(self._delete_record, domain['id'], record['id'])
self.assertIsNotNone(record['id'])
self.assertEqual(domain['id'], record['domain_id'])
self.assertEqual(r_name, record['name'])
self.assertEqual(r_data, record['data'])
self.assertEqual('A', record['type'])
# Update Record with data and ttl
r_data1 = "192.0.2.5"
r_ttl = 3600
_, update_record = self.client.update_record(domain['id'],
record['id'],
name=r_name, type='A',
data=r_data1, ttl=r_ttl)
self.assertEqual(r_data1, update_record['data'])
self.assertEqual(r_ttl, update_record['ttl'])
# GET record
_, get_record = self.client.get_record(domain['id'], record['id'])
self.assertEqual(update_record['data'], get_record['data'])
self.assertEqual(update_record['name'], get_record['name'])
self.assertEqual(update_record['type'], get_record['type'])
self.assertEqual(update_record['ttl'], get_record['ttl'])
self.assertEqual(update_record['domain_id'], get_record['domain_id'])

View File

@ -1,101 +0,0 @@
# Copyright 2014 Hewlett-Packard Development Company, L.P.
# Copyright 2016 Hewlett Packard Enterprise Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import six
from tempest.lib.common.utils import data_utils
from tempest.lib import exceptions as lib_exc
from tempest import config
from tempest.lib import decorators
from designate_tempest_plugin.tests import base
CONF = config.CONF
class ServersAdminTest(base.BaseDnsV1Test):
"""
Tests Servers API Create, Get, List and Delete
that require admin privileges
"""
credentials = ['admin']
@classmethod
def setup_credentials(cls):
# Do not create network resources for these test.
cls.set_network_resources()
super(ServersAdminTest, cls).setup_credentials()
@classmethod
def setup_clients(cls):
super(ServersAdminTest, cls).setup_clients()
cls.client = cls.os_admin.servers_client
@classmethod
def skip_checks(cls):
super(ServersAdminTest, cls).skip_checks()
if not CONF.dns_feature_enabled.api_v1_servers:
skip_msg = ("%s skipped as designate V1 servers API is not "
"available" % cls.__name__)
raise cls.skipException(skip_msg)
@classmethod
def resource_setup(cls):
super(ServersAdminTest, cls).resource_setup()
cls.setup_servers = list()
for i in range(2):
name = data_utils.rand_name('dns-server') + '.com.'
_, server = cls.client.create_server(name)
cls.setup_servers.append(server)
@classmethod
def resource_cleanup(cls):
for server in cls.setup_servers:
cls.client.delete_server(server['id'])
super(ServersAdminTest, cls).resource_cleanup()
def _delete_server(self, server_id):
self.client.delete_server(server_id)
self.assertRaises(lib_exc.NotFound,
self.client.get_server, server_id)
@decorators.idempotent_id('0296fb0c-f400-4b52-9be4-a24f37646e3f')
def test_list_servers(self):
# Get a list of servers
_, servers = self.client.list_servers()
# Verify servers created in setup class are in the list
for server in self.setup_servers:
self.assertIn(server['id'],
six.moves.map(lambda x: x['id'], servers))
@decorators.idempotent_id('7d18fdfc-3959-4c3f-9855-0bf2f8c9ade2')
def test_create_update_get_delete_server(self):
# Create Dns Server
s_name1 = data_utils.rand_name('dns-server') + '.com.'
_, server = self.client.create_server(s_name1)
self.addCleanup(self._delete_server, server['id'])
self.assertEqual(s_name1, server['name'])
self.assertIsNotNone(server['id'])
# Update Dns Server
s_name2 = data_utils.rand_name('update-dns-server') + '.com.'
_, update_server = self.client.update_server(server['id'],
name=s_name2)
self.assertEqual(s_name2, update_server['name'])
# Get the details of Server
_, get_server = self.client.get_server(server['id'])
self.assertEqual(update_server['name'], get_server['name'])

View File

@ -119,22 +119,6 @@ class BaseDnsTest(test.BaseTestCase):
zone_id) is None
class BaseDnsV1Test(BaseDnsTest):
"""Base class for DNS V1 API tests."""
# Use the Designate V1 Client Manager
client_manager = clients.ManagerV1
@classmethod
def skip_checks(cls):
super(BaseDnsV1Test, cls).skip_checks()
if not CONF.dns_feature_enabled.api_v1:
skip_msg = ("%s skipped as designate v1 API is not available"
% cls.__name__)
raise cls.skipException(skip_msg)
class BaseDnsV2Test(BaseDnsTest):
"""Base class for DNS V2 API tests."""

View File

@ -0,0 +1,7 @@
---
other:
- |
The Designate API V1 tests have been removed. The V1 API was removed
from Designate in the Queens release. It has now been eight releases
since then, so it is time to remove the tests for it. If these tests are
still needed, please use git tag version 0.11.0 (Wallaby) or older.