Skip to content

Commit

Permalink
e2e: deploy Nomad from testing framework (#6949)
Browse files Browse the repository at this point in the history
The e2e framework instantiates clients for Nomad/Consul but the
provisioning of the actual Nomad cluster is left to Terraform. The
Terraform provisioning process uses `remote-exec` to deploy specific
versions of Nomad so that we don't have to bake an AMI every time we
want to test a new version. But Terraform treats the resulting
instances as immutable, so we can't use the same tooling to update the
version of Nomad in-place. This is a prerequisite for upgrade testing.

This changeset extends the e2e framework to provide the option of
deploying Nomad (and, in the future, Consul/Vault) with specific
versions to running infrastructure. This initial implementation is
focused on deploying to a single cluster via `ssh` (because that's our
current need), but provides interfaces to hook the test run at the
start of the run, the start of each suite, or the start of a given
test case.

The input JSON for configuring provisioning targets can be generated
by Terraform (or written by hand). That will be under a separate PR.
  • Loading branch information
tgross authored Jan 21, 2020
1 parent a3dc578 commit 047fc42
Show file tree
Hide file tree
Showing 15 changed files with 1,086 additions and 137 deletions.
16 changes: 0 additions & 16 deletions e2e/e2e.go

This file was deleted.

11 changes: 10 additions & 1 deletion e2e/e2e_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
// This package exists to wrap our e2e provisioning and test framework so that it
// can be run via 'go test ./e2e'. See './framework/framework.go'
package e2e

import (
"os"
"testing"

"github.com/hashicorp/nomad/e2e/framework"

_ "github.com/hashicorp/nomad/e2e/affinities"
_ "github.com/hashicorp/nomad/e2e/clientstate"
_ "github.com/hashicorp/nomad/e2e/connect"
Expand All @@ -19,5 +24,9 @@ import (
)

func TestE2E(t *testing.T) {
RunE2ETests(t)
if os.Getenv("NOMAD_E2E") == "" {
t.Skip("Skipping e2e tests, NOMAD_E2E not set")
} else {
framework.Run(t)
}
}
5 changes: 3 additions & 2 deletions e2e/framework/case.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

capi "github.com/hashicorp/consul/api"
"github.com/hashicorp/nomad/api"
"github.com/hashicorp/nomad/e2e/framework/provisioning"
)

// TestSuite defines a set of test cases and under what conditions to run them
Expand Down Expand Up @@ -58,7 +59,7 @@ func (c Constraints) matches(env Environment) error {

// TC is the base test case which should be embedded in TestCase implementations.
type TC struct {
cluster *ClusterInfo
cluster *provisioning.ClusterInfo
}

// Nomad returns a configured nomad api client
Expand All @@ -77,6 +78,6 @@ func (tc *TC) Name() string {
return tc.cluster.Name
}

func (tc *TC) setClusterInfo(info *ClusterInfo) {
func (tc *TC) setClusterInfo(info *provisioning.ClusterInfo) {
tc.cluster = info
}
Loading

0 comments on commit 047fc42

Please sign in to comment.