rally-openstack/rally-jobs/plugins/fake_plugin.py
Mikhail Dubov c5dae00f94 Cover Rally with docstrings & Test this coverage
Rally should have detailed docstrings for:
* Benchmark scenario classes
* Benchmark scenarios
* Deploy engines
* Server providers
* SLA

Here we add such docstrings and also add a test suite that checks
that Rally is 100% covered with docstrings and that these docstrings
are correctly formed.

We also change the interface of the following benchmark scenarios
(for the sake of unification):
* CinderVolumes.create_and_attach_volume
* CinderVolumes.create_snapshot_and_attach_volume
* CinderVolumes.create_nested_snapshots_and_attach_volume

Finally, we refactor a bit NovaServers.boot_and_bounce_server.

Change-Id: Ia38c8fc2d692a09719d3e068d332647d4b0da47f
2014-12-20 14:13:56 +03:00

42 lines
1.2 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
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
"""
self._test1(factor)
self._test2(factor)