Add load_test mechanism for InputScenarioUtils
Similar to what was done for the negative test framework this commit adds a method to handle using CONF values with testscenarios. Previously the attr's were set in the test class definition which would force a getattr at import time. This will cause issues if the config file is not present. By adding a method which won't be executed at import but rather when the tests are run we can avoid this. Change-Id: Ib635f8b895f6642f78a3af644170700f72259d46
This commit is contained in:
parent
d75edef97f
commit
a0048cb626
@ -20,13 +20,11 @@ from tempest.scenario import manager
|
|||||||
from tempest.scenario import utils as test_utils
|
from tempest.scenario import utils as test_utils
|
||||||
from tempest import test
|
from tempest import test
|
||||||
|
|
||||||
import testscenarios
|
|
||||||
|
|
||||||
CONF = config.CONF
|
CONF = config.CONF
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
load_tests = testscenarios.load_tests_apply_scenarios
|
load_tests = test_utils.load_tests_input_scenario_utils
|
||||||
|
|
||||||
|
|
||||||
class TestServerBasicOps(manager.OfficialClientTest):
|
class TestServerBasicOps(manager.OfficialClientTest):
|
||||||
@ -43,13 +41,6 @@ class TestServerBasicOps(manager.OfficialClientTest):
|
|||||||
* Terminate the instance
|
* Terminate the instance
|
||||||
"""
|
"""
|
||||||
|
|
||||||
scenario_utils = test_utils.InputScenarioUtils()
|
|
||||||
scenario_flavor = scenario_utils.scenario_flavors
|
|
||||||
scenario_image = scenario_utils.scenario_images
|
|
||||||
|
|
||||||
scenarios = testscenarios.multiply_scenarios(scenario_image,
|
|
||||||
scenario_flavor)
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestServerBasicOps, self).setUp()
|
super(TestServerBasicOps, self).setUp()
|
||||||
# Setup image and flavor the test instance
|
# Setup image and flavor the test instance
|
||||||
|
@ -12,6 +12,9 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import testscenarios
|
||||||
|
import testtools
|
||||||
|
|
||||||
from tempest import clients
|
from tempest import clients
|
||||||
from tempest.common.utils import misc
|
from tempest.common.utils import misc
|
||||||
from tempest import config
|
from tempest import config
|
||||||
@ -134,3 +137,22 @@ class InputScenarioUtils(object):
|
|||||||
for f in flavors if re.search(self.flavor_pattern, str(f.name))
|
for f in flavors if re.search(self.flavor_pattern, str(f.name))
|
||||||
]
|
]
|
||||||
return self._scenario_flavors
|
return self._scenario_flavors
|
||||||
|
|
||||||
|
|
||||||
|
def load_tests_input_scenario_utils(*args):
|
||||||
|
"""
|
||||||
|
Wrapper for testscenarios to set the scenarios to avoid running a getattr
|
||||||
|
on the CONF object at import.
|
||||||
|
"""
|
||||||
|
if getattr(args[0], 'suiteClass', None) is not None:
|
||||||
|
loader, standard_tests, pattern = args
|
||||||
|
else:
|
||||||
|
standard_tests, module, loader = args
|
||||||
|
scenario_utils = InputScenarioUtils()
|
||||||
|
scenario_flavor = scenario_utils.scenario_flavors
|
||||||
|
scenario_image = scenario_utils.scenario_images
|
||||||
|
for test in testtools.iterate_tests(standard_tests):
|
||||||
|
setattr(test, 'scenarios', testscenarios.multiply_scenarios(
|
||||||
|
scenario_image,
|
||||||
|
scenario_flavor))
|
||||||
|
return testscenarios.load_tests_apply_scenarios(*args)
|
||||||
|
Loading…
Reference in New Issue
Block a user