open-nomad/e2e/framework/provisioning/targets.go
Tim Gross 2edbdfc8be
e2e: update framework to allow deploying Nomad (#6969)
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.

Terraform work includes:
* provides Terraform output that written to JSON used by the framework
  to configure provisioning via `terraform output provisioning`.
* provides Terraform output that can be used by test operators to
  configure their shell via `$(terraform output environment)`
* drops `remote-exec` provisioning steps from Terraform
* makes changes to the deployment scripts to ensure they can be run
  multiple times w/ different versions against the same host.
2020-01-22 08:48:52 -05:00

47 lines
1.6 KiB
Go

package provisioning
import "testing"
// ProvisioningTargets is a set of hosts that will get a Nomad and/or Consul
// deployment.
type ProvisioningTargets struct {
Servers []*ProvisioningTarget `json:"servers"`
Clients []*ProvisioningTarget `json:"clients"`
}
// ProvisioningTarget is a specific host that will get a Nomad and/or Consul
// deployment.
type ProvisioningTarget struct {
Deployment Deployment `json:"deployment"`
Runner map[string]interface{} `json:"runner"`
runner ProvisioningRunner
}
type Deployment struct {
// Note: these override each other. NomadLocalBinary > NomadSha > NomadVersion
NomadLocalBinary string `json:"nomad_local_binary"`
NomadSha string `json:"nomad_sha"`
NomadVersion string `json:"nomad_version"`
RemoteBinaryPath string `json:"remote_binary_path"`
Platform string `json:"platform"`
Bundles []Bundle `json:"bundles"`
Steps []string `json:"steps"`
}
// Bundle is an arbitrary collection of files to support Nomad, Consul,
// etc. that will be placed as part of provisioning.
type Bundle struct {
Source string `json:"source"`
Destination string `json:"destination"`
}
// ProvisioningRunner is the interface for how a Provisioner will connect
// with a target and execute steps. Each target has its own runner.
type ProvisioningRunner interface {
Open(t *testing.T) error // start the runner, caching connection info
Run(string) error // run one step
Copy(string, string) error // copy a file
Close() // clean up the runner, call in a defer
}