2022-08-31 12:08:46 -04:00
|
|
|
# boundary-e2e-tests
|
|
|
|
|
|
2022-09-23 14:21:00 -04:00
|
|
|
This test suite tests Boundary in an end-to-end setting, utilizing both the Boundary CLI and the
|
|
|
|
|
Boundary Go API to exercise Boundary through various user workflows. It was designed to be run in a
|
|
|
|
|
variety of environments as long as the appropriate environment variables are set. The test suite
|
|
|
|
|
itself uses the standard [go test](https://pkg.go.dev/testing) library.
|
|
|
|
|
|
|
|
|
|
One method for setting up an environment is utilizing [Enos](https://github.com/hashicorp/Enos-Docs)
|
|
|
|
|
to create the desired infrastructure.
|
2022-08-31 12:08:46 -04:00
|
|
|
|
|
|
|
|
## Getting Started
|
2022-09-23 14:21:00 -04:00
|
|
|
### Enos
|
|
|
|
|
Setup Enos as described [here](../../../enos/README.md)
|
2022-08-31 12:08:46 -04:00
|
|
|
|
2022-09-23 14:21:00 -04:00
|
|
|
Then, use the following commands to run tests
|
2022-08-31 12:08:46 -04:00
|
|
|
```shell
|
2022-09-23 14:21:00 -04:00
|
|
|
cd enos
|
|
|
|
|
enos scenario list
|
2022-08-31 12:08:46 -04:00
|
|
|
|
2022-09-23 14:21:00 -04:00
|
|
|
# `Run` executes the tests and destroys the associated infrastructure in one command
|
|
|
|
|
enos scenario run e2e_{scenario} builder:local
|
2022-08-31 12:08:46 -04:00
|
|
|
|
2022-09-23 14:21:00 -04:00
|
|
|
# `Launch` executes the tests, but leaves the infrastructure online for debugging purposes
|
|
|
|
|
enos scenario launch e2e_{scenario} builder:local
|
|
|
|
|
enos scenario output # displays any defined enos output
|
|
|
|
|
enos scenario destroy # destroys infra
|
2022-08-31 12:08:46 -04:00
|
|
|
```
|
|
|
|
|
|
2022-09-23 14:21:00 -04:00
|
|
|
Enos scenarios set up the infrastructure, set the appropriate environment variables, and run the
|
|
|
|
|
specified tests in its scenario file.
|
|
|
|
|
|
|
|
|
|
Note: To run the `e2e_host_aws` scenario, you will need access to the boundary team's test AWS
|
|
|
|
|
account.
|
2022-08-31 12:08:46 -04:00
|
|
|
|
2022-09-23 14:21:00 -04:00
|
|
|
### Local
|
2022-08-31 12:08:46 -04:00
|
|
|
Set the appropriate environment variables...
|
|
|
|
|
```shell
|
2022-12-06 15:59:17 -05:00
|
|
|
export E2E_TESTS=true # This is needed for any e2e test. Otherwise, the test is skipped
|
2022-12-13 17:00:50 -05:00
|
|
|
|
|
|
|
|
# For e2e/tests/static
|
2022-08-31 12:08:46 -04:00
|
|
|
export BOUNDARY_ADDR= # e.g. http://127.0.0.1:9200
|
|
|
|
|
export E2E_PASSWORD_AUTH_METHOD_ID= # e.g. ampw_1234567890
|
|
|
|
|
export E2E_PASSWORD_ADMIN_LOGIN_NAME= # e.g. "admin"
|
|
|
|
|
export E2E_PASSWORD_ADMIN_PASSWORD= # e.g. "password"
|
|
|
|
|
|
|
|
|
|
export E2E_TARGET_IP= # e.g. 192.168.0.1
|
|
|
|
|
export E2E_SSH_KEY_PATH= # e.g. /Users/username/key.pem
|
|
|
|
|
export E2E_SSH_USER= # e.g. ubuntu
|
2022-09-16 11:45:55 -04:00
|
|
|
|
2022-12-13 17:00:50 -05:00
|
|
|
# For e2e/tests/static_with_vault
|
|
|
|
|
export BOUNDARY_ADDR= # e.g. http://127.0.0.1:9200
|
|
|
|
|
export E2E_PASSWORD_AUTH_METHOD_ID= # e.g. ampw_1234567890
|
|
|
|
|
export E2E_PASSWORD_ADMIN_LOGIN_NAME= # e.g. "admin"
|
|
|
|
|
export E2E_PASSWORD_ADMIN_PASSWORD= # e.g. "password"
|
|
|
|
|
|
|
|
|
|
export VAULT_ADDR= # e.g. http://127.0.0.1:8200
|
|
|
|
|
export VAULT_TOKEN=
|
|
|
|
|
export E2E_TARGET_IP= # e.g. 192.168.0.1
|
|
|
|
|
export E2E_SSH_KEY_PATH= # e.g. /Users/username/key.pem
|
|
|
|
|
export E2E_SSH_USER= # e.g. ubuntu
|
|
|
|
|
|
|
|
|
|
# For e2e/tests/aws
|
|
|
|
|
export BOUNDARY_ADDR= # e.g. http://127.0.0.1:9200
|
|
|
|
|
export E2E_PASSWORD_AUTH_METHOD_ID= # e.g. ampw_1234567890
|
|
|
|
|
export E2E_PASSWORD_ADMIN_LOGIN_NAME= # e.g. "admin"
|
|
|
|
|
export E2E_PASSWORD_ADMIN_PASSWORD= # e.g. "password"
|
|
|
|
|
|
2022-09-23 14:21:00 -04:00
|
|
|
export E2E_AWS_ACCESS_KEY_ID=
|
|
|
|
|
export E2E_AWS_SECRET_ACCESS_KEY=
|
2022-12-13 17:00:50 -05:00
|
|
|
export E2E_AWS_HOST_SET_FILTER= # e.g. "tag:testtag=true"
|
|
|
|
|
export E2E_AWS_HOST_SET_IPS= # e.g. "[\"1.2.3.4\", \"2.3.4.5\"]"
|
2022-09-23 14:21:00 -04:00
|
|
|
export E2E_AWS_HOST_SET_FILTER2= # e.g. "tag:testtagtwo=test"
|
2022-10-10 14:10:41 -04:00
|
|
|
export E2E_AWS_HOST_SET_IPS2= # e.g. "[\"1.2.3.4\"]
|
2022-09-23 14:21:00 -04:00
|
|
|
export E2E_SSH_KEY_PATH= # e.g. /Users/username/key.pem
|
|
|
|
|
export E2E_SSH_USER= # e.g. ubuntu
|
|
|
|
|
|
2022-12-13 17:00:50 -05:00
|
|
|
# For e2e/tests/database
|
|
|
|
|
export E2E_AWS_ACCESS_KEY_ID=
|
|
|
|
|
export E2E_AWS_SECRET_ACCESS_KEY=
|
|
|
|
|
export E2E_AWS_HOST_SET_FILTER= # e.g. "tag:testtag=true"
|
2022-09-16 11:45:55 -04:00
|
|
|
export VAULT_ADDR= # e.g. http://127.0.0.1:8200
|
|
|
|
|
export VAULT_TOKEN=
|
2022-08-31 12:08:46 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Then, run...
|
|
|
|
|
```shell
|
2023-03-02 14:32:53 -05:00
|
|
|
go test github.com/hashicorp/boundary/testing/internal/e2e/tests/static
|
2022-08-31 12:08:46 -04:00
|
|
|
go test ./target/ // run target tests if running from this directory
|
2023-03-02 14:32:53 -05:00
|
|
|
go test github.com/hashicorp/boundary/testing/internal/e2e/tests/static -v // verbose
|
|
|
|
|
go test github.com/hashicorp/boundary/testing/internal/e2e/tests/static -v -run '^TestCreateTargetApi$' // run a specific test
|
2022-08-31 12:08:46 -04:00
|
|
|
```
|
2022-09-23 14:21:00 -04:00
|
|
|
|
|
|
|
|
## Adding Tests
|
|
|
|
|
|
2022-12-13 17:00:50 -05:00
|
|
|
Tests live in the `tests/` directory. Additional tests can be added to an existing go package or a
|
|
|
|
|
new one can be created. If a new package is created, a new enos scenario would also need to be
|
|
|
|
|
created.
|
2022-09-23 14:21:00 -04:00
|
|
|
|
|
|
|
|
Enos is comprised of scenarios, where a scenario is the environment you want the tests to operate
|
|
|
|
|
in. In one scenario, there may be a boundary cluster and a target. Another scenario might involve a
|
|
|
|
|
boundary cluster and a vault instance. Scenarios can be found in [boundary/enos](../../../enos/)
|
2022-10-10 11:56:07 -04:00
|
|
|
|
|
|
|
|
To run these tests in CI, the [enos-run.yml](../../../.github/workflows/enos-run.yml) github action
|
|
|
|
|
workflow must be updated to include the new scenario (see the `matrix`).
|
|
|
|
|
|
|
|
|
|
### Development
|
|
|
|
|
To assist with iterating on tests on enos launched infrastructure, you can perform the following...
|
|
|
|
|
|
2022-12-13 17:00:50 -05:00
|
|
|
Launch an enos scenario and print out the environment variables
|
2022-10-10 11:56:07 -04:00
|
|
|
```
|
2022-12-13 17:00:50 -05:00
|
|
|
cd enos
|
2022-10-10 11:56:07 -04:00
|
|
|
enos scenario launch e2e_{scenario} builder:local
|
2023-03-02 12:37:12 -05:00
|
|
|
bash scripts/test_e2e_env.sh
|
2022-10-10 11:56:07 -04:00
|
|
|
```
|
2022-12-13 17:00:50 -05:00
|
|
|
|
2022-10-10 11:56:07 -04:00
|
|
|
Take the printed environment variable information and export them into another terminal session
|
|
|
|
|
```
|
|
|
|
|
export BOUNDARY_ADDR=
|
|
|
|
|
export E2E_PASSWORD_AUTH_METHOD_ID=
|
|
|
|
|
...
|
|
|
|
|
```
|
|
|
|
|
Run your tests
|
|
|
|
|
```
|
|
|
|
|
go test -v {go package}
|
|
|
|
|
```
|