rally-openstack/rally-jobs/plugins/fake_plugin.py
Boris Pavlovic 2437f21f64 Fix rally plugins relative imports
We are not able to use relative imports for plugins that are
outside of rally package.

To fix this we should add to sys.path all directories with Rally
plugins.

This is quite easy fix. But in any case it includes functional test
that checks that this actually works in real life.

+ Fix of Rally gates to copy whole tree not just *.py files from
  rally-jobs/plugins/

Change-Id: Ie53dc2ba5c32a5e83d84d0ea5703e2e04b10ff33
Closes-bug: #1446923
2015-04-22 11:59:40 +03:00

46 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.benchmark.scenarios import base
# This is used to test relative import
from test_relative_import import zzz
class FakePlugin(base.Scenario):
"""Fake plugin with a scenario."""
@base.atomic_action_timer("test1")
def _test1(self, factor):
time.sleep(random.random() * 0.1)
@base.atomic_action_timer("test2")
def _test2(self, factor):
time.sleep(random.random() * factor)
@base.scenario()
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)