test(e2e): Improve reliability of enos docker scenario (#3167)

This commit is contained in:
Michael Li authored and GitHub committed 2023-04-19 17:03:38 -04:00
1 parent c5b1b7bbc7
commit d25f4493d3
7 files changed
+63 -10

No files matched your search

+1 -3
View File
@@ -8,8 +8,6 @@
# This script must only output the JSON that comes from `boundary database init` as the output is
# consumed by other scripts.
TEST_BOUNDARY_IMAGE=$1
TEST_DATABASE_ADDRESS=$2
TEST_CONTAINER_NAME=boundary-init
SOURCE=$(realpath $(dirname ${BASH_SOURCE[0]})) # get directory of this script
@@ -20,6 +18,6 @@ docker run \
-e "SKIP_CHOWN=true" \
--cap-add IPC_LOCK \
--mount type=bind,src=$SOURCE,dst=/boundary/ \
--network e2e_network \
--network $TEST_NETWORK_NAME \
$TEST_BOUNDARY_IMAGE \
boundary database init -config /boundary/boundary-config.hcl -format json
+15 -2
View File
@@ -44,7 +44,12 @@ resource "docker_image" "boundary" {
}
resource "enos_local_exec" "init_database" {
inline = ["bash ./${path.module}/init.sh \"${var.image_name}\" \"${var.postgres_address}\""]
environment = {
TEST_BOUNDARY_IMAGE = var.image_name,
TEST_DATABASE_ADDRESS = var.postgres_address,
TEST_NETWORK_NAME = var.network_name
}
inline = ["bash ./${path.module}/init.sh"]
}
locals {
@@ -102,7 +107,7 @@ resource "docker_container" "boundary" {
}
}
resource "enos_local_exec" "wait" {
resource "enos_local_exec" "check_address" {
depends_on = [
docker_container.boundary
]
@@ -110,6 +115,14 @@ resource "enos_local_exec" "wait" {
inline = ["timeout 10s bash -c 'until curl http://0.0.0.0:9200; do sleep 2; done'"]
}
resource "enos_local_exec" "check_health" {
depends_on = [
enos_local_exec.check_address
]
inline = ["timeout 10s bash -c 'until curl -i http://0.0.0.0:9203/health; do sleep 2; done'"]
}
output "address" {
value = "http://0.0.0.0:9200"
}