diff --git a/enos/enos-scenario-e2e-aws.hcl b/enos/enos-scenario-e2e-aws.hcl index 9f824b096e..9400f5c958 100644 --- a/enos/enos-scenario-e2e-aws.hcl +++ b/enos/enos-scenario-e2e-aws.hcl @@ -176,6 +176,7 @@ scenario "e2e_aws" { variables { test_package = "github.com/hashicorp/boundary/testing/internal/e2e/tests/aws" + debug_no_run = var.e2e_debug_no_run alb_boundary_api_addr = step.create_boundary_cluster.alb_boundary_api_addr auth_method_id = step.create_boundary_cluster.auth_method_id auth_login_name = step.create_boundary_cluster.auth_login_name diff --git a/enos/enos-scenario-e2e-database.hcl b/enos/enos-scenario-e2e-database.hcl index b937d0b996..144c4c6323 100644 --- a/enos/enos-scenario-e2e-database.hcl +++ b/enos/enos-scenario-e2e-database.hcl @@ -100,6 +100,7 @@ scenario "e2e_database" { variables { test_package = "github.com/hashicorp/boundary/testing/internal/e2e/tests/database" + debug_no_run = var.e2e_debug_no_run local_boundary_dir = local.local_boundary_dir target_user = "ubuntu" aws_ssh_private_key_path = local.aws_ssh_private_key_path diff --git a/enos/enos-scenario-e2e-static-with-vault.hcl b/enos/enos-scenario-e2e-static-with-vault.hcl index 1d232c0a52..661207ee76 100644 --- a/enos/enos-scenario-e2e-static-with-vault.hcl +++ b/enos/enos-scenario-e2e-static-with-vault.hcl @@ -132,6 +132,7 @@ scenario "e2e_static_with_vault" { variables { test_package = "github.com/hashicorp/boundary/testing/internal/e2e/tests/static_with_vault" + debug_no_run = var.e2e_debug_no_run alb_boundary_api_addr = step.create_boundary_cluster.alb_boundary_api_addr auth_method_id = step.create_boundary_cluster.auth_method_id auth_login_name = step.create_boundary_cluster.auth_login_name diff --git a/enos/enos-scenario-e2e-static.hcl b/enos/enos-scenario-e2e-static.hcl index 98ada1c6f6..a6f3b81795 100644 --- a/enos/enos-scenario-e2e-static.hcl +++ b/enos/enos-scenario-e2e-static.hcl @@ -109,6 +109,7 @@ scenario "e2e_static" { variables { test_package = "github.com/hashicorp/boundary/testing/internal/e2e/tests/static" + debug_no_run = var.e2e_debug_no_run alb_boundary_api_addr = step.create_boundary_cluster.alb_boundary_api_addr auth_method_id = step.create_boundary_cluster.auth_method_id auth_login_name = step.create_boundary_cluster.auth_login_name diff --git a/enos/enos-variables.hcl b/enos/enos-variables.hcl index 599939b53d..26ff0b38e1 100644 --- a/enos/enos-variables.hcl +++ b/enos/enos-variables.hcl @@ -124,3 +124,9 @@ variable "local_build_target" { type = string default = "build-ui build" } + +variable "e2e_debug_no_run" { + description = "If set, this will prevent test suites from running" + type = bool + default = false +} diff --git a/enos/enos.vars.hcl b/enos/enos.vars.hcl index 36ef63d9b3..c8bf1b8110 100644 --- a/enos/enos.vars.hcl +++ b/enos/enos.vars.hcl @@ -40,3 +40,8 @@ // The port the ALB will listen on to proxy controller API requests. This defaults // to 9200 // alb_listener_api_port = 9200 + +// Generally, if there's failure in the test suite for any reason, enos/terraform will throw an error and you +// would not be able to access the environment variables needed to test locally. Enabling this +// will ensure that the enos scenario passes. +// e2e_debug_no_run = true diff --git a/enos/modules/test_e2e/main.tf b/enos/modules/test_e2e/main.tf index 7a53c7bac6..c279fb053e 100644 --- a/enos/modules/test_e2e/main.tf +++ b/enos/modules/test_e2e/main.tf @@ -9,6 +9,11 @@ terraform { } } +variable "debug_no_run" { + description = "If set, this module will not execute the tests so that you can still access environment variables" + type = bool + default = false +} variable "test_package" { description = "Name of Go test package to run" type = string @@ -139,7 +144,7 @@ resource "enos_local_exec" "run_e2e_test" { E2E_AWS_HOST_SET_IPS2 = local.aws_host_set_ips2 } - inline = ["set -o pipefail; PATH=\"${var.local_boundary_dir}:$PATH\" go test -v ${var.test_package} -count=1 -json | tparse -follow -format plain 2>&1 | tee ${path.module}/../../test-e2e-${local.package_name}.out"] + inline = var.debug_no_run ? [""] : ["set -o pipefail; PATH=\"${var.local_boundary_dir}:$PATH\" go test -v ${var.test_package} -count=1 -json | tparse -follow -format plain 2>&1 | tee ${path.module}/../../test-e2e-${local.package_name}.out"] } output "test_results" { diff --git a/enos/scripts/test_e2e_env.sh b/enos/scripts/test_e2e_env.sh new file mode 100644 index 0000000000..2a6ad63ae7 --- /dev/null +++ b/enos/scripts/test_e2e_env.sh @@ -0,0 +1,13 @@ +#!/bin/bash +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: MPL-2.0 + +DIR=$(pwd) + +SCRIPTS_DIR=$( cd -- "$( dirname -- "$0" )" &> /dev/null && pwd ) +STATEDIR=$(ls -td $SCRIPTS_DIR/../.enos/*/ | head -1) # get latest directory + +cd $STATEDIR +terraform show -json terraform.tfstate | jq -r '.values.root_module.child_modules[].resources[] | select(.address=="module.run_e2e_test.enos_local_exec.run_e2e_test") | .values.environment | to_entries[] | "export \(.key)=\(.value|@sh)"' + +cd $DIR diff --git a/testing/internal/e2e/README.md b/testing/internal/e2e/README.md index 806c633067..13719195a7 100644 --- a/testing/internal/e2e/README.md +++ b/testing/internal/e2e/README.md @@ -110,11 +110,7 @@ Launch an enos scenario and print out the environment variables ``` cd enos enos scenario launch e2e_{scenario} builder:local -enos scenario output -cd .enos -ls -ltr -cd # bottom of list -terraform show -json terraform.tfstate | jq -r '.values.root_module.child_modules[].resources[] | select(.address=="module.run_e2e_test.enos_local_exec.run_e2e_test") | .values.environment | to_entries[] | "export \(.key)=\(.value)"' +bash scripts/test_e2e_env.sh ``` Take the printed environment variable information and export them into another terminal session