Remove zone import and export client methods + tests
This patch removes zone_import and zone_export client's methods and tests as they have been moved to designate-tempest-plugin. Change-Id: I38258c1bdfd32b7719f25df795acde2af5e66eec
This commit is contained in:
parent
e23eb9a030
commit
696503281b
@ -1,75 +0,0 @@
|
|||||||
"""
|
|
||||||
Copyright 2015 Rackspace
|
|
||||||
|
|
||||||
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 functionaltests.api.v2.models.zone_export_model import ZoneExportModel
|
|
||||||
from functionaltests.api.v2.models.zone_export_model import ZoneExportListModel
|
|
||||||
from functionaltests.common import utils
|
|
||||||
from functionaltests.common.client import ClientMixin
|
|
||||||
from functionaltests.common.models import ZoneFile
|
|
||||||
|
|
||||||
|
|
||||||
class ZoneExportClient(ClientMixin):
|
|
||||||
|
|
||||||
def zone_exports_uri(self, filters=None):
|
|
||||||
return self.create_uri("/zones/tasks/exports", filters=filters)
|
|
||||||
|
|
||||||
def create_zone_export_uri(self, zone_id, filters=None):
|
|
||||||
return self.create_uri(
|
|
||||||
"/zones/{0}/tasks/export".format(zone_id),
|
|
||||||
filters=filters,
|
|
||||||
)
|
|
||||||
|
|
||||||
def zone_export_uri(self, id):
|
|
||||||
return "{0}/{1}".format(self.zone_exports_uri(), id)
|
|
||||||
|
|
||||||
def list_zone_exports(self, filters=None, **kwargs):
|
|
||||||
resp, body = self.client.get(
|
|
||||||
self.zone_exports_uri(filters), **kwargs)
|
|
||||||
return self.deserialize(resp, body, ZoneExportListModel)
|
|
||||||
|
|
||||||
def get_zone_export(self, id, **kwargs):
|
|
||||||
resp, body = self.client.get(self.zone_export_uri(id))
|
|
||||||
return self.deserialize(resp, body, ZoneExportModel)
|
|
||||||
|
|
||||||
def get_exported_zone(self, id, **kwargs):
|
|
||||||
uri = "{0}/export".format(self.zone_export_uri(id))
|
|
||||||
headers = {'Accept': 'text/dns'}
|
|
||||||
resp, body = self.client.get(uri, headers=headers)
|
|
||||||
if resp.status < 400:
|
|
||||||
return resp, ZoneFile.from_text(body)
|
|
||||||
return resp, body
|
|
||||||
|
|
||||||
def post_zone_export(self, zone_id, **kwargs):
|
|
||||||
uri = self.create_zone_export_uri(zone_id)
|
|
||||||
resp, body = self.client.post(uri, body='', **kwargs)
|
|
||||||
return self.deserialize(resp, body, ZoneExportModel)
|
|
||||||
|
|
||||||
def delete_zone_export(self, id, **kwargs):
|
|
||||||
resp, body = self.client.delete(self.zone_export_uri(id), **kwargs)
|
|
||||||
return resp, body
|
|
||||||
|
|
||||||
def wait_for_zone_export(self, zone_export_id):
|
|
||||||
utils.wait_for_condition(
|
|
||||||
lambda: self.is_zone_export_active(zone_export_id))
|
|
||||||
|
|
||||||
def is_zone_export_active(self, zone_export_id):
|
|
||||||
resp, model = self.get_zone_export(zone_export_id)
|
|
||||||
# don't have assertEqual but still want to fail fast
|
|
||||||
assert resp.status == 200
|
|
||||||
if model.status == 'COMPLETE':
|
|
||||||
return True
|
|
||||||
elif model.status == 'ERROR':
|
|
||||||
raise Exception("Saw ERROR status")
|
|
||||||
return False
|
|
@ -1,61 +0,0 @@
|
|||||||
"""
|
|
||||||
Copyright 2015 Rackspace
|
|
||||||
|
|
||||||
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 functionaltests.api.v2.models.zone_import_model import ZoneImportModel
|
|
||||||
from functionaltests.api.v2.models.zone_import_model import ZoneImportListModel
|
|
||||||
from functionaltests.common.client import ClientMixin
|
|
||||||
from functionaltests.common import utils
|
|
||||||
|
|
||||||
|
|
||||||
class ZoneImportClient(ClientMixin):
|
|
||||||
|
|
||||||
def zone_imports_uri(self, filters=None):
|
|
||||||
return self.create_uri("/zones/tasks/imports", filters=filters)
|
|
||||||
|
|
||||||
def zone_import_uri(self, id):
|
|
||||||
return "{0}/{1}".format(self.zone_imports_uri(), id)
|
|
||||||
|
|
||||||
def list_zone_imports(self, filters=None, **kwargs):
|
|
||||||
resp, body = self.client.get(
|
|
||||||
self.zone_imports_uri(filters), **kwargs)
|
|
||||||
return self.deserialize(resp, body, ZoneImportListModel)
|
|
||||||
|
|
||||||
def get_zone_import(self, id, **kwargs):
|
|
||||||
resp, body = self.client.get(self.zone_import_uri(id))
|
|
||||||
return self.deserialize(resp, body, ZoneImportModel)
|
|
||||||
|
|
||||||
def post_zone_import(self, zonefile_data, **kwargs):
|
|
||||||
headers = {'Content-Type': 'text/dns'}
|
|
||||||
resp, body = self.client.post(self.zone_imports_uri(),
|
|
||||||
body=zonefile_data, headers=headers, **kwargs)
|
|
||||||
return self.deserialize(resp, body, ZoneImportModel)
|
|
||||||
|
|
||||||
def delete_zone_import(self, id, **kwargs):
|
|
||||||
resp, body = self.client.delete(self.zone_import_uri(id), **kwargs)
|
|
||||||
return resp, body
|
|
||||||
|
|
||||||
def wait_for_zone_import(self, zone_import_id):
|
|
||||||
utils.wait_for_condition(
|
|
||||||
lambda: self.is_zone_import_active(zone_import_id))
|
|
||||||
|
|
||||||
def is_zone_import_active(self, zone_import_id):
|
|
||||||
resp, model = self.get_zone_import(zone_import_id)
|
|
||||||
# don't have assertEqual but still want to fail fast
|
|
||||||
assert resp.status == 200
|
|
||||||
if model.status == 'COMPLETE':
|
|
||||||
return True
|
|
||||||
elif model.status == 'ERROR':
|
|
||||||
raise Exception("Saw ERROR status")
|
|
||||||
return False
|
|
@ -28,8 +28,6 @@ from functionaltests.api.v2.clients.pool_client import PoolClient
|
|||||||
from functionaltests.api.v2.clients.recordset_client import RecordsetClient
|
from functionaltests.api.v2.clients.recordset_client import RecordsetClient
|
||||||
from functionaltests.api.v2.clients.tld_client import TLDClient
|
from functionaltests.api.v2.clients.tld_client import TLDClient
|
||||||
from functionaltests.api.v2.clients.zone_client import ZoneClient
|
from functionaltests.api.v2.clients.zone_client import ZoneClient
|
||||||
from functionaltests.api.v2.clients.zone_import_client import ZoneImportClient
|
|
||||||
from functionaltests.api.v2.clients.zone_export_client import ZoneExportClient
|
|
||||||
from functionaltests.api.v2.clients.transfer_requests_client import \
|
from functionaltests.api.v2.clients.transfer_requests_client import \
|
||||||
TransferRequestClient
|
TransferRequestClient
|
||||||
from functionaltests.common import datagen
|
from functionaltests.common import datagen
|
||||||
@ -78,60 +76,6 @@ class ZoneFixture(BaseFixture):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class ZoneImportFixture(BaseFixture):
|
|
||||||
|
|
||||||
def __init__(self, post_model=None, user='default'):
|
|
||||||
super(ZoneImportFixture, self).__init__()
|
|
||||||
self.post_model = post_model or datagen.random_zonefile_data()
|
|
||||||
self.user = user
|
|
||||||
|
|
||||||
def _setUp(self):
|
|
||||||
super(ZoneImportFixture, self)._setUp()
|
|
||||||
self._import_zone()
|
|
||||||
|
|
||||||
def _import_zone(self):
|
|
||||||
client = ZoneImportClient.as_user(self.user)
|
|
||||||
self.post_resp, self.zone_import = client.post_zone_import(
|
|
||||||
self.post_model)
|
|
||||||
assert self.post_resp.status == 202
|
|
||||||
self.addCleanup(self.cleanup_zone_import, client, self.zone_import.id)
|
|
||||||
client.wait_for_zone_import(self.zone_import.id)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def cleanup_zone_import(cls, client, import_id):
|
|
||||||
try:
|
|
||||||
client.delete_zone_import(import_id)
|
|
||||||
except NotFound:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ZoneExportFixture(BaseFixture):
|
|
||||||
|
|
||||||
def __init__(self, zone_id, user='default'):
|
|
||||||
super(ZoneExportFixture, self).__init__()
|
|
||||||
self.zone_id = zone_id
|
|
||||||
self.user = user
|
|
||||||
|
|
||||||
def _setUp(self):
|
|
||||||
super(ZoneExportFixture, self)._setUp()
|
|
||||||
self._export_zone()
|
|
||||||
|
|
||||||
def _export_zone(self):
|
|
||||||
client = ZoneExportClient.as_user(self.user)
|
|
||||||
self.post_resp, self.zone_export = client.post_zone_export(
|
|
||||||
self.zone_id)
|
|
||||||
assert self.post_resp.status == 202
|
|
||||||
self.addCleanup(self.cleanup_zone_export, client, self.zone_export.id)
|
|
||||||
client.wait_for_zone_export(self.zone_export.id)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def cleanup_zone_export(cls, client, export_id):
|
|
||||||
try:
|
|
||||||
client.delete_zone_export(export_id)
|
|
||||||
except NotFound:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class RecordsetFixture(BaseFixture):
|
class RecordsetFixture(BaseFixture):
|
||||||
|
|
||||||
def __init__(self, zone_id, post_model, user='default'):
|
def __init__(self, zone_id, post_model, user='default'):
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
"""
|
|
||||||
Copyright 2015 Rackspace
|
|
||||||
|
|
||||||
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 functionaltests.common.models import BaseModel
|
|
||||||
from functionaltests.common.models import CollectionModel
|
|
||||||
|
|
||||||
|
|
||||||
class ZoneExportModel(BaseModel):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ZoneExportListModel(CollectionModel):
|
|
||||||
COLLECTION_NAME = 'exports'
|
|
||||||
MODEL_TYPE = ZoneExportModel
|
|
@ -1,27 +0,0 @@
|
|||||||
"""
|
|
||||||
Copyright 2015 Rackspace
|
|
||||||
|
|
||||||
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 functionaltests.common.models import BaseModel
|
|
||||||
from functionaltests.common.models import CollectionModel
|
|
||||||
|
|
||||||
|
|
||||||
class ZoneImportModel(BaseModel):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ZoneImportListModel(CollectionModel):
|
|
||||||
COLLECTION_NAME = 'imports'
|
|
||||||
MODEL_TYPE = ZoneImportModel
|
|
@ -1,98 +0,0 @@
|
|||||||
"""
|
|
||||||
Copyright 2015 Rackspace
|
|
||||||
|
|
||||||
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_lib.exceptions import NotFound
|
|
||||||
|
|
||||||
from functionaltests.api.v2.base import DesignateV2Test
|
|
||||||
from functionaltests.api.v2.clients.recordset_client import RecordsetClient
|
|
||||||
from functionaltests.api.v2.clients.zone_client import ZoneClient
|
|
||||||
from functionaltests.api.v2.clients.zone_import_client import ZoneImportClient
|
|
||||||
from functionaltests.api.v2.clients.zone_export_client import ZoneExportClient
|
|
||||||
from functionaltests.api.v2.fixtures import ZoneFixture
|
|
||||||
from functionaltests.api.v2.fixtures import ZoneImportFixture
|
|
||||||
from functionaltests.api.v2.fixtures import ZoneExportFixture
|
|
||||||
from functionaltests.common.models import ZoneFileRecord
|
|
||||||
|
|
||||||
|
|
||||||
class ZoneImportTest(DesignateV2Test):
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
super(ZoneImportTest, self).setUp()
|
|
||||||
self.increase_quotas(user='default')
|
|
||||||
self.ensure_tld_exists('com')
|
|
||||||
|
|
||||||
def test_import_domain(self):
|
|
||||||
user = 'default'
|
|
||||||
import_client = ZoneImportClient.as_user(user)
|
|
||||||
zone_client = ZoneClient.as_user(user)
|
|
||||||
|
|
||||||
fixture = self.useFixture(ZoneImportFixture(user=user))
|
|
||||||
import_id = fixture.zone_import.id
|
|
||||||
|
|
||||||
resp, model = import_client.get_zone_import(import_id)
|
|
||||||
self.assertEqual(200, resp.status)
|
|
||||||
self.assertEqual('COMPLETE', model.status)
|
|
||||||
self.addCleanup(ZoneFixture.cleanup_zone, zone_client, model.zone_id)
|
|
||||||
|
|
||||||
# Wait for the zone to become 'ACTIVE'
|
|
||||||
zone_client.wait_for_zone(model.zone_id)
|
|
||||||
resp, zone_model = zone_client.get_zone(model.zone_id)
|
|
||||||
|
|
||||||
# Now make sure we can delete the zone_import
|
|
||||||
import_client.delete_zone_import(import_id)
|
|
||||||
self.assertRaises(NotFound,
|
|
||||||
lambda: import_client.get_zone_import(model.id))
|
|
||||||
|
|
||||||
|
|
||||||
class ZoneExportTest(DesignateV2Test):
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
super(ZoneExportTest, self).setUp()
|
|
||||||
self.increase_quotas(user='default')
|
|
||||||
self.ensure_tld_exists('com')
|
|
||||||
|
|
||||||
def test_export_domain(self):
|
|
||||||
user = 'default'
|
|
||||||
zone_fixture = self.useFixture(ZoneFixture(user=user))
|
|
||||||
zone = zone_fixture.created_zone
|
|
||||||
|
|
||||||
export_fixture = self.useFixture(ZoneExportFixture(zone.id, user=user))
|
|
||||||
export_id = export_fixture.zone_export.id
|
|
||||||
|
|
||||||
export_client = ZoneExportClient.as_user(user)
|
|
||||||
|
|
||||||
resp, model = export_client.get_zone_export(export_id)
|
|
||||||
self.assertEqual(200, resp.status)
|
|
||||||
self.assertEqual('COMPLETE', model.status)
|
|
||||||
|
|
||||||
# fetch the zone file
|
|
||||||
resp, zone_file = export_client.get_exported_zone(export_id)
|
|
||||||
self.assertEqual(200, resp.status)
|
|
||||||
self.assertEqual(zone.name, zone_file.origin)
|
|
||||||
self.assertEqual(zone.ttl, zone_file.ttl)
|
|
||||||
|
|
||||||
# the list of records in the zone file must match the zone's recordsets
|
|
||||||
# (in this case there should be only two records - a SOA and an NS?)
|
|
||||||
recordset_client = RecordsetClient.as_user(user)
|
|
||||||
resp, model = recordset_client.list_recordsets(zone.id)
|
|
||||||
records = []
|
|
||||||
for recordset in model.recordsets:
|
|
||||||
records.extend(ZoneFileRecord.records_from_recordset(recordset))
|
|
||||||
self.assertEqual(set(records), set(zone_file.records))
|
|
||||||
|
|
||||||
export_client.delete_zone_export(export_id)
|
|
||||||
self.assertRaises(NotFound,
|
|
||||||
lambda: export_client.get_zone_export(export_id))
|
|
Loading…
Reference in New Issue
Block a user