test(e2e): Add test for worker-led worker registration (#4014)
* refact(e2e): Create module to run boundary commands * test(e2e): Add worker-led registration test
This commit is contained in:
1 parent
527c383ea3
commit
b0127116f3
13 files changed
+432
-66
No files matched your search
+10
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env sh
|
||||
# Copyright (c) HashiCorp, Inc.
|
||||
# SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
set -eu -o pipefail
|
||||
|
||||
boundary workers create worker-led \
|
||||
-worker-generated-auth-token $WORKER_TOKEN \
|
||||
-token env://BOUNDARY_TOKEN \
|
||||
-format json
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env sh
|
||||
# Copyright (c) HashiCorp, Inc.
|
||||
# SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
set -eu -o pipefail
|
||||
|
||||
boundary authenticate password \
|
||||
-login-name $LOGIN_NAME \
|
||||
-password env://BPASS \
|
||||
-format json
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env sh
|
||||
# Copyright (c) HashiCorp, Inc.
|
||||
# SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
set -eu -o pipefail
|
||||
|
||||
boundary workers create controller-led \
|
||||
-token env://BOUNDARY_TOKEN \
|
||||
-format json
|
||||
@@ -0,0 +1,78 @@
|
||||
# Copyright (c) HashiCorp, Inc.
|
||||
# SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
terraform {
|
||||
required_providers {
|
||||
enos = {
|
||||
source = "app.terraform.io/hashicorp-qti/enos"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
variable "address" {
|
||||
description = "Address/URL to the Boundary controller/server"
|
||||
type = string
|
||||
}
|
||||
variable "image_name" {
|
||||
description = "Name of docker image to use"
|
||||
type = string
|
||||
}
|
||||
variable "network_name" {
|
||||
description = "Name of docker network to use"
|
||||
type = string
|
||||
}
|
||||
variable "login_name" {
|
||||
description = "Login Name to log in to boundary"
|
||||
type = string
|
||||
}
|
||||
variable "password" {
|
||||
description = "Password to log in to boundary"
|
||||
type = string
|
||||
}
|
||||
variable "script" {
|
||||
description = "Filename of a script in the module directory to run"
|
||||
type = string
|
||||
}
|
||||
variable "worker_token" {
|
||||
description = "Worker generated auth token"
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
|
||||
resource "enos_local_exec" "get_auth_token" {
|
||||
environment = {
|
||||
TEST_BOUNDARY_IMAGE = var.image_name
|
||||
BOUNDARY_ADDR = var.address
|
||||
TEST_NETWORK_NAME = var.network_name
|
||||
E2E_PASSWORD_ADMIN_LOGIN_NAME = var.login_name
|
||||
E2E_PASSWORD_ADMIN_PASSWORD = var.password
|
||||
MODULE_DIR = abspath(path.module)
|
||||
SCRIPT = "${abspath(path.module)}/get_auth_token.sh"
|
||||
}
|
||||
inline = ["bash ./${path.module}/script_runner.sh"]
|
||||
}
|
||||
|
||||
locals {
|
||||
auth_info = jsondecode(enos_local_exec.get_auth_token.stdout)
|
||||
auth_token = local.auth_info["item"]["attributes"]["token"]
|
||||
}
|
||||
|
||||
resource "enos_local_exec" "run_script" {
|
||||
depends_on = [enos_local_exec.get_auth_token]
|
||||
environment = {
|
||||
TEST_BOUNDARY_IMAGE = var.image_name
|
||||
BOUNDARY_ADDR = var.address
|
||||
TEST_NETWORK_NAME = var.network_name
|
||||
E2E_PASSWORD_ADMIN_LOGIN_NAME = var.login_name
|
||||
E2E_PASSWORD_ADMIN_PASSWORD = var.password
|
||||
MODULE_DIR = abspath(path.module)
|
||||
SCRIPT = "${abspath(path.module)}/${var.script}"
|
||||
BOUNDARY_TOKEN = local.auth_token
|
||||
WORKER_TOKEN = var.worker_token
|
||||
}
|
||||
inline = ["bash ./${path.module}/script_runner.sh"]
|
||||
}
|
||||
|
||||
output "output" {
|
||||
value = jsondecode(enos_local_exec.run_script.stdout)
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright (c) HashiCorp, Inc.
|
||||
# SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
# This script initializes a postgres database to work with Boundary by spinning up a temporary
|
||||
# Boundary docker container pointed to the specified database and invoking `boundary database init`.
|
||||
#
|
||||
# This script must only output the JSON that comes from `boundary database init` as the output is
|
||||
# consumed by other scripts.
|
||||
|
||||
TEST_CONTAINER_NAME=boundary-script-runner
|
||||
SOURCE=$(realpath $(dirname ${BASH_SOURCE[0]})) # get directory of this script
|
||||
|
||||
docker run \
|
||||
--rm \
|
||||
--name $TEST_CONTAINER_NAME \
|
||||
-e "BOUNDARY_ADDR=$BOUNDARY_ADDR" \
|
||||
-e "LOGIN_NAME=$E2E_PASSWORD_ADMIN_LOGIN_NAME" \
|
||||
-e "BPASS=$E2E_PASSWORD_ADMIN_PASSWORD" \
|
||||
-e "BOUNDARY_TOKEN=$BOUNDARY_TOKEN" \
|
||||
-e "WORKER_TOKEN=$WORKER_TOKEN" \
|
||||
-e "SKIP_CHOWN=true" \
|
||||
--cap-add IPC_LOCK \
|
||||
--network $TEST_NETWORK_NAME \
|
||||
-v "$SCRIPT:/script.sh" \
|
||||
$TEST_BOUNDARY_IMAGE \
|
||||
/bin/sh -c /script.sh
|
||||
Reference in new issue
Block a user