Merge "Add load_test mechanism for InputScenarioUtils"

This commit is contained in:
Jenkins 2014-04-15 19:40:19 +00:00 committed by Gerrit Code Review
commit 498b1de92b
2 changed files with 23 additions and 10 deletions

View File

@ -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

View File

@ -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)