README.md
1# End to End Tests
2
3This package contains integration tests. Unlike tests alongside Nomad code,
4these tests expect there to already be a functional Nomad cluster accessible
5(either on localhost or via the `NOMAD_ADDR` env var).
6
7See [`framework/doc.go`](framework/doc.go) for how to write tests.
8
9The `NOMAD_E2E=1` environment variable must be set for these tests to run.
10
11## Provisioning Test Infrastructure on AWS
12
13The `terraform/` folder has provisioning code to spin up a Nomad cluster on
14AWS. You'll need both Terraform and AWS credentials to setup AWS instances on
15which e2e tests will run. See the
16[README](https://github.com/hashicorp/nomad/blob/main/e2e/terraform/README.md)
17for details. The number of servers and clients is configurable, as is the
18specific build of Nomad to deploy and the configuration file for each client
19and server.
20
21## Provisioning Local Clusters
22
23To run tests against a local cluster, you'll need to make sure the following
24environment variables are set:
25
26* `NOMAD_ADDR` should point to one of the Nomad servers
27* `CONSUL_HTTP_ADDR` should point to one of the Consul servers
28* `NOMAD_E2E=1`
29
30_TODO: the scripts in `./bin` currently work only with Terraform, it would be
31nice for us to have a way to deploy Nomad to Vagrant or local clusters._
32
33## Running
34
35After completing the provisioning step above, you can set the client
36environment for `NOMAD_ADDR` and run the tests as shown below:
37
38```sh
39# from the ./e2e/terraform directory, set your client environment
40# if you haven't already
41$(terraform output environment)
42
43cd ..
44go test -v .
45```
46
47If you want to run a specific suite, you can specify the `-suite` flag as
48shown below. Only the suite with a matching `Framework.TestSuite.Component`
49will be run, and all others will be skipped.
50
51```sh
52go test -v -suite=Consul .
53```
54
55If you want to run a specific test, you'll need to regex-escape some of the
56test's name so that the test runner doesn't skip over framework struct method
57names in the full name of the tests:
58
59```sh
60go test -v . -run 'TestE2E/Consul/\*consul\.ScriptChecksE2ETest/TestGroup'
61 ^ ^ ^ ^
62 | | | |
63 Component | | Test func
64 | |
65 Go Package Struct
66```
67
68## I Want To...
69
70### ...SSH Into One Of The Test Machines
71
72You can use the Terraform output to find the IP address. The keys will
73in the `./terraform/keys/` directory.
74
75```sh
76ssh -i keys/nomad-e2e-*.pem ubuntu@${EC2_IP_ADDR}
77```
78
79Run `terraform output` for IP addresses and details.
80
81### ...Deploy a Cluster of Mixed Nomad Versions
82
83The `variables.tf` file describes the `nomad_version`, and
84`nomad_local_binary` variables that can be used for most circumstances. But if
85you want to deploy mixed Nomad versions, you can provide a list of versions in
86your `terraform.tfvars` file.
87
88For example, if you want to provision 3 servers all using Nomad 0.12.1, and 2
89Linux clients using 0.12.1 and 0.12.2, you can use the following variables:
90
91```hcl
92# will be used for servers
93nomad_version = "0.12.1"
94
95# will override the nomad_version for Linux clients
96nomad_version_client_linux = [
97 "0.12.1",
98 "0.12.2"
99]
100```
101
102### ...Deploy Custom Configuration Files
103
104Set the `profile` field to `"custom"` and put the configuration files in
105`./terraform/config/custom/` as described in the
106[README](https://github.com/hashicorp/nomad/blob/main/e2e/terraform/README.md#Profiles).
107
108### ...Deploy More Than 4 Linux Clients
109
110Use the `"custom"` profile as described above.
111
112### ...Change the Nomad Version After Provisioning
113
114You can update the `nomad_version` variable, or simply rebuild the binary you
115have at the `nomad_local_binary` path so that Terraform picks up the
116changes. Then run `terraform plan`/`terraform apply` again. This will update
117Nomad in place, making the minimum amount of changes necessary.
118