diff --git a/include-acceptance-regular-user.txt b/include-acceptance-regular-user.txt new file mode 100644 index 000000000..44563523a --- /dev/null +++ b/include-acceptance-regular-user.txt @@ -0,0 +1,7 @@ +# This file contains list of tests that can work with regular user privileges +# Until all tests are modified to properly identify whether they are able to +# run or must skip the ones that are known to work are listed here. +openstack.tests.functional.block_storage.v3.test_volume +# Do not enable test_backup for now, since it is not capable to determine +# backup capabilities of the cloud +# openstack.tests.functional.block_storage.v3.test_backup diff --git a/openstack/tests/functional/base.py b/openstack/tests/functional/base.py index 1e20f3ee4..7e965eb71 100644 --- a/openstack/tests/functional/base.py +++ b/openstack/tests/functional/base.py @@ -12,6 +12,8 @@ import operator import os +import time +import uuid from keystoneauth1 import discover @@ -57,10 +59,11 @@ class BaseFunctionalTest(base.TestCase): self.config = openstack.config.OpenStackConfig() self._set_user_cloud() - self._set_operator_cloud() + if self._op_name: + self._set_operator_cloud() self.identity_version = \ - self.operator_cloud.config.get_api_version('identity') + self.user_cloud.config.get_api_version('identity') self.flavor = self._pick_flavor() self.image = self._pick_image() @@ -78,10 +81,11 @@ class BaseFunctionalTest(base.TestCase): # This cloud is used by the project_cleanup test, so you can't rely on # it - user_config_alt = self.config.get_one( - cloud=self._demo_name_alt, **kwargs) - self.user_cloud_alt = connection.Connection(config=user_config_alt) - _disable_keep_alive(self.user_cloud_alt) + if self._demo_name_alt: + user_config_alt = self.config.get_one( + cloud=self._demo_name_alt, **kwargs) + self.user_cloud_alt = connection.Connection(config=user_config_alt) + _disable_keep_alive(self.user_cloud_alt) def _set_operator_cloud(self, **kwargs): operator_config = self.config.get_one(cloud=self._op_name, **kwargs) @@ -216,6 +220,15 @@ class BaseFunctionalTest(base.TestCase): f'{min_microversion}' ) + def getUniqueString(self, prefix=None): + """Generate unique resource name""" + # Globally unique names can only rely on some form of uuid + # unix_t is also used to easier determine orphans when running real + # functional tests on a real cloud + return (prefix if prefix else '') + "{time}-{uuid}".format( + time=int(time.time()), + uuid=uuid.uuid4().hex) + class KeystoneBaseFunctionalTest(BaseFunctionalTest): diff --git a/openstack/tests/functional/block_storage/v3/base.py b/openstack/tests/functional/block_storage/v3/base.py index 7bb01ce73..d9e60e818 100644 --- a/openstack/tests/functional/block_storage/v3/base.py +++ b/openstack/tests/functional/block_storage/v3/base.py @@ -20,7 +20,5 @@ class BaseBlockStorageTest(base.BaseFunctionalTest): def setUp(self): super(BaseBlockStorageTest, self).setUp() self._set_user_cloud(block_storage_api_version='3') - self._set_operator_cloud(block_storage_api_version='3') - if not self.user_cloud.has_service('block-storage', '3'): self.skipTest('block-storage service not supported by cloud') diff --git a/openstack/tests/functional/block_storage/v3/test_type.py b/openstack/tests/functional/block_storage/v3/test_type.py index c86e15930..db7ae74f0 100644 --- a/openstack/tests/functional/block_storage/v3/test_type.py +++ b/openstack/tests/functional/block_storage/v3/test_type.py @@ -22,7 +22,9 @@ class TestType(base.BaseBlockStorageTest): self.TYPE_NAME = self.getUniqueString() self.TYPE_ID = None - + if not self._op_name: + self.skip("Operator cloud must be set for this test") + self._set_operator_cloud(block_storage_api_version='3') sot = self.operator_cloud.block_storage.create_type( name=self.TYPE_NAME) assert isinstance(sot, _type.Type) diff --git a/tox.ini b/tox.ini index ed565d2b4..a9de9c143 100644 --- a/tox.ini +++ b/tox.ini @@ -38,6 +38,23 @@ commands = stestr --test-path ./openstack/tests/functional/{env:OPENSTACKSDK_TESTS_SUBDIR:} run --serial {posargs} stestr slowest +# Acceptance tests are the ones running on real clouds +[testenv:acceptance-regular-user] +# This env intends to test functions of a regular user without admin privileges +# Some jobs (especially heat) takes longer, therefore increase default timeout +# This timeout should not be smaller, than the longest individual timeout +setenv = + {[testenv]setenv} + OS_TEST_TIMEOUT=600 + OPENSTACKSDK_FUNC_TEST_TIMEOUT_LOAD_BALANCER=600 + # OPENSTACKSDK_DEMO_CLOUD and OS_CLOUD should point to the cloud to test + # Othee clouds are explicitly set empty to let tests detect absense + OPENSTACKSDK_DEMO_CLOUD_ALT= + OPENSTACKSDK_OPERATOR_CLOUD= +commands = + stestr --test-path ./openstack/tests/functional/{env:OPENSTACKSDK_TESTS_SUBDIR:} run --serial {posargs} --include-list include-acceptance-regular-user.txt + stestr slowest + [testenv:pep8] deps = hacking>=3.1.0,<4.0.0 # Apache-2.0