test(e2e): Add end-to-end tests (connect to first target)
This adds the initial end-to-end tests. These tests validate the admin workflow of setting up their first target
This commit is contained in:
1 parent
172381f273
commit
21e4b70e27
10 files changed
+697
No files matched your search
@@ -111,3 +111,8 @@ you could test that version against the cluster by setting `local_boundary_dir`
|
||||
in the Boundary cluster and then executes the Bats CLI UI tests against it. This
|
||||
scenario requires the machine executing `enos` to be configured for the Bats
|
||||
tests as described in the Requirements section.
|
||||
|
||||
## End-to-end tests
|
||||
|
||||
Scenarios with `e2e_` invoke an end-to-end test suite written in Go. Different tests
|
||||
are invoked depending on the scenario.
|
||||
@@ -66,3 +66,6 @@ module "test_cli_ui" {
|
||||
source = "./modules/test_cli_ui"
|
||||
}
|
||||
|
||||
module "test_e2e" {
|
||||
source = "./modules/test_e2e"
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
scenario "e2e_target" {
|
||||
terraform_cli = terraform_cli.default
|
||||
terraform = terraform.default
|
||||
providers = [
|
||||
provider.aws.default,
|
||||
provider.enos.default
|
||||
]
|
||||
|
||||
matrix {
|
||||
builder = ["local", "crt"]
|
||||
}
|
||||
|
||||
locals {
|
||||
aws_ssh_private_key_path = abspath(var.aws_ssh_private_key_path)
|
||||
boundary_install_dir = abspath(var.boundary_install_dir)
|
||||
local_boundary_dir = abspath(var.local_boundary_dir)
|
||||
build_path = {
|
||||
"local" = "/tmp",
|
||||
"crt" = var.crt_bundle_path == null ? null : abspath(var.crt_bundle_path)
|
||||
}
|
||||
}
|
||||
|
||||
step "find_azs" {
|
||||
module = module.az_finder
|
||||
|
||||
variables {
|
||||
instance_type = [
|
||||
var.worker_instance_type,
|
||||
var.controller_instance_type
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
step "create_db_password" {
|
||||
module = module.random_stringifier
|
||||
}
|
||||
|
||||
step "build_boundary" {
|
||||
module = matrix.builder == "crt" ? module.build_crt : module.build_local
|
||||
|
||||
variables {
|
||||
path = local.build_path[matrix.builder]
|
||||
}
|
||||
}
|
||||
|
||||
step "create_base_infra" {
|
||||
module = module.infra
|
||||
|
||||
variables {
|
||||
availability_zones = step.find_azs.availability_zones
|
||||
}
|
||||
}
|
||||
|
||||
step "create_boundary_cluster" {
|
||||
module = module.boundary
|
||||
depends_on = [
|
||||
step.create_base_infra,
|
||||
step.build_boundary
|
||||
]
|
||||
|
||||
variables {
|
||||
boundary_install_dir = local.boundary_install_dir
|
||||
controller_instance_type = var.controller_instance_type
|
||||
controller_count = var.controller_count
|
||||
db_pass = step.create_db_password.string
|
||||
kms_key_arn = step.create_base_infra.kms_key_arn
|
||||
local_artifact_path = step.build_boundary.artifact_path
|
||||
ubuntu_ami_id = step.create_base_infra.ami_ids["ubuntu"]["amd64"]
|
||||
vpc_id = step.create_base_infra.vpc_id
|
||||
worker_count = var.worker_count
|
||||
worker_instance_type = var.worker_instance_type
|
||||
}
|
||||
}
|
||||
|
||||
step "launch_targets" {
|
||||
module = module.target
|
||||
depends_on = [step.create_base_infra]
|
||||
|
||||
variables {
|
||||
ami_id = step.create_base_infra.ami_ids["ubuntu"]["amd64"]
|
||||
aws_ssh_keypair_name = var.aws_ssh_keypair_name
|
||||
enos_user = var.enos_user
|
||||
instance_type = var.target_instance_type
|
||||
vpc_id = step.create_base_infra.vpc_id
|
||||
}
|
||||
}
|
||||
|
||||
step "run_e2e_targets_test" {
|
||||
module = module.test_e2e
|
||||
depends_on = [
|
||||
step.create_boundary_cluster,
|
||||
step.launch_targets
|
||||
]
|
||||
|
||||
variables {
|
||||
test_package = "github.com/hashicorp/boundary/testing/internal/e2e/target"
|
||||
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
|
||||
auth_password = step.create_boundary_cluster.auth_password
|
||||
local_boundary_dir = local.local_boundary_dir
|
||||
aws_ssh_private_key_path = local.aws_ssh_private_key_path
|
||||
target_ips = step.launch_targets.target_ips
|
||||
}
|
||||
}
|
||||
|
||||
output "test_results" {
|
||||
value = step.run_e2e_targets_test.test_results
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
enos = {
|
||||
source = "app.terraform.io/hashicorp-qti/enos"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
variable "test_package" {
|
||||
description = "Name of Go test package to run"
|
||||
type = string
|
||||
}
|
||||
variable "alb_boundary_api_addr" {
|
||||
description = "URL of the Boundary instance"
|
||||
type = string
|
||||
}
|
||||
variable "auth_method_id" {
|
||||
description = "Id of Auth Method used to login to Boundary instance"
|
||||
type = string
|
||||
}
|
||||
variable "auth_login_name" {
|
||||
description = "Name of admin user"
|
||||
type = string
|
||||
}
|
||||
variable "auth_password" {
|
||||
description = "Password of admin user"
|
||||
type = string
|
||||
}
|
||||
variable "local_boundary_dir" {
|
||||
description = "Local Path to boundary executable"
|
||||
type = string
|
||||
}
|
||||
variable "aws_ssh_private_key_path" {
|
||||
description = "Local Path to key used to SSH onto created hosts"
|
||||
type = string
|
||||
}
|
||||
variable "target_ips" {
|
||||
description = "List of IP Addresses of created hosts"
|
||||
type = list(string)
|
||||
}
|
||||
|
||||
locals {
|
||||
aws_ssh_private_key_path = abspath(var.aws_ssh_private_key_path)
|
||||
}
|
||||
|
||||
resource "enos_local_exec" "run_e2e_test" {
|
||||
environment = {
|
||||
BOUNDARY_ADDR = var.alb_boundary_api_addr,
|
||||
E2E_PASSWORD_AUTH_METHOD_ID = var.auth_method_id,
|
||||
E2E_PASSWORD_ADMIN_LOGIN_NAME = var.auth_login_name,
|
||||
E2E_PASSWORD_ADMIN_PASSWORD = var.auth_password,
|
||||
E2E_TARGET_IP = var.target_ips[0],
|
||||
E2E_SSH_USER = "ubuntu"
|
||||
E2E_SSH_KEY_PATH = local.aws_ssh_private_key_path,
|
||||
}
|
||||
|
||||
inline = ["PATH=\"${var.local_boundary_dir}:$PATH\" go test -v ${var.test_package}"]
|
||||
}
|
||||
|
||||
output "test_results" {
|
||||
value = enos_local_exec.run_e2e_test.stdout
|
||||
}
|
||||
Reference in new issue
Block a user