2edbdfc8be
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.
34 lines
751 B
Go
34 lines
751 B
Go
package provisioning
|
|
|
|
import (
|
|
"os/exec"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// LinuxRunner is a ProvisioningRunner that runs on the executing host only.
|
|
// The Nomad configurations used with this runner will need to avoid port
|
|
// conflicts!
|
|
type LinuxRunner struct{}
|
|
|
|
func (runner *LinuxRunner) Open(_ *testing.T) error { return nil }
|
|
|
|
func (runner *LinuxRunner) Run(script string) error {
|
|
commands := strings.Split(script, "\n")
|
|
for _, command := range commands {
|
|
cmd := exec.Command(strings.TrimSpace(command))
|
|
err := cmd.Run()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (runner *LinuxRunner) Copy(local, remote string) error {
|
|
cmd := exec.Command("cp", "-rf", local, remote)
|
|
return cmd.Run()
|
|
}
|
|
|
|
func (runner *LinuxRunner) Close() {}
|