test(e2e): Add test for boundary connect postgres (#3671)
* refact(e2e): Rename env * test(e2e): Add test for `connect postgres` * fixup! test(e2e): Add test for `connect postgres`
This commit is contained in:
1 parent
78161c0187
commit
9a6b0d26cb
43 files changed
+346
-82
No files matched your search
@@ -152,7 +152,7 @@ scenario "e2e_aws_base_with_vault" {
|
||||
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_ip = step.create_target.target_ips[0]
|
||||
target_address = step.create_target.target_ips[0]
|
||||
target_user = "ubuntu"
|
||||
target_port = "22"
|
||||
vault_addr = step.create_vault_cluster.instance_public_ips[0]
|
||||
|
||||
@@ -129,7 +129,7 @@ scenario "e2e_aws_base" {
|
||||
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_ip = step.create_target.target_ips[0]
|
||||
target_address = step.create_target.target_ips[0]
|
||||
target_user = "ubuntu"
|
||||
target_port = "22"
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ scenario "e2e_aws" {
|
||||
aws_host_set_ips1 = step.create_targets_with_tag1.target_ips
|
||||
aws_host_set_filter2 = step.create_tag2_inputs.tag_string
|
||||
aws_host_set_ips2 = step.create_targets_with_tag2.target_ips
|
||||
target_ip = step.create_isolated_target.target_ips[0]
|
||||
target_address = step.create_isolated_target.target_ips[0]
|
||||
worker_tags = step.create_isolated_worker.worker_tags
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
# Copyright (c) HashiCorp, Inc.
|
||||
# SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
# For this scenario to work, add the following line to /etc/hosts
|
||||
# 127.0.0.1 localhost boundary
|
||||
|
||||
scenario "e2e_docker_base_with_postgres" {
|
||||
terraform_cli = terraform_cli.default
|
||||
terraform = terraform.default
|
||||
providers = [
|
||||
provider.enos.default
|
||||
]
|
||||
|
||||
matrix {
|
||||
builder = ["local", "crt"]
|
||||
}
|
||||
|
||||
locals {
|
||||
aws_ssh_private_key_path = abspath(var.aws_ssh_private_key_path)
|
||||
local_boundary_dir = abspath(var.local_boundary_dir)
|
||||
local_boundary_src_dir = abspath(var.local_boundary_src_dir)
|
||||
boundary_docker_image_file = abspath(var.boundary_docker_image_file)
|
||||
license_path = abspath(var.boundary_license_path != null ? var.boundary_license_path : joinpath(path.root, "./support/boundary.hclic"))
|
||||
|
||||
network_cluster = "e2e_cluster"
|
||||
|
||||
build_path = {
|
||||
"local" = "/tmp",
|
||||
"crt" = var.crt_bundle_path == null ? null : abspath(var.crt_bundle_path)
|
||||
}
|
||||
tags = merge({
|
||||
"Project Name" : var.project_name
|
||||
"Project" : "Enos",
|
||||
"Environment" : "ci"
|
||||
}, var.tags)
|
||||
}
|
||||
|
||||
step "build_boundary_docker_image" {
|
||||
module = matrix.builder == "crt" ? module.build_boundary_docker_crt : module.build_boundary_docker_local
|
||||
|
||||
variables {
|
||||
path = matrix.builder == "crt" ? local.boundary_docker_image_file : ""
|
||||
cli_build_path = local.build_path[matrix.builder]
|
||||
}
|
||||
}
|
||||
|
||||
step "create_docker_network" {
|
||||
module = module.docker_network
|
||||
variables {
|
||||
network_name = local.network_cluster
|
||||
}
|
||||
}
|
||||
|
||||
step "create_boundary_database" {
|
||||
depends_on = [
|
||||
step.create_docker_network
|
||||
]
|
||||
variables {
|
||||
image_name = "${var.docker_mirror}/library/postgres:latest"
|
||||
network_name = [local.network_cluster]
|
||||
}
|
||||
module = module.docker_postgres
|
||||
}
|
||||
|
||||
step "read_license" {
|
||||
skip_step = var.boundary_edition == "oss"
|
||||
module = module.read_license
|
||||
|
||||
variables {
|
||||
file_name = local.license_path
|
||||
}
|
||||
}
|
||||
|
||||
step "create_boundary" {
|
||||
module = module.docker_boundary
|
||||
depends_on = [
|
||||
step.create_docker_network,
|
||||
step.create_boundary_database,
|
||||
step.build_boundary_docker_image
|
||||
]
|
||||
variables {
|
||||
image_name = matrix.builder == "crt" ? var.boundary_docker_image_name : step.build_boundary_docker_image.image_name
|
||||
network_name = [local.network_cluster]
|
||||
database_network = local.network_cluster
|
||||
postgres_address = step.create_boundary_database.address
|
||||
boundary_license = var.boundary_edition != "oss" ? step.read_license.license : ""
|
||||
}
|
||||
}
|
||||
|
||||
step "run_e2e_test" {
|
||||
module = module.test_e2e_docker
|
||||
depends_on = [
|
||||
step.create_boundary,
|
||||
]
|
||||
variables {
|
||||
test_package = "github.com/hashicorp/boundary/testing/internal/e2e/tests/base_with_postgres"
|
||||
docker_mirror = var.docker_mirror
|
||||
network_name = step.create_docker_network.network_name
|
||||
go_version = var.go_version
|
||||
debug_no_run = var.e2e_debug_no_run
|
||||
alb_boundary_api_addr = step.create_boundary.address
|
||||
auth_method_id = step.create_boundary.auth_method_id
|
||||
auth_login_name = step.create_boundary.login_name
|
||||
auth_password = step.create_boundary.password
|
||||
local_boundary_dir = step.build_boundary_docker_image.cli_zip_path
|
||||
local_boundary_src_dir = local.local_boundary_src_dir
|
||||
aws_ssh_private_key_path = local.aws_ssh_private_key_path
|
||||
target_address = step.create_boundary_database.container_name
|
||||
target_port = step.create_boundary_database.port
|
||||
target_user = "ubuntu"
|
||||
postgres_user = step.create_boundary_database.user
|
||||
postgres_password = step.create_boundary_database.password
|
||||
postgres_database_name = step.create_boundary_database.database_name
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -130,7 +130,7 @@ scenario "e2e_docker_base_with_vault" {
|
||||
local_boundary_dir = step.build_boundary_docker_image.cli_zip_path
|
||||
local_boundary_src_dir = local.local_boundary_src_dir
|
||||
aws_ssh_private_key_path = local.aws_ssh_private_key_path
|
||||
target_ip = step.create_host.address
|
||||
target_address = step.create_host.address
|
||||
target_port = step.create_host.port
|
||||
target_user = "ubuntu"
|
||||
vault_addr = step.create_vault.address
|
||||
|
||||
@@ -118,7 +118,7 @@ scenario "e2e_docker_base" {
|
||||
local_boundary_dir = step.build_boundary_docker_image.cli_zip_path
|
||||
local_boundary_src_dir = local.local_boundary_src_dir
|
||||
aws_ssh_private_key_path = local.aws_ssh_private_key_path
|
||||
target_ip = step.create_host.address
|
||||
target_address = step.create_host.address
|
||||
target_port = step.create_host.port
|
||||
target_user = "ubuntu"
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ scenario "e2e_ui" {
|
||||
local_boundary_dir = local.local_boundary_dir
|
||||
local_boundary_ui_src_dir = local.local_boundary_ui_src_dir
|
||||
aws_ssh_private_key_path = local.aws_ssh_private_key_path
|
||||
target_ip = step.create_targets_with_tag1.target_ips[0]
|
||||
target_address = step.create_targets_with_tag1.target_ips[0]
|
||||
target_user = "ubuntu"
|
||||
target_port = "22"
|
||||
vault_addr = step.create_vault_cluster.instance_public_ips[0]
|
||||
|
||||
@@ -43,6 +43,11 @@ variable "database_name" {
|
||||
type = string
|
||||
default = "boundarydb"
|
||||
}
|
||||
variable "port" {
|
||||
description = "Docker container port to use"
|
||||
type = number
|
||||
default = 5432
|
||||
}
|
||||
|
||||
resource "docker_image" "postgres" {
|
||||
name = var.image_name
|
||||
@@ -63,8 +68,8 @@ resource "docker_container" "postgres" {
|
||||
container_path = "/etc/postgresql/"
|
||||
}
|
||||
ports {
|
||||
internal = 5432
|
||||
external = 5432
|
||||
internal = var.port
|
||||
external = var.port
|
||||
}
|
||||
healthcheck {
|
||||
test = ["CMD", "pg_isready", "-U", "${var.user}", "-d", "${var.database_name}"]
|
||||
@@ -93,3 +98,23 @@ resource "enos_local_exec" "wait" {
|
||||
output "address" {
|
||||
value = "postgres://${var.user}:${var.password}@${var.container_name}:5432/${var.database_name}?sslmode=disable"
|
||||
}
|
||||
|
||||
output "user" {
|
||||
value = var.user
|
||||
}
|
||||
|
||||
output "password" {
|
||||
value = var.password
|
||||
}
|
||||
|
||||
output "database_name" {
|
||||
value = var.database_name
|
||||
}
|
||||
|
||||
output "port" {
|
||||
value = var.port
|
||||
}
|
||||
|
||||
output "container_name" {
|
||||
value = var.container_name
|
||||
}
|
||||
@@ -52,8 +52,8 @@ variable "aws_ssh_private_key_path" {
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
variable "target_ip" {
|
||||
description = "IP address of target"
|
||||
variable "target_address" {
|
||||
description = "Address of target"
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
@@ -157,9 +157,9 @@ resource "enos_local_exec" "run_e2e_test" {
|
||||
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_ip,
|
||||
E2E_TARGET_ADDRESS = var.target_address,
|
||||
E2E_TARGET_PORT = var.target_port,
|
||||
E2E_SSH_USER = var.target_user,
|
||||
E2E_SSH_PORT = var.target_port,
|
||||
E2E_SSH_KEY_PATH = local.aws_ssh_private_key_path,
|
||||
E2E_SSH_CA_KEY = "",
|
||||
VAULT_ADDR = local.vault_addr,
|
||||
|
||||
@@ -80,8 +80,8 @@ variable "aws_ssh_private_key_path" {
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
variable "target_ip" {
|
||||
description = "IP address of target"
|
||||
variable "target_address" {
|
||||
description = "Address of target"
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
@@ -164,6 +164,18 @@ variable "worker_tags" {
|
||||
type = list(string)
|
||||
default = [""]
|
||||
}
|
||||
variable "postgres_user" {
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
variable "postgres_password" {
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
variable "postgres_database_name" {
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
variable "test_timeout" {
|
||||
type = string
|
||||
default = "15m"
|
||||
@@ -203,9 +215,9 @@ resource "enos_local_exec" "run_e2e_test" {
|
||||
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_ip,
|
||||
E2E_TARGET_ADDRESS = var.target_address,
|
||||
E2E_TARGET_PORT = var.target_port,
|
||||
E2E_SSH_USER = var.target_user,
|
||||
E2E_SSH_PORT = var.target_port,
|
||||
E2E_SSH_KEY_PATH = local.aws_ssh_private_key_path,
|
||||
E2E_SSH_CA_KEY = var.target_ca_key,
|
||||
VAULT_ADDR = local.vault_addr,
|
||||
@@ -221,6 +233,9 @@ resource "enos_local_exec" "run_e2e_test" {
|
||||
E2E_AWS_REGION = var.aws_region,
|
||||
E2E_AWS_BUCKET_NAME = var.aws_bucket_name,
|
||||
E2E_WORKER_TAG = jsonencode(var.worker_tags),
|
||||
E2E_POSTGRES_USER = var.postgres_user
|
||||
E2E_POSTGRES_PASSWORD = var.postgres_password
|
||||
E2E_POSTGRES_DB_NAME = var.postgres_database_name
|
||||
BOUNDARY_DIR = abspath(var.local_boundary_src_dir),
|
||||
BOUNDARY_CLI_DIR = abspath(var.local_boundary_dir),
|
||||
MODULE_DIR = abspath(path.module)
|
||||
|
||||
@@ -13,7 +13,8 @@ apt update
|
||||
# unzip is used to unzip boundary.zip
|
||||
# pass is used to store the auth token from `boundary authenticate``
|
||||
# lsb-release is used for adding the hashicorp apt source
|
||||
apt install unzip pass lsb-release -y
|
||||
# postgresql is used for postgres tests
|
||||
apt install unzip pass lsb-release postgresql-client -y
|
||||
|
||||
# Create a GPG key
|
||||
export KEY_PW=boundary
|
||||
|
||||
@@ -17,9 +17,9 @@ docker run \
|
||||
-e "E2E_PASSWORD_AUTH_METHOD_ID=$E2E_PASSWORD_AUTH_METHOD_ID" \
|
||||
-e "E2E_PASSWORD_ADMIN_LOGIN_NAME=$E2E_PASSWORD_ADMIN_LOGIN_NAME" \
|
||||
-e "E2E_PASSWORD_ADMIN_PASSWORD=$E2E_PASSWORD_ADMIN_PASSWORD" \
|
||||
-e "E2E_TARGET_IP=$E2E_TARGET_IP" \
|
||||
-e "E2E_TARGET_ADDRESS=$E2E_TARGET_ADDRESS" \
|
||||
-e "E2E_SSH_USER=$E2E_SSH_USER" \
|
||||
-e "E2E_SSH_PORT=$E2E_SSH_PORT" \
|
||||
-e "E2E_TARGET_PORT=$E2E_TARGET_PORT" \
|
||||
-e "E2E_SSH_CA_KEY=$E2E_SSH_CA_KEY" \
|
||||
-e "E2E_SSH_KEY_PATH=/keys/target.pem" \
|
||||
-e "VAULT_ADDR=$VAULT_ADDR_INTERNAL" \
|
||||
@@ -33,6 +33,9 @@ docker run \
|
||||
-e "E2E_AWS_HOST_SET_IPS2=$E2E_AWS_HOST_SET_IPS2" \
|
||||
-e "E2E_AWS_REGION=$E2E_AWS_REGION" \
|
||||
-e "E2E_AWS_BUCKET_NAME=$E2E_AWS_BUCKET_NAME" \
|
||||
-e "E2E_POSTGRES_USER=$E2E_POSTGRES_USER" \
|
||||
-e "E2E_POSTGRES_PASSWORD=$E2E_POSTGRES_PASSWORD" \
|
||||
-e "E2E_POSTGRES_DB_NAME=$E2E_POSTGRES_DB_NAME" \
|
||||
-e "E2E_WORKER_TAG=$E2E_WORKER_TAG" \
|
||||
--mount type=bind,src=$BOUNDARY_DIR,dst=/src/boundary/ \
|
||||
--mount type=bind,src=$MODULE_DIR/../..,dst=/testlogs \
|
||||
|
||||
@@ -52,8 +52,8 @@ variable "aws_ssh_private_key_path" {
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
variable "target_ip" {
|
||||
description = "IP address of target"
|
||||
variable "target_address" {
|
||||
description = "Address of target"
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
@@ -132,9 +132,9 @@ resource "enos_local_exec" "run_e2e_ui_test" {
|
||||
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_ip,
|
||||
E2E_TARGET_ADDRESS = var.target_address,
|
||||
E2E_TARGET_PORT = var.target_port,
|
||||
E2E_SSH_USER = var.target_user,
|
||||
E2E_SSH_PORT = var.target_port,
|
||||
E2E_SSH_KEY_PATH = local.aws_ssh_private_key_path,
|
||||
VAULT_ADDR = local.vault_addr,
|
||||
VAULT_TOKEN = var.vault_root_token,
|
||||
|
||||
Reference in new issue
Block a user