Initial designate domains and server tests
Change-Id: I5fa767fc5cd7522cde0be9260fd04736ee494338
This commit is contained in:
15
cloudroast/designate/__init__.py
Normal file
15
cloudroast/designate/__init__.py
Normal file
@@ -0,0 +1,15 @@
|
||||
"""
|
||||
Copyright 2013 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.
|
||||
"""
|
||||
82
cloudroast/designate/fixtures.py
Normal file
82
cloudroast/designate/fixtures.py
Normal file
@@ -0,0 +1,82 @@
|
||||
"""
|
||||
Copyright 2013 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 cafe.drivers.unittest.fixtures import BaseTestFixture
|
||||
from cloudcafe.common.resources import ResourcePool
|
||||
from cloudcafe.common.tools.datagen import rand_name
|
||||
from cloudcafe.designate.config import DesignateConfig
|
||||
from cloudcafe.designate.config import MarshallingConfig
|
||||
from cloudcafe.designate.v1.domain_api.client import DomainAPIClient
|
||||
from cloudcafe.designate.v1.server_api.client import ServerAPIClient
|
||||
from cloudcafe.designate.behaviors import DomainBehaviors
|
||||
from cloudcafe.designate.behaviors import ServerBehaviors
|
||||
|
||||
|
||||
class DesignateFixture(BaseTestFixture):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(DesignateFixture, cls).setUpClass()
|
||||
cls.designate_config = DesignateConfig()
|
||||
cls.marshalling = MarshallingConfig()
|
||||
|
||||
v1_client_args = [cls.designate_config.url_v1,
|
||||
cls.marshalling.serializer,
|
||||
cls.marshalling.deserializer]
|
||||
|
||||
cls.domain_client = DomainAPIClient(*v1_client_args)
|
||||
cls.server_client = ServerAPIClient(*v1_client_args)
|
||||
|
||||
cls.domain_behaviors = DomainBehaviors(cls.domain_client,
|
||||
config=cls.designate_config)
|
||||
cls.server_behaviors = ServerBehaviors(cls.server_client)
|
||||
|
||||
cls.resources = ResourcePool()
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
cls.resources.release()
|
||||
|
||||
|
||||
class ServersFixture(DesignateFixture):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(ServersFixture, cls).setUpClass()
|
||||
|
||||
# ensure one server exists beforehand; else, server delete tests will
|
||||
# fail since the api prevents us from deleting the last remaining
|
||||
# server. And no domains can be created without at least one server.
|
||||
cls.create_server()
|
||||
|
||||
@classmethod
|
||||
def create_server(cls, *args, **kwargs):
|
||||
response = cls.server_behaviors.create_server(*args, **kwargs)
|
||||
if response.status_code == 200:
|
||||
cls.resources.add(response.entity.id,
|
||||
cls.server_client.delete_server)
|
||||
return response
|
||||
|
||||
|
||||
class DomainsFixture(ServersFixture):
|
||||
|
||||
@classmethod
|
||||
def create_domain(cls, *args, **kwargs):
|
||||
response = cls.domain_behaviors.create_domain(*args, **kwargs)
|
||||
if response.status_code == 200:
|
||||
cls.resources.add(response.entity.id,
|
||||
cls.domain_client.delete_domain)
|
||||
return response
|
||||
15
cloudroast/designate/smoke/__init__.py
Normal file
15
cloudroast/designate/smoke/__init__.py
Normal file
@@ -0,0 +1,15 @@
|
||||
"""
|
||||
Copyright 2013 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.
|
||||
"""
|
||||
15
cloudroast/designate/smoke/v1/__init__.py
Normal file
15
cloudroast/designate/smoke/v1/__init__.py
Normal file
@@ -0,0 +1,15 @@
|
||||
"""
|
||||
Copyright 2013 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.
|
||||
"""
|
||||
77
cloudroast/designate/smoke/v1/domains.py
Normal file
77
cloudroast/designate/smoke/v1/domains.py
Normal file
@@ -0,0 +1,77 @@
|
||||
"""
|
||||
Copyright 2013 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.
|
||||
"""
|
||||
|
||||
import json
|
||||
|
||||
from cafe.drivers.unittest.decorators import tags
|
||||
from cloudcafe.common.tools.datagen import rand_name
|
||||
|
||||
from cloudroast.designate.fixtures import DomainsFixture
|
||||
|
||||
|
||||
class DomainTest(DomainsFixture):
|
||||
|
||||
@tags('smoke', 'positive')
|
||||
def test_list_domains(self):
|
||||
self.create_domain()
|
||||
list_resp = self.domain_client.list_domains()
|
||||
self.assertEquals(list_resp.status_code, 200)
|
||||
self.assertGreater(len(list_resp.entity), 0)
|
||||
|
||||
domains = list_resp.entity
|
||||
for domain in domains:
|
||||
get_resp = self.domain_client.get_domain(domain.id)
|
||||
self.assertEquals(get_resp.status_code, 200)
|
||||
|
||||
@tags('smoke', 'positive')
|
||||
def test_create_domain(self):
|
||||
create_resp = self.create_domain()
|
||||
self.assertEquals(create_resp.status_code, 200)
|
||||
|
||||
get_resp = self.domain_client.get_domain(create_resp.entity.id)
|
||||
self.assertEquals(get_resp.status_code, 200)
|
||||
|
||||
@tags('smoke', 'positive')
|
||||
def test_update_domain(self):
|
||||
name, email = self.domain_behaviors._prepare_domain_and_email()
|
||||
create_resp = self.create_domain(name=name, email=email)
|
||||
domain_id = create_resp.entity.id
|
||||
|
||||
# the updated email address must have the same domain
|
||||
new_email = "new_" + email
|
||||
update_resp = self.domain_behaviors.update_domain(domain_id=domain_id,
|
||||
email=new_email,
|
||||
name=name)
|
||||
self.assertEquals(update_resp.status_code, 200)
|
||||
|
||||
@tags('smoke', 'positive')
|
||||
def test_delete_domain(self):
|
||||
create_resp = self.create_domain()
|
||||
domain_id = create_resp.entity.id
|
||||
|
||||
del_resp = self.domain_client.delete_domain(domain_id)
|
||||
self.assertEquals(del_resp.status_code, 200)
|
||||
|
||||
@tags('smoke', 'positive')
|
||||
def test_list_domain_servers(self):
|
||||
create_resp = self.create_domain()
|
||||
domain_id = create_resp.entity.id
|
||||
|
||||
list_resp = self.domain_client.list_domain_servers(domain_id)
|
||||
self.assertEquals(list_resp.status_code, 200)
|
||||
|
||||
servers = list_resp.entity
|
||||
self.assertGreater(len(servers), 0)
|
||||
68
cloudroast/designate/smoke/v1/server.py
Normal file
68
cloudroast/designate/smoke/v1/server.py
Normal file
@@ -0,0 +1,68 @@
|
||||
"""
|
||||
Copyright 2013 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.
|
||||
"""
|
||||
|
||||
import json
|
||||
|
||||
from cafe.drivers.unittest.decorators import tags
|
||||
from cloudcafe.common.tools.datagen import rand_name
|
||||
|
||||
from cloudroast.designate.fixtures import ServersFixture
|
||||
|
||||
|
||||
class ServerTest(ServersFixture):
|
||||
|
||||
@tags('smoke', 'positive')
|
||||
def test_list_servers(self):
|
||||
self.create_server()
|
||||
list_resp = self.server_client.list_servers()
|
||||
self.assertEquals(list_resp.status_code, 200)
|
||||
|
||||
servers = list_resp.entity
|
||||
self.assertGreater(len(servers), 0)
|
||||
|
||||
@tags('smoke', 'positive')
|
||||
def test_create_server(self):
|
||||
create_resp = self.create_server()
|
||||
self.assertEquals(create_resp.status_code, 200)
|
||||
|
||||
server_id = create_resp.entity.id
|
||||
|
||||
get_resp = self.server_client.get_server(server_id)
|
||||
self.assertEquals(get_resp.status_code, 200)
|
||||
|
||||
@tags('smoke', 'positive')
|
||||
def test_update_server(self):
|
||||
create_resp = self.create_server()
|
||||
self.assertEquals(create_resp.status_code, 200)
|
||||
|
||||
server_id = create_resp.entity.id
|
||||
|
||||
new_name = rand_name("new.server") + ".com."
|
||||
update_resp = self.server_client.update_server(server_id, new_name)
|
||||
self.assertEquals(update_resp.status_code, 200)
|
||||
|
||||
@tags('smoke', 'positive')
|
||||
def test_delete_server(self):
|
||||
create_resp = self.create_server()
|
||||
self.assertEquals(create_resp.status_code, 200)
|
||||
|
||||
server_id = create_resp.entity.id
|
||||
|
||||
del_resp = self.server_client.delete_server(server_id)
|
||||
self.assertEquals(del_resp.status_code, 200)
|
||||
|
||||
get_resp = self.server_client.get_server(server_id)
|
||||
self.assertEquals(get_resp.status_code, 404)
|
||||
Reference in New Issue
Block a user