diff --git a/e2e/terraform/README.md b/e2e/terraform/README.md index 811e95c7f96..e691bb77338 100644 --- a/e2e/terraform/README.md +++ b/e2e/terraform/README.md @@ -134,20 +134,21 @@ about the cluster: client node IPs. - `terraform output windows_clients` will output the list of Windows client node IPs. +- `cluster_unique_identifier` will output the random name used to identify the cluster's resources ## SSH You can use Terraform outputs above to access nodes via ssh: ```sh -ssh -i keys/{cluster-name}/nomad-e2e-*.pem ubuntu@${EC2_IP_ADDR} +ssh -i keys/${CLUSTER_UNIQUE_IDENTIFIER}/nomad-e2e-*.pem ubuntu@${EC2_IP_ADDR} ``` The Windows client runs OpenSSH for convenience, but has a different user and will drop you into a Powershell shell instead of bash: ```sh -ssh -i keys/{cluster-name}/nomad-e2e-*.pem Administrator@${EC2_IP_ADDR} +ssh -i keys/${CLUSTER_UNIQUE_IDENTIFIER}/nomad-e2e-*.pem Administrator@${EC2_IP_ADDR} ``` ## Teardown diff --git a/e2e/terraform/outputs.tf b/e2e/terraform/outputs.tf index 985f523a524..a6539a7d765 100644 --- a/e2e/terraform/outputs.tf +++ b/e2e/terraform/outputs.tf @@ -38,6 +38,10 @@ output "nomad_token" { sensitive = true } +output "cluster_unique_identifier" { + value = module.provision-infra.cluster_unique_identifier +} + # Note: Consul and Vault environment needs to be set in test # environment before the Terraform run, so we don't have that output # here @@ -45,4 +49,4 @@ output "environment" { description = "get connection config by running: $(terraform output environment)" sensitive = true value = module.provision-infra.environment -} \ No newline at end of file +} diff --git a/e2e/terraform/provision-infra/outputs.tf b/e2e/terraform/provision-infra/outputs.tf index 80574a7bcd8..c330eadb486 100644 --- a/e2e/terraform/provision-infra/outputs.tf +++ b/e2e/terraform/provision-infra/outputs.tf @@ -57,9 +57,14 @@ export NOMAD_E2E=1 export CONSUL_HTTP_ADDR=https://${aws_instance.consul_server.public_ip}:8501 export CONSUL_HTTP_TOKEN=${local_sensitive_file.consul_initial_management_token.content} export CONSUL_CACERT=${abspath(local.keys_dir)}/tls_ca.crt +export CLUSTER_UNIQUE_IDENTIFIER=${local.random_name} EOM } +output "cluster_unique_identifier" { + value = "${local.random_name}" +} + output "nomad_addr" { value = "https://${aws_instance.server[0].public_ip}:4646" } diff --git a/enos/modules/fetch_artifactory/outputs.tf b/enos/modules/fetch_artifactory/outputs.tf new file mode 100644 index 00000000000..8e6ed5de00a --- /dev/null +++ b/enos/modules/fetch_artifactory/outputs.tf @@ -0,0 +1,25 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: BUSL-1.1 + +output "nomad_local_binary" { + value = "${var.binary_path}/nomad" + description = "Path where the binary will be placed" +} + +output "vault_artifactory_release" { + description = "Binary information returned from the artifactory" + value = { + url = data.enos_artifactory_item.nomad.results[0].url + sha256 = data.enos_artifactory_item.nomad.results[0].sha256 + } +} + +output "nomad_local_binary_ubuntu_jammy" { + value = "${var.binary_path}/nomad" + description = "Path where the binary will be placed" +} + +output "nomad_local_binary_windows_2016" { + value = "${var.binary_path}/nomad.exe" + description = "Path where the binary will be placed" +} diff --git a/enos/modules/run_workloads/scripts/wait_for_nomad_api.sh b/enos/modules/run_workloads/scripts/wait_for_nomad_api.sh new file mode 100644 index 00000000000..a658aae60e4 --- /dev/null +++ b/enos/modules/run_workloads/scripts/wait_for_nomad_api.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: BUSL-1.1 + +set -xeuo pipefail + +TIMEOUT=15 +INTERVAL=5 + +start_time=$(date +%s) + +while ! nomad server members > /dev/null 2>&1; do + echo "Waiting for Nomad API..." + + current_time=$(date +%s) + elapsed_time=$((current_time - start_time)) + if [ "$elapsed_time" -ge "$TIMEOUT" ]; then + echo "Error: Nomad API did not become available within $TIMEOUT seconds." + exit 1 + fi + + sleep "$INTERVAL" +done + +echo "Nomad API is available!"