Use cases and examples
Overriding Scenario settings and Environment for an automated test
In this use case, the user will use a YAML file describing the Scenario to use instead of the existing one in a NeoLoad project.
The YAML file to use for the scenario settings to apply is:
scenarios:
- name: MyScenario
populations:
- name: MyPopulation
constant_load:
users: 500
duration: 15m
When having the same name, the scenario included in the YAML file replaces the scenario existing in the NeoLoad project. Also, if the scenario available in the YAML file does not exist in the NeoLoad project, it is then added in the project. In this example, we consider that a "Myscenario" scenario already exists in the NeoLoad project, is then replaced by the scenario of the same name specified in the YAML file.
The same mechanism can be used to override Server host names and Test data:
servers:
- name: myapp
host: myapp-staging.company.com
scheme: https
port: 443
variables:
- file:
name: cities_file
path: staging/data/list_of_cities.csv
is_first_line_column_names: true
change_policy: each_iteration
scope: global
The user can then run the following command line:
NeoLoadCmd.exe -project "<neoload projects path>/MyProject/MyProject.nlp" "<neoload projects path>/myproject-scenarios.yaml" "<neoload projects path>/myproject-environment.yaml"-launch MyScenario
Or create a Zip archive with the content of the <neoload projects path> folder, upload it and run it from NeoLoad Web.
Structuring YAML files per environment
Here is an example of using only YAML files, for two different execution environments:
common/design.yaml
staging/servers.yaml
staging/variables.yaml
staging/slas.yaml
preprod/servers.yaml
preprod/variables.yaml
preprod/slas.yaml
You should add top-level files that include the required files for each environment:
staging.yaml:
includes:
- common/design.yaml
- staging/servers.yaml
- staging/variables.yaml
- staging/slas.yaml
preprod.yaml:
includes:
- common/design.yaml
- preprod/servers.yaml
- preprod/variables.yaml
- preprod/slas.yaml
And a default file for example:
default.yaml:
includes:
- staging.yaml
Caution: The separator for the paths can only be "/" in the "includes" section of the YAML files.
Then, zip the whole content and:
-
Choose which YAML file to execute from the command line or the NeoLoad Web API. For example, "-project staging.yaml" or "as-code: staging.yaml".
-
Edit the default file to make sure it includes the appropriate file and execute through NeoLoad Web interface, through NeoLoad Web API without-specifying the ‘as-code’ argument- or through the command line by specifying only the folder in which the YAML files are stored.