e2d52daf12
* Moved rally.task.scenarios.base -> rally.task.scenario - Shorter imports and simpler structure of tree - Unified with other plugin bases * Add rally.task.atomic module - We will use atomic actions in both scenarios and context this is first step of unification - Module has only links to method and atomic action context with new names. So we will change all plugins but won't touch atomic actions at this patch (to reduce amount of LOC in this patch) - Next step is to move and unify atomic action code for scenarios and contexts * Rename rally.task.scenario.scenario to rally.task.scenario.configure scenario.scenario is unclear and not aligned with other plugin types where configure() method is used for the same purpose * Add shortcut rally.plugins.openstack.scenario.configure so there is no need to import rally.plugins.openstack.scenario and rally.task.scenario modules * Fix all unit tests & docs Change-Id: I388bd1c1af951670c6a1d043cfeb2a6753a085b0
47 lines
1.3 KiB
Python
47 lines
1.3 KiB
Python
# Copyright 2014: Mirantis Inc.
|
|
# All Rights Reserved.
|
|
#
|
|
# 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.
|
|
|
|
|
|
import random
|
|
import time
|
|
|
|
from rally.task import atomic
|
|
from rally.task import scenario
|
|
|
|
# This is used to test relative import
|
|
from test_relative_import import zzz
|
|
|
|
|
|
class FakePlugin(scenario.Scenario):
|
|
"""Fake plugin with a scenario."""
|
|
|
|
@atomic.action_timer("test1")
|
|
def _test1(self, factor):
|
|
time.sleep(random.random() * 0.1)
|
|
|
|
@atomic.action_timer("test2")
|
|
def _test2(self, factor):
|
|
time.sleep(random.random() * factor)
|
|
|
|
@scenario.configure()
|
|
def testplugin(self, factor=1):
|
|
"""Fake scenario.
|
|
|
|
:param factor: influences the argument value for a time.sleep() call
|
|
"""
|
|
zzz.some_very_important_function()
|
|
self._test1(factor)
|
|
self._test2(factor)
|