I'm attempting to write a YAML config script for a load testing utility called Artillery.
The YAML syntax is not making any sense to me though. Artillery appears to deserialize the YAML to a Javascript object syntax so it expects nodes in the YAML file to have a certain structure.
config:
target: https://mhhs-prod-webapp.azurewebsites.net/
phases:
- duration: 60
arrivalRate: 50
scenarios:
- flow:
- get:
url: '/'
Given the above file though it fails complaining that 'get' must be of type object
. In the file above the get
node has a child node url
of key value type, so I'm expecting it to be of type object
.
After much trial and error I've managed to get it to work using the following layout.
config:
target: https://mhhs-prod-webapp.azurewebsites.net/
phases:
- duration: 60
arrivalRate: 50
scenarios:
- flow:
- get:
url: '/'
But the bizarre thing is that this file is identical to the previous one apart from the fact that the url
node is indented 4 spaces instead of the 2 spaces of indentation used throughout the rest of the file.
Is this correct? I'm having trouble finding an explanation of YAML that is understandable but so far I haven't come across anything that suggests that different amounts of indentation do completely different things.
Hohoho, I understand how you feel about YAML indentations.
It's like Python-based indentation but with a mix of JSON.
In your code:
config:
...
scenarios:
- flow:
- get:
url: '/'
"url" looks like a child of "flow" since it has an indent like so.
It can go in a couple of routes.
Route #1: (Where "url" is under "flow:")
...
scenarios:
- flow:
- get:
- url: '/'
Route #2: (Where "url" is under "get:")
...
scenarios:
- flow:
- get:
- url: '/'
Route #3: (Where "url" is under~ uhm...)
config:
...
scenarios:
...
url: '/'