Debian Codegraph @

ansible_collections/hetzner/hcloud/tests/integration/README.md

raw
1 # Integration tests
2
3 This document provides information to work with the integration tests.
4
5 ## Guidelines
6
7 A set of guidelines to follow when writing integrations tests.
8
9 ### Prepare and cleanup
10
11 The integration tests use a small testing framework that helps to set up and teardown any resources needed or generated by the tests. This small testing framework is located in the `tests/integration/common` directory. The files within the `common` directory are then duplicated and kept in sync in all the integration tests targets (`tests/integration/targets/hcloud_*`).
12
13 - Use a `tasks/prepare.yml` file to set up resources needed during the tests.
14 - Use a `tasks/cleanup.yml` file to teardown resources from the `tasts/prepare.yml` tasks **and** the resources generated by the tests.
15 - Use a `tasks/test.yml` file to defines your tests.
16 - You may explode the tests into multiple `tasks/test-*.yml` files and import them in the `tasks/test.yml` file.
17 - The `tasks/cleanup.yml` file cannot use variables present in the `tasks/prepare.yml` file because cleanup should also run before the prepare tasks.
18
19 ### Naming convention
20
21 The integration tests handle a lot of different variables, names, identifier. To reduce this complexity, make sure to use the following naming conventions:
22
23 - Any test resources MUST be registered using the `test_<resource>` variable name (e.g. `test_server` or `test_floating_ip`) and MUST be created and cleaned in the `tasks/prepare.yml` and `tasks/cleanup.yml`. The scope of this variable is the entire target.
24 - In `tasks/prepare.yml`, tasks names MUST start with: `Create test_<resource>` (e.g. `Create test_server` or `Create test_floating_ip`)
25 - In `tasks/cleanup.yml`, tasks names MUST start with: `Cleanup test_<resource>` (e.g. `Cleanup test_server` or `Cleanup test_floating_ip`)
26 - Any fact starting with `_` is scoped to the current file and MUST NOT be used outside of it.
27 - Any test result MUST be registered using the `result` variable name unless it is required in a future test, in that case it MUST use the `<resource>` variable name as prefix.