Skip to content

Commit 1a40161

Browse files
authored
Document how system tests work (#727)
1 parent a7482dc commit 1a40161

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

docs/howto/system_testing.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,32 @@ data "aws_ami" "latest-amzn" {
143143

144144
Notice the use of the `TEST_RUN_ID` variable. It contains a unique ID, which can help differentiate resources created in potential concurrent test runs.
145145

146+
#### Environment variables
147+
148+
To use environment variables within the Terraform service deployer a `env.yml` file is required.
149+
150+
The file should be structured like this:
151+
152+
```yaml
153+
version: '2.3'
154+
services:
155+
terraform:
156+
environment:
157+
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
158+
```
159+
160+
It's purpose is to inject environment variables in the Terraform service deployer environment.
161+
162+
To specify a default use this syntax: `AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:-default}`, replacing `default` with the desired default value.
163+
164+
**NOTE**: Terraform requires to prefix variables using the environment variables form with `TF_VAR_`. These variables are not available in test case definitions because they are [not injected](https://github.com/elastic/elastic-package/blob/f5312b6022e3527684e591f99e73992a73baafcf/internal/testrunner/runners/system/servicedeployer/terraform_env.go#L43) in the test environment.
165+
166+
#### Cloud Provider CI support
167+
168+
Terraform is often used to interact with Cloud Providers. This require Cloud Provider credentials.
169+
170+
Injecting credentials can be achieved with functions from the [`apm-pipeline-library`](https://github.com/elastic/apm-pipeline-library/tree/main/vars) Jenkins library. For example look for `withAzureCredentials`, `withAWSEnv` or `withGCPEnv`.
171+
146172
### Kubernetes service deployer
147173

148174
The Kubernetes service deployer requires the `_dev/deploy/k8s` directory to be present. It can include additional `*.yaml` files to deploy
@@ -217,6 +243,9 @@ The `SERVICE_LOGS_DIR` placeholder is not the only one available for use in a da
217243
218244
Placeholders used in the `test-<test_name>-config.yml` must be enclosed in `{{` and `}}` delimiters, per Handlebars syntax.
219245
246+
247+
**NOTE**: Terraform variables in the form of environment variables (prefixed with `TF_VAR_`) are not injected and cannot be used as placeholder (their value will always be empty).
248+
220249
## Running a system test
221250
222251
Once the two levels of configurations are defined as described in the previous section, you are ready to run system tests for a package's data streams.
@@ -264,3 +293,18 @@ to indexing generated data from the integration's data streams into Elasticsearc
264293
```
265294
elastic-package test system --generate
266295
```
296+
297+
## Continuous Integration
298+
299+
`elastic-package` runs a set of system tests on some [dummy packages](https://github.com/elastic/elastic-package/tree/main/test/packages) to ensure it's functionalities work as expected. This allows to test changes affecting package testing within `elastic-package` before merging and releasing the changes.
300+
301+
Tests use set of environment variables that are set at the beginning of the `Jenkinsfile`.
302+
303+
The exposed environment variables are passed to the test runners through service deployer specific configuration (refer to the service deployer section for further details).
304+
305+
### Stack version
306+
307+
The tests use the [default version](https://github.com/elastic/elastic-package/blob/main/internal/install/stack_version.go#L9) `elastic-package` provides.
308+
309+
You can override this value by changing it in your PR if needed. To update the default version always create a dedicated PR.
310+

0 commit comments

Comments
 (0)