diff --git a/performa/engine/main.py b/performa/engine/main.py index 4cc3e9b..77dcc10 100644 --- a/performa/engine/main.py +++ b/performa/engine/main.py @@ -15,6 +15,7 @@ import os +import jinja2 from oslo_config import cfg from oslo_log import log as logging import yaml @@ -30,11 +31,13 @@ from performa.engine import utils LOG = logging.getLogger(__name__) -def resolve_hosts(scenario, hosts): - for k, v in hosts.items(): - scenario = scenario.replace('$%s' % k, ','.join(v) + ',') +def resolve_hosts(scenario_template, hosts): + jinja_env = jinja2.Environment() - return scenario + compiled_template = jinja_env.from_string(scenario_template) + rendered_template = compiled_template.render(hosts) + + return rendered_template def main(): diff --git a/performa/scenarios/db/sysbench.yaml b/performa/scenarios/db/sysbench.yaml index b41bb78..295198d 100644 --- a/performa/scenarios/db/sysbench.yaml +++ b/performa/scenarios/db/sysbench.yaml @@ -3,9 +3,12 @@ title: Sysbench DB description: This scenario uses sysbench to execute DB test plan. +parameters: + target: List of hosts were omsimulator will be executed + setup: - - hosts: $target + hosts: {{ target }} tasks: - name: installing sysbench apt: name=sysbench @@ -15,20 +18,20 @@ setup: name: atop, daemon become: yes - - hosts: $target + hosts: {{ target }} tasks: - atop: command=start execution: - - hosts: $target + hosts: {{ target }} matrix: threads: [ 10, 20, 30, 40, 50, 60 ] tasks: - sysbench_oltp: duration: 10 - - hosts: $target + hosts: {{ target }} tasks: - atop: command: stop diff --git a/performa/scenarios/mq/omsimulator.yaml b/performa/scenarios/mq/omsimulator.yaml index 3da2757..568ae14 100644 --- a/performa/scenarios/mq/omsimulator.yaml +++ b/performa/scenarios/mq/omsimulator.yaml @@ -3,9 +3,12 @@ title: OMSimulator description: This scenario uses oslo.messaging simulator tool to execute MQ test plan. +parameters: + target: List of hosts were omsimulator will be executed + setup: - - hosts: $target + hosts: {{ target }} tasks: - apt: name=git become: yes @@ -25,11 +28,11 @@ setup: execution: - - hosts: $target + hosts: {{ target }} tasks: - atop: command=start - - hosts: $target + hosts: {{ target }} matrix: threads: [ 1, 2, 5, 10, 25, 50, 100 ] tasks: @@ -38,7 +41,7 @@ execution: duration: 10 url: "rabbit://stackrabbit:swordfish@localhost:5672/" - - hosts: $target + hosts: {{ target }} tasks: - atop: command: stop