Use os-cloud instead of OS env vars for functional tests
In order to support switching auth contexts, such as for registered_limits which take a system scoped token, switch the functional tests to using the --os-cloud command line parameter. However, honor the OS_CLOUD env var as a way that someone can select a different cloud, including 'envvars', to use. Use devstack-system-admin cloud for limit tests Keystone requires these to have system scope now. Change-Id: Ia81eebd3e00ae986cf3ba7e3d98f3e8a1647b622
This commit is contained in:
parent
2ab3396f19
commit
2dd5393167
@ -24,6 +24,7 @@ COMMON_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
FUNCTIONAL_DIR = os.path.normpath(os.path.join(COMMON_DIR, '..'))
|
||||
ROOT_DIR = os.path.normpath(os.path.join(FUNCTIONAL_DIR, '..'))
|
||||
EXAMPLE_DIR = os.path.join(ROOT_DIR, 'examples')
|
||||
ADMIN_CLOUD = os.environ.get('OS_ADMIN_CLOUD', 'devstack-admin')
|
||||
|
||||
|
||||
def execute(cmd, fail_ok=False, merge_stderr=False):
|
||||
@ -59,9 +60,11 @@ class TestCase(testtools.TestCase):
|
||||
delimiter_line = re.compile('^\+\-[\+\-]+\-\+$')
|
||||
|
||||
@classmethod
|
||||
def openstack(cls, cmd, fail_ok=False):
|
||||
def openstack(cls, cmd, cloud=ADMIN_CLOUD, fail_ok=False):
|
||||
"""Executes openstackclient command for the given action."""
|
||||
return execute('openstack ' + cmd, fail_ok=fail_ok)
|
||||
return execute(
|
||||
'openstack --os-cloud={cloud} '.format(cloud=cloud) +
|
||||
cmd, fail_ok=fail_ok)
|
||||
|
||||
@classmethod
|
||||
def get_openstack_configuration_value(cls, configuration):
|
||||
|
@ -19,6 +19,7 @@ from openstackclient.tests.functional import base
|
||||
|
||||
|
||||
BASIC_LIST_HEADERS = ['ID', 'Name']
|
||||
SYSTEM_CLOUD = os.environ.get('OS_SYSTEM_CLOUD', 'devstack-system-admin')
|
||||
|
||||
|
||||
class IdentityTests(base.TestCase):
|
||||
@ -341,7 +342,8 @@ class IdentityTests(base.TestCase):
|
||||
'registered limit create'
|
||||
' --service %(service_name)s'
|
||||
' --default-limit %(default_limit)s'
|
||||
' %(resource_name)s' % params
|
||||
' %(resource_name)s' % params,
|
||||
cloud=SYSTEM_CLOUD
|
||||
)
|
||||
items = self.parse_show(raw_output)
|
||||
registered_limit_id = self._extract_value_from_items('id', items)
|
||||
@ -349,7 +351,8 @@ class IdentityTests(base.TestCase):
|
||||
if add_clean_up:
|
||||
self.addCleanup(
|
||||
self.openstack,
|
||||
'registered limit delete %s' % registered_limit_id
|
||||
'registered limit delete %s' % registered_limit_id,
|
||||
cloud=SYSTEM_CLOUD
|
||||
)
|
||||
|
||||
self.assert_show_fields(items, self.REGISTERED_LIMIT_FIELDS)
|
||||
@ -365,7 +368,8 @@ class IdentityTests(base.TestCase):
|
||||
registered_limit_id = self._create_dummy_registered_limit()
|
||||
|
||||
raw_output = self.openstack(
|
||||
'registered limit show %s' % registered_limit_id
|
||||
'registered limit show %s' % registered_limit_id,
|
||||
cloud=SYSTEM_CLOUD
|
||||
)
|
||||
items = self.parse_show(raw_output)
|
||||
resource_name = self._extract_value_from_items('resource_name', items)
|
||||
@ -389,13 +393,17 @@ class IdentityTests(base.TestCase):
|
||||
' --project %(project_id)s'
|
||||
' --service %(service_id)s'
|
||||
' --resource-limit %(resource_limit)s'
|
||||
' %(resource_name)s' % params
|
||||
' %(resource_name)s' % params,
|
||||
cloud=SYSTEM_CLOUD
|
||||
)
|
||||
items = self.parse_show(raw_output)
|
||||
limit_id = self._extract_value_from_items('id', items)
|
||||
|
||||
if add_clean_up:
|
||||
self.addCleanup(self.openstack, 'limit delete %s' % limit_id)
|
||||
self.addCleanup(
|
||||
self.openstack, 'limit delete %s' % limit_id,
|
||||
cloud=SYSTEM_CLOUD
|
||||
)
|
||||
|
||||
self.assert_show_fields(items, self.LIMIT_FIELDS)
|
||||
return limit_id
|
||||
|
@ -10,17 +10,22 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
|
||||
from tempest.lib.common.utils import data_utils
|
||||
|
||||
from openstackclient.tests.functional.identity.v3 import common
|
||||
|
||||
SYSTEM_CLOUD = os.environ.get('OS_SYSTEM_CLOUD', 'devstack-system-admin')
|
||||
|
||||
|
||||
class LimitTestCase(common.IdentityTests):
|
||||
|
||||
def test_limit_create_with_service_name(self):
|
||||
registered_limit_id = self._create_dummy_registered_limit()
|
||||
raw_output = self.openstack(
|
||||
'registered limit show %s' % registered_limit_id
|
||||
'registered limit show %s' % registered_limit_id,
|
||||
cloud=SYSTEM_CLOUD
|
||||
)
|
||||
items = self.parse_show(raw_output)
|
||||
service_id = self._extract_value_from_items('service_id', items)
|
||||
@ -46,18 +51,24 @@ class LimitTestCase(common.IdentityTests):
|
||||
' --project %(project_id)s'
|
||||
' --service %(service_name)s'
|
||||
' --resource-limit %(resource_limit)s'
|
||||
' %(resource_name)s' % params
|
||||
' %(resource_name)s' % params,
|
||||
cloud=SYSTEM_CLOUD
|
||||
)
|
||||
items = self.parse_show(raw_output)
|
||||
limit_id = self._extract_value_from_items('id', items)
|
||||
self.addCleanup(self.openstack, 'limit delete %s' % limit_id)
|
||||
self.addCleanup(
|
||||
self.openstack,
|
||||
'limit delete %s' % limit_id,
|
||||
cloud=SYSTEM_CLOUD
|
||||
)
|
||||
|
||||
self.assert_show_fields(items, self.LIMIT_FIELDS)
|
||||
|
||||
def test_limit_create_with_project_name(self):
|
||||
registered_limit_id = self._create_dummy_registered_limit()
|
||||
raw_output = self.openstack(
|
||||
'registered limit show %s' % registered_limit_id
|
||||
'registered limit show %s' % registered_limit_id,
|
||||
cloud=SYSTEM_CLOUD
|
||||
)
|
||||
items = self.parse_show(raw_output)
|
||||
service_id = self._extract_value_from_items('service_id', items)
|
||||
@ -80,11 +91,16 @@ class LimitTestCase(common.IdentityTests):
|
||||
' --project %(project_name)s'
|
||||
' --service %(service_name)s'
|
||||
' --resource-limit %(resource_limit)s'
|
||||
' %(resource_name)s' % params
|
||||
' %(resource_name)s' % params,
|
||||
cloud=SYSTEM_CLOUD
|
||||
)
|
||||
items = self.parse_show(raw_output)
|
||||
limit_id = self._extract_value_from_items('id', items)
|
||||
self.addCleanup(self.openstack, 'limit delete %s' % limit_id)
|
||||
self.addCleanup(
|
||||
self.openstack,
|
||||
'limit delete %s' % limit_id,
|
||||
cloud=SYSTEM_CLOUD
|
||||
)
|
||||
|
||||
self.assert_show_fields(items, self.LIMIT_FIELDS)
|
||||
registered_limit_id = self._create_dummy_registered_limit()
|
||||
@ -107,7 +123,8 @@ class LimitTestCase(common.IdentityTests):
|
||||
raw_output = self.openstack(
|
||||
'registered limit set'
|
||||
' %(registered_limit_id)s'
|
||||
' --region %(region_id)s' % params
|
||||
' --region %(region_id)s' % params,
|
||||
cloud=SYSTEM_CLOUD
|
||||
)
|
||||
items = self.parse_show(raw_output)
|
||||
service_id = self._extract_value_from_items('service_id', items)
|
||||
@ -134,17 +151,25 @@ class LimitTestCase(common.IdentityTests):
|
||||
' --resource-limit %(resource_limit)s'
|
||||
' --region %(region_id)s'
|
||||
' --description %(description)s'
|
||||
' %(resource_name)s' % params
|
||||
' %(resource_name)s' % params,
|
||||
cloud=SYSTEM_CLOUD
|
||||
)
|
||||
items = self.parse_show(raw_output)
|
||||
limit_id = self._extract_value_from_items('id', items)
|
||||
self.addCleanup(self.openstack, 'limit delete %s' % limit_id)
|
||||
self.addCleanup(
|
||||
self.openstack,
|
||||
'limit delete %s' % limit_id,
|
||||
cloud=SYSTEM_CLOUD
|
||||
)
|
||||
|
||||
self.assert_show_fields(items, self.LIMIT_FIELDS)
|
||||
|
||||
def test_limit_show(self):
|
||||
limit_id = self._create_dummy_limit()
|
||||
raw_output = self.openstack('limit show %s' % limit_id)
|
||||
raw_output = self.openstack(
|
||||
'limit show %s' % limit_id,
|
||||
cloud=SYSTEM_CLOUD
|
||||
)
|
||||
items = self.parse_show(raw_output)
|
||||
self.assert_show_fields(items, self.LIMIT_FIELDS)
|
||||
|
||||
@ -159,7 +184,8 @@ class LimitTestCase(common.IdentityTests):
|
||||
raw_output = self.openstack(
|
||||
'limit set'
|
||||
' --description %(description)s'
|
||||
' %(limit_id)s' % params
|
||||
' %(limit_id)s' % params,
|
||||
cloud=SYSTEM_CLOUD
|
||||
)
|
||||
items = self.parse_show(raw_output)
|
||||
self.assert_show_fields(items, self.LIMIT_FIELDS)
|
||||
@ -175,18 +201,21 @@ class LimitTestCase(common.IdentityTests):
|
||||
raw_output = self.openstack(
|
||||
'limit set'
|
||||
' --resource-limit %(resource_limit)s'
|
||||
' %(limit_id)s' % params
|
||||
' %(limit_id)s' % params,
|
||||
cloud=SYSTEM_CLOUD
|
||||
)
|
||||
items = self.parse_show(raw_output)
|
||||
self.assert_show_fields(items, self.LIMIT_FIELDS)
|
||||
|
||||
def test_limit_list(self):
|
||||
self._create_dummy_limit()
|
||||
raw_output = self.openstack('limit list')
|
||||
raw_output = self.openstack('limit list', cloud=SYSTEM_CLOUD)
|
||||
items = self.parse_listing(raw_output)
|
||||
self.assert_table_structure(items, self.LIMIT_LIST_HEADERS)
|
||||
|
||||
def test_limit_delete(self):
|
||||
limit_id = self._create_dummy_limit(add_clean_up=False)
|
||||
raw_output = self.openstack('limit delete %s' % limit_id)
|
||||
raw_output = self.openstack(
|
||||
'limit delete %s' % limit_id,
|
||||
cloud=SYSTEM_CLOUD)
|
||||
self.assertEqual(0, len(raw_output))
|
||||
|
@ -10,10 +10,14 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
|
||||
from tempest.lib.common.utils import data_utils
|
||||
|
||||
from openstackclient.tests.functional.identity.v3 import common
|
||||
|
||||
SYSTEM_CLOUD = os.environ.get('OS_SYSTEM_CLOUD', 'devstack-system-admin')
|
||||
|
||||
|
||||
class RegisteredLimitTestCase(common.IdentityTests):
|
||||
|
||||
@ -37,7 +41,8 @@ class RegisteredLimitTestCase(common.IdentityTests):
|
||||
'service_id': service_id,
|
||||
'default_limit': 10,
|
||||
'resource_name': 'cores'
|
||||
}
|
||||
},
|
||||
cloud=SYSTEM_CLOUD
|
||||
)
|
||||
items = self.parse_show(raw_output)
|
||||
registered_limit_id = self._extract_value_from_items('id', items)
|
||||
@ -46,7 +51,8 @@ class RegisteredLimitTestCase(common.IdentityTests):
|
||||
'registered limit delete'
|
||||
' %(registered_limit_id)s' % {
|
||||
'registered_limit_id': registered_limit_id
|
||||
}
|
||||
},
|
||||
cloud=SYSTEM_CLOUD
|
||||
)
|
||||
|
||||
self.assert_show_fields(items, self.REGISTERED_LIMIT_FIELDS)
|
||||
@ -68,7 +74,8 @@ class RegisteredLimitTestCase(common.IdentityTests):
|
||||
' --region %(region_id)s'
|
||||
' --service %(service_name)s'
|
||||
' --default-limit %(default_limit)s'
|
||||
' %(resource_name)s' % params
|
||||
' %(resource_name)s' % params,
|
||||
cloud=SYSTEM_CLOUD
|
||||
)
|
||||
items = self.parse_show(raw_output)
|
||||
registered_limit_id = self._extract_value_from_items('id', items)
|
||||
@ -76,7 +83,8 @@ class RegisteredLimitTestCase(common.IdentityTests):
|
||||
self.openstack,
|
||||
'registered limit delete %(registered_limit_id)s' % {
|
||||
'registered_limit_id': registered_limit_id
|
||||
}
|
||||
},
|
||||
cloud=SYSTEM_CLOUD
|
||||
)
|
||||
|
||||
self.assert_show_fields(items, self.REGISTERED_LIMIT_FIELDS)
|
||||
@ -102,7 +110,8 @@ class RegisteredLimitTestCase(common.IdentityTests):
|
||||
raw_output = self.openstack(
|
||||
'registered limit set'
|
||||
' %(registered_limit_id)s'
|
||||
' --region %(region_id)s' % params
|
||||
' --region %(region_id)s' % params,
|
||||
cloud=SYSTEM_CLOUD
|
||||
)
|
||||
items = self.parse_show(raw_output)
|
||||
self.assert_show_fields(items, self.REGISTERED_LIMIT_FIELDS)
|
||||
@ -116,7 +125,8 @@ class RegisteredLimitTestCase(common.IdentityTests):
|
||||
raw_output = self.openstack(
|
||||
'registered limit set'
|
||||
' %(registered_limit_id)s'
|
||||
' --description \'%(description)s\'' % params
|
||||
' --description \'%(description)s\'' % params,
|
||||
cloud=SYSTEM_CLOUD
|
||||
)
|
||||
items = self.parse_show(raw_output)
|
||||
self.assert_show_fields(items, self.REGISTERED_LIMIT_FIELDS)
|
||||
@ -131,7 +141,8 @@ class RegisteredLimitTestCase(common.IdentityTests):
|
||||
raw_output = self.openstack(
|
||||
'registered limit set'
|
||||
' %(registered_limit_id)s'
|
||||
' --service %(service)s' % params
|
||||
' --service %(service)s' % params,
|
||||
cloud=SYSTEM_CLOUD
|
||||
)
|
||||
items = self.parse_show(raw_output)
|
||||
self.assert_show_fields(items, self.REGISTERED_LIMIT_FIELDS)
|
||||
@ -145,7 +156,8 @@ class RegisteredLimitTestCase(common.IdentityTests):
|
||||
raw_output = self.openstack(
|
||||
'registered limit set'
|
||||
' %(registered_limit_id)s'
|
||||
' --default-limit %(default_limit)s' % params
|
||||
' --default-limit %(default_limit)s' % params,
|
||||
cloud=SYSTEM_CLOUD
|
||||
)
|
||||
items = self.parse_show(raw_output)
|
||||
self.assert_show_fields(items, self.REGISTERED_LIMIT_FIELDS)
|
||||
@ -160,7 +172,8 @@ class RegisteredLimitTestCase(common.IdentityTests):
|
||||
raw_output = self.openstack(
|
||||
'registered limit set'
|
||||
' %(registered_limit_id)s'
|
||||
' --resource-name %(resource_name)s' % params
|
||||
' --resource-name %(resource_name)s' % params,
|
||||
cloud=SYSTEM_CLOUD
|
||||
)
|
||||
items = self.parse_show(raw_output)
|
||||
self.assert_show_fields(items, self.REGISTERED_LIMIT_FIELDS)
|
||||
@ -179,6 +192,7 @@ class RegisteredLimitTestCase(common.IdentityTests):
|
||||
'registered limit delete'
|
||||
' %(registered_limit_id)s' % {
|
||||
'registered_limit_id': registered_limit_id
|
||||
}
|
||||
},
|
||||
cloud=SYSTEM_CLOUD
|
||||
)
|
||||
self.assertEqual(0, len(raw_output))
|
||||
|
@ -1,16 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This is a script that runs ostestr with the openrc OS_ variables sourced.
|
||||
# Do not run this script unless you know what you're doing.
|
||||
# For more information refer to:
|
||||
# https://docs.openstack.org/python-openstackclient/latest/
|
||||
|
||||
# Source environment variables to kick things off
|
||||
if [ -f ~stack/devstack/openrc ] ; then
|
||||
source ~stack/devstack/openrc admin admin
|
||||
fi
|
||||
|
||||
echo 'Running tests with:'
|
||||
env | grep OS
|
||||
|
||||
stestr run $*
|
6
tox.ini
6
tox.ini
@ -70,14 +70,12 @@ whitelist_externals = stestr
|
||||
[testenv:functional]
|
||||
setenv = OS_TEST_PATH=./openstackclient/tests/functional
|
||||
passenv = OS_*
|
||||
whitelist_externals = openstackclient/tests/functional/run_stestr.sh
|
||||
commands =
|
||||
{toxinidir}/openstackclient/tests/functional/run_stestr.sh {posargs}
|
||||
stestr run {posargs}
|
||||
|
||||
[testenv:functional-tips]
|
||||
setenv = OS_TEST_PATH=./openstackclient/tests/functional
|
||||
passenv = OS_*
|
||||
whitelist_externals = openstackclient/tests/functional/run_stestr.sh
|
||||
commands =
|
||||
pip install -q -U -e "git+file://{toxinidir}/../cliff#egg=cliff"
|
||||
pip install -q -U -e "git+file://{toxinidir}/../keystoneauth#egg=keystoneauth"
|
||||
@ -85,7 +83,7 @@ commands =
|
||||
pip install -q -U -e "git+file://{toxinidir}/../os-client-config#egg=os_client_config"
|
||||
pip install -q -U -e "git+file://{toxinidir}/../openstacksdk#egg=openstacksdk"
|
||||
pip freeze
|
||||
{toxinidir}/openstackclient/tests/functional/run_stestr.sh {posargs}
|
||||
stestr run {posargs}
|
||||
|
||||
[testenv:venv]
|
||||
basepython = python3
|
||||
|
Loading…
x
Reference in New Issue
Block a user