add functional tests for identity v3

add functional tests for endpoint, region and service.

Change-Id: I504878811dc8f9fcb2295cbf7419885959d9c1f6
Implements: blueprint identity-functional-tests
This commit is contained in:
Guojian Shao 2015-07-14 21:41:07 +08:00 committed by Terry Howe
parent bbe71eb9a3
commit 566987ecf1
5 changed files with 279 additions and 11 deletions

View File

@ -24,17 +24,20 @@ class CatalogTests(test_identity.IdentityTests):
"""test catalog show command
The output example:
+-----------+-------------------------------------------+
| Field | Value |
+-----------+-------------------------------------------+
| endpoints | test1 |
| | publicURL: http://localhost:5000/v2.0 |
| | internalURL: http://localhost:5000/v2.0 |
| | adminURL: http://localhost:5000/v2.0 |
| | |
| name | keystone |
| type | identity |
+-----------+-------------------------------------------+
+-----------+----------------------------------------+
| Field | Value |
+-----------+----------------------------------------+
| endpoints | test1 |
| | public: http://localhost:5000/v2.0 |
| | test1 |
| | internal: http://localhost:5000/v2.0 |
| | test1 |
| | admin: http://localhost:35357/v2.0 |
| | |
| id | e1e68b5ba21a43a39ff1cf58e736c3aa |
| name | keystone |
| type | identity |
+-----------+----------------------------------------+
"""
raw_output = self.openstack('catalog show %s' % 'identity')
items = self.parse_show(raw_output)

View File

@ -0,0 +1,60 @@
# 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.utils import data_utils
from functional.tests.identity.v3 import test_identity
class EndpointTests(test_identity.IdentityTests):
def test_endpoint_create(self):
self._create_dummy_endpoint(interface='public')
self._create_dummy_endpoint(interface='admin')
self._create_dummy_endpoint(interface='internal')
def test_endpoint_delete(self):
endpoint_id = self._create_dummy_endpoint(add_clean_up=False)
raw_output = self.openstack(
'endpoint delete %s' % endpoint_id)
self.assertEqual(0, len(raw_output))
def test_endpoint_list(self):
endpoint_id = self._create_dummy_endpoint()
raw_output = self.openstack('endpoint list')
self.assertInOutput(endpoint_id, raw_output)
items = self.parse_listing(raw_output)
self.assert_table_structure(items, self.ENDPOINT_LIST_HEADERS)
def test_endpoint_set(self):
endpoint_id = self._create_dummy_endpoint()
new_endpoint_url = data_utils.rand_url()
raw_output = self.openstack(
'endpoint set '
'--interface %(interface)s '
'--url %(url)s '
'--disable '
'%(endpoint_id)s' % {'interface': 'admin',
'url': new_endpoint_url,
'endpoint_id': endpoint_id})
self.assertEqual(0, len(raw_output))
raw_output = self.openstack('endpoint show %s' % endpoint_id)
endpoint = self.parse_show_as_object(raw_output)
self.assertEqual('admin', endpoint['interface'])
self.assertEqual(new_endpoint_url, endpoint['url'])
self.assertEqual('False', endpoint['enabled'])
def test_endpoint_show(self):
endpoint_id = self._create_dummy_endpoint()
raw_output = self.openstack('endpoint show %s' % endpoint_id)
items = self.parse_show(raw_output)
self.assert_show_fields(items, self.ENDPOINT_FIELDS)

View File

@ -31,6 +31,16 @@ class IdentityTests(test.TestCase):
PROJECT_FIELDS = ['description', 'id', 'domain_id',
'enabled', 'name', 'parent_id', 'links']
ROLE_FIELDS = ['id', 'name', 'links']
SERVICE_FIELDS = ['id', 'enabled', 'name', 'type', 'description']
REGION_FIELDS = ['description', 'enabled', 'parent_region',
'region', 'url']
ENDPOINT_FIELDS = ['id', 'region', 'region_id', 'service_id',
'service_name', 'service_type', 'enabled',
'interface', 'url']
REGION_LIST_HEADERS = ['Region', 'Parent Region', 'Description', 'URL']
ENDPOINT_LIST_HEADERS = ['ID', 'Region', 'Service Name', 'Service Type',
'Enabled', 'Interface', 'URL']
@classmethod
def setUpClass(cls):
@ -68,7 +78,9 @@ class IdentityTests(test.TestCase):
@classmethod
def tearDownClass(cls):
# delete dummy project
cls.openstack('project delete %s' % cls.project_name)
# disable and delete dummy domain
cls.openstack('domain set --disable %s' % cls.domain_name)
cls.openstack('domain delete %s' % cls.domain_name)
@ -173,3 +185,69 @@ class IdentityTests(test.TestCase):
'%(name)s' % {'domain': self.domain_name,
'name': project_name})
return project_name
def _create_dummy_region(self, parent_region=None, add_clean_up=True):
region_id = data_utils.rand_name('TestRegion')
description = data_utils.rand_name('description')
url = data_utils.rand_url()
parent_region_arg = ''
if parent_region is not None:
parent_region_arg = '--parent-region %s' % parent_region
raw_output = self.openstack(
'region create '
'%(parent_region_arg)s '
'--description %(description)s '
'--url %(url)s '
'%(id)s' % {'parent_region_arg': parent_region_arg,
'description': description,
'url': url,
'id': region_id})
items = self.parse_show(raw_output)
self.assert_show_fields(items, self.REGION_FIELDS)
if add_clean_up:
self.addCleanup(self.openstack,
'region delete %s' % region_id)
return region_id
def _create_dummy_service(self, add_clean_up=True):
service_name = data_utils.rand_name('TestService')
description = data_utils.rand_name('description')
type_name = data_utils.rand_name('TestType')
raw_output = self.openstack(
'service create '
'--name %(name)s '
'--description %(description)s '
'--enable '
'%(type)s' % {'name': service_name,
'description': description,
'type': type_name})
items = self.parse_show(raw_output)
self.assert_show_fields(items, self.SERVICE_FIELDS)
if add_clean_up:
service = self.parse_show_as_object(raw_output)
self.addCleanup(self.openstack,
'service delete %s' % service['id'])
return service_name
def _create_dummy_endpoint(self, interface='public', add_clean_up=True):
region_id = self._create_dummy_region()
service_name = self._create_dummy_service()
endpoint_url = data_utils.rand_url()
raw_output = self.openstack(
'endpoint create '
'--region %(region)s '
'--enable '
'%(service)s '
'%(interface)s '
'%(url)s' % {'region': region_id,
'service': service_name,
'interface': interface,
'url': endpoint_url})
items = self.parse_show(raw_output)
self.assert_show_fields(items, self.ENDPOINT_FIELDS)
endpoint = self.parse_show_as_object(raw_output)
if add_clean_up:
self.addCleanup(
self.openstack,
'endpoint delete %s' % endpoint['id'])
return endpoint['id']

View File

@ -0,0 +1,63 @@
# 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 functional.tests.identity.v3 import test_identity
class RegionTests(test_identity.IdentityTests):
def test_region_create(self):
self._create_dummy_region()
def test_region_create_with_parent_region(self):
parent_region_id = self._create_dummy_region()
self._create_dummy_region(parent_region=parent_region_id)
def test_region_delete(self):
region_id = self._create_dummy_region(add_clean_up=False)
raw_output = self.openstack('region delete %s' % region_id)
self.assertEqual(0, len(raw_output))
def test_region_list(self):
raw_output = self.openstack('region list')
items = self.parse_listing(raw_output)
self.assert_table_structure(items, self.REGION_LIST_HEADERS)
def test_region_set(self):
# prepare region with parent-region
parent_region_id = self._create_dummy_region()
new_parent_region_id = self._create_dummy_region()
region_id = self._create_dummy_region(parent_region_id)
# check region details
raw_output = self.openstack('region show %s' % region_id)
region = self.parse_show_as_object(raw_output)
self.assertEqual(parent_region_id, region['parent_region'])
self.assertEqual(region_id, region['region'])
# update parent-region
raw_output = self.openstack(
'region set '
'--parent-region %(parent_region)s '
'%(region)s' % {'parent_region': new_parent_region_id,
'region': region_id})
self.assertEqual(0, len(raw_output))
# check updated region details
raw_output = self.openstack('region show %s' % region_id)
region = self.parse_show_as_object(raw_output)
self.assertEqual(new_parent_region_id, region['parent_region'])
self.assertEqual(region_id, region['region'])
def test_region_show(self):
region_id = self._create_dummy_region()
raw_output = self.openstack('region show %s' % region_id)
region = self.parse_show_as_object(raw_output)
self.assertEqual(region_id, region['region'])
self.assertEqual('None', region['parent_region'])

View File

@ -0,0 +1,64 @@
# 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.utils import data_utils
from functional.tests.identity.v3 import test_identity
class ServiceTests(test_identity.IdentityTests):
def test_service_create(self):
self._create_dummy_service()
def test_service_delete(self):
service_name = self._create_dummy_service(add_clean_up=False)
raw_output = self.openstack('service delete %s' % service_name)
self.assertEqual(0, len(raw_output))
def test_service_list(self):
self._create_dummy_service()
raw_output = self.openstack('service list')
items = self.parse_listing(raw_output)
self.assert_table_structure(items, test_identity.BASIC_LIST_HEADERS)
def test_service_set(self):
service_name = self._create_dummy_service()
# set service
new_service_name = data_utils.rand_name('NewTestService')
new_service_description = data_utils.rand_name('description')
new_service_type = data_utils.rand_name('NewTestType')
raw_output = self.openstack(
'service set '
'--type %(type)s '
'--name %(name)s '
'--description %(description)s '
'--disable '
'%(service)s' % {'type': new_service_type,
'name': new_service_name,
'description': new_service_description,
'service': service_name})
self.assertEqual(0, len(raw_output))
# get service details
raw_output = self.openstack('service show %s' % new_service_name)
# assert service details
service = self.parse_show_as_object(raw_output)
self.assertEqual(new_service_type, service['type'])
self.assertEqual(new_service_name, service['name'])
self.assertEqual(new_service_description, service['description'])
def test_service_show(self):
service_name = self._create_dummy_service()
raw_output = self.openstack(
'service show %s' % service_name)
items = self.parse_show(raw_output)
self.assert_show_fields(items, self.SERVICE_FIELDS)