rally-openstack/doc/specs/implemented/class-based-scenarios.rst
Alexander Maretskiy f9b55363a4 [Spec] Spec class-based-scenarios.rst is implemented
Change-Id: If50cc5a341029b72ff92eeac41b1fc4559c6974b
2016-07-11 13:28:28 +03: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 splitted 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