6 A nice feature of the input task format used in Yardstick is that it supports
7 the template syntax based on Jinja2.
8 This turns out to be extremely useful when, say, you have a fixed structure of
9 your task but you want to parameterize this task in some way.
10 For example, imagine your input task file (task.yaml) runs a set of Ping
15 # Sample benchmark task config file
16 # measure network latency using ping
17 schema: "yardstick:task:0.1"
39 Let's say you want to run the same set of scenarios with the same runner/
40 context/sla, but you want to try another packetsize to compare the performance.
41 The most elegant solution is then to turn the packetsize name into a template
46 # Sample benchmark task config file
47 # measure network latency using ping
49 schema: "yardstick:task:0.1"
54 packetsize: {{packetsize}}
70 and then pass the argument value for {{packetsize}} when starting a task with
71 this configuration file.
72 Yardstick provides you with different ways to do that:
74 1.Pass the argument values directly in the command-line interface (with either
75 a JSON or YAML dictionary):
79 yardstick task start samples/ping-template.yaml
80 --task-args '{"packetsize":"200"}'
82 2.Refer to a file that specifies the argument values (JSON/YAML):
86 yardstick task start samples/ping-template.yaml --task-args-file args.yaml
88 Using the default values
89 ------------------------
90 Note that the Jinja2 template syntax allows you to set the default values for
92 With default values set, your task file will work even if you don't
93 parameterize it explicitly while starting a task.
94 The default values should be set using the {% set ... %} clause (task.yaml).
99 # Sample benchmark task config file
100 # measure network latency using ping
101 schema: "yardstick:task:0.1"
102 {% set packetsize = packetsize or "100" %}
107 packetsize: {{packetsize}}
117 If you don't pass the value for {{packetsize}} while starting a task, the
118 default one will be used.
123 Yardstick makes it possible to use all the power of Jinja2 template syntax,
124 including the mechanism of built-in functions.
125 As an example, let us make up a task file that will do a block storage
127 The input task file (fio-template.yaml) below uses the Jinja2 for-endfor
128 construct to accomplish that:
132 #Test block sizes of 4KB, 8KB, 64KB, 1MB
133 #Test 5 workloads: read, write, randwrite, randread, rw
134 schema: "yardstick:task:0.1"
137 {% for bs in ['4k', '8k', '64k', '1024k' ] %}
138 {% for rw in ['read', 'write', 'randwrite', 'randread', 'rw' ] %}
142 filename: /home/ubuntu/data.raw