diff --git a/doc/source/index.rst b/doc/source/index.rst index f959118f..fe001c90 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -49,6 +49,7 @@ Reference Documentation glossary backends integrations + tempest Source Documentation ==================== diff --git a/doc/source/tempest.rst b/doc/source/tempest.rst new file mode 100644 index 00000000..34ddd22f --- /dev/null +++ b/doc/source/tempest.rst @@ -0,0 +1,71 @@ +.. _tempest: + +=============== + Tempest tests +=============== + +The Tempest tests are functional tests that hit a live Designate endpoint and +verify responses. + +Installation +============ + +The tests depend on both ``tempest-lib`` and ``tempest``: + +:: + + # install tempest + git clone https://github.com/openstack/tempest.git + pip install tempest/ + + # tempest-lib is in test-requirements.txt + cd designate + pip install -r requirements.txt -r test-requirements.txt + python setup.py develop + +Configuration +============= + +The Tempest tests look for the file ``functionaltests/designate-tempest.conf``, +which contains information about your Keystone setup. For the time being, these +tests require Keystone. + +:: + + [identity] + # Replace these with values that represent your identity configuration + uri=http://localhost:5000/v2.0 + uri_v3=http://localhost:5000/v3 + auth_version=v2 + region=RegionOne + + username=admin + tenant_name=admin + password=password + domain_name=Default + + admin_username=admin + admin_tenant_name=admin + admin_password=password + admin_domain_name=Default + + +Execution +========= + +The tests should work with any test runner, like ``nose``: + +:: + + cd functionaltests + pip install nose + nosetests --logging-level=WARN api/ + +A file ``.testr.conf`` is included for use with ``testr``: + +:: + + cd functionaltests + pip install testrepository + testr init + testr run diff --git a/functionaltests/.testr.conf b/functionaltests/.testr.conf new file mode 100644 index 00000000..c31512a3 --- /dev/null +++ b/functionaltests/.testr.conf @@ -0,0 +1,4 @@ +[DEFAULT] +test_command=python -m subunit.run discover ./api $LISTOPT $IDOPTION +test_id_option=--load-list $IDFILE +test_list_option=--list diff --git a/functionaltests/__init__.py b/functionaltests/__init__.py new file mode 100644 index 00000000..07190543 --- /dev/null +++ b/functionaltests/__init__.py @@ -0,0 +1,19 @@ +""" +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.config import CONF + +CONF.set_config_path('designate-tempest.conf') diff --git a/functionaltests/api/__init__.py b/functionaltests/api/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/functionaltests/api/v2/__init__.py b/functionaltests/api/v2/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/functionaltests/api/v2/test_zone.py b/functionaltests/api/v2/test_zone.py new file mode 100644 index 00000000..ad0a21bf --- /dev/null +++ b/functionaltests/api/v2/test_zone.py @@ -0,0 +1,31 @@ +""" +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. +""" + +import tempest_lib +import tempest_lib.base + +from functionaltests.common.client import DesignateClient + + +class ZoneTest(tempest_lib.base.BaseTestCase): + + def __init__(self, *args, **kwargs): + super(ZoneTest, self).__init__(*args, **kwargs) + self.client = DesignateClient() + + def test_list_zones(self): + resp, body = self.client.get('/v2/zones') + self.assertEqual(resp.status, 200) diff --git a/functionaltests/common/__init__.py b/functionaltests/common/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/functionaltests/common/client.py b/functionaltests/common/client.py new file mode 100644 index 00000000..db250915 --- /dev/null +++ b/functionaltests/common/client.py @@ -0,0 +1,37 @@ +""" +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.common.rest_client import RestClient +from tempest.auth import KeystoneV2Credentials +from tempest.config import CONF +import tempest.manager + + +class DesignateClient(RestClient): + + def __init__(self): + creds = KeystoneV2Credentials( + username=CONF.identity.username, + password=CONF.identity.password, + tenant_name=CONF.identity.tenant_name, + ) + auth_provider = tempest.manager.get_auth_provider(creds) + auth_provider.fill_credentials() + super(DesignateClient, self).__init__( + auth_provider=auth_provider, + service='dns', + region=CONF.identity.region, + )