Skip to content

Commit 585b69f

Browse files
committed
Added variables documentation
1 parent d5399b3 commit 585b69f

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

content/en/docs/measuring/runner-switches.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Apart from the `config.yml` some additional configuration is possible when manua
1414
- `--branch` When providing a git repository, optionally specify a branch
1515
- `--name` A name which will be stored to the database to discern this run from others
1616
- `--filename` An optional alternative filename if you do not want to use "usage_scenario.yml"
17+
- `--variables` A list of string key-value pairs with variables to be replaced in the [usage_scenario.yml →]({{< relref "usage-scenario" >}})
18+
+ e.g.: `--variables '__GMT_VAR_MY_VALUE_=cats are cool'`
1719
- `--config-override` Override the configuration file with the passed in yml file.
1820
+ Must be located in the same directory as the regular configuration file. Pass in only the name.
1921
- `--no-file-cleanup` flag to not delete the metric provider data in `/tmp/green-metrics-tool`

content/en/docs/measuring/usage-scenario.md

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ The `usage_scenario.yml` consists of these main blocks:
1515
- `compose-file` - (optional) A compose file to include
1616

1717
Its format is an extended subset of the [Docker Compose Specification](https://docs.docker.com/compose/compose-file/), which means that we keep the same format, but disallow some options and also add some exclusive options to our tool. However, keys that have the same name are also identical in function - thought potentially with some limitations.
18+
See also the note on [unsupported features](#unsupported-docker-compose-features) to disable the warning about that.
19+
20+
Inside the `usage_scenario.yml` you can use variables. See [variables](#variables) for details.
21+
1822

19-
See also the note on [unsupported features](#unsupported-docker-compose-features)
2023

2124
### Basic root level keys
2225

@@ -291,3 +294,43 @@ All features not listed here are not supported by the Green Metrics Tool.
291294
Since we allow the import of [Docker Compose](https://docs.docker.com/compose/compose-file) files this can lead to importing unsupported features.
292295

293296
GMT will error in this case. If you do not want that add the `ignore-unsupported-compose` key after you have tested your *usage_scenario.yml* file.
297+
298+
299+
## Variables
300+
301+
A variable must adhere to the format `__GMT_VAR_[\w]+__`. An example would be `__GMT_VAR_NUMBER__`.
302+
303+
The value of the variable is a string. It will be replaced as is without adding " or ' though.
304+
305+
Example in a `usage_scenario.yml`:
306+
```yml
307+
---
308+
name: Test Stress
309+
author: Dan Mateas
310+
description: test
311+
312+
services:
313+
test-container:
314+
type: container
315+
image: gcb_stress
316+
build:
317+
context: ../stress-application
318+
319+
flow:
320+
- name: Stress
321+
container: test-container
322+
commands:
323+
- type: console
324+
command: stress-ng -c 1 -t __GMT_VAR_DURATION__ -q
325+
note: Starting Stress
326+
```
327+
328+
Here we can leverage the variable functionality to supply different durations without creating new usage scenarios all the time.
329+
330+
A run where we want the variable to be *1* as example can be started like this:
331+
```bash
332+
$ python3 runner.py --uri PATH_TO_SCENARIO --variables "__GMT_VAR_DURATION__=1"
333+
```
334+
See more details in [Runner switches →]({{< relref "/docs/measuring/runner-switches/" >}})
335+
336+
The API accepts these variables as arguments also to the `/v1/software/add` endpoint. See the [API documentation →]({{< relref "/docs/api/overview" >}}) for details.

0 commit comments

Comments
 (0)