rally-openstack/doc/specs/implemented/class-based-scenarios.rst
Anh Tran 055fd50f72 Typo fix: splitted => split
Change-Id: I1c3f0b9c5196bdd961d5a32e2df2acc4f3c10301
2017-02-06 13:49:27 +07:00

2.6 KiB

Class-based Scenario Implementation

Introduce scenarios implementation as classes, not methods.

Problem description

Current scenario implementation transforms method to class at runtime, so this overcomplicates the code.

Method-based extensions mechanism is not a common practice in frameworks, so this is a bit confusing.

Most Rally plugins like Context, SLA, Runner, OutputChart (except Scenario) are implemented as classes, not methods.

Proposed change

Add an ability to implement scenarios as classes, keeping full backward compatibility with existing code.

This means that class represents single scenario which is actually implemented in method Scenario.run().

So input task can contain scenario names that does not have method part split by dot from class part.

For example, here we have two scenarios, first one is in old manner and another is class-based:

{
  "Dummy.dummy": [
    {
      "runner": {
        "type": "serial",
        "times": 20
      }
    }
  ],
  "another_dummy_scenario": [
    {
      "runner": {
        "type": "serial",
        "times": 20
      }
    }
  ]
}

Class AnotherDummyScenario should have method run():

from rally.task import scenario

@scenario.configure(name="another_dummy_scenario")
class AnotherDummyScenario(scenario.Scenario):

    def run(self):
        """Scenario implementation."""

Modules rally.task.engine and rally.task.processing should be modified to make them working with class-based scenarios.

Alternatives

None

Implementation

Assignee(s)

Primary assignee:

Alexander Maretskiy <amaretskiy@mirantis.com>

Work Items

  • Update task.engine and task.processing for class-based scenarios
  • Transform all Dummy scenarios into class-based implementations as first stage of usage class-based scenarios.

Dependencies

None