From 56d3a1889376786e4e90135e7bf5b8bf91104430 Mon Sep 17 00:00:00 2001 From: Sandra Maria Peter <83961684+sandrampeter@users.noreply.github.com> Date: Thu, 30 Jun 2022 17:45:33 -0400 Subject: [PATCH 1/3] add sleep time (#182) --- tests/private-active-active/run-tests.sh | 2 ++ tests/private-tcp-active-active/run-tests.sh | 2 ++ tests/public-active-active/run-tests.sh | 2 ++ 3 files changed, 6 insertions(+) diff --git a/tests/private-active-active/run-tests.sh b/tests/private-active-active/run-tests.sh index 70cb886e..40d4b050 100644 --- a/tests/private-active-active/run-tests.sh +++ b/tests/private-active-active/run-tests.sh @@ -114,6 +114,8 @@ if [[ -z "$skip_init" ]]; then export TFE_EMAIL=tf-onprem-team@hashicorp.com export http_proxy=socks5://localhost:5000/ export https_proxy=socks5://localhost:5000/" > .env.sh + echo "Sleeping for 3 minutes to ensure that both instances are ready." + sleep 180 fi source .env.sh diff --git a/tests/private-tcp-active-active/run-tests.sh b/tests/private-tcp-active-active/run-tests.sh index 303b659e..b4d57dfc 100644 --- a/tests/private-tcp-active-active/run-tests.sh +++ b/tests/private-tcp-active-active/run-tests.sh @@ -115,6 +115,8 @@ if [[ -z "$skip_init" ]]; then export TFE_EMAIL=tf-onprem-team@hashicorp.com export http_proxy=socks5://localhost:5000/ export https_proxy=socks5://localhost:5000/" > .env.sh + echo "Sleeping for 3 minutes to ensure that both instances are ready." + sleep 180 fi source .env.sh diff --git a/tests/public-active-active/run-tests.sh b/tests/public-active-active/run-tests.sh index ca78390f..b40f5cab 100644 --- a/tests/public-active-active/run-tests.sh +++ b/tests/public-active-active/run-tests.sh @@ -103,6 +103,8 @@ if [[ -z "$skip_init" ]]; then export TFE_EMAIL=tf-onprem-team@hashicorp.com export http_proxy=socks5://localhost:5000/ export https_proxy=socks5://localhost:5000/" > .env.sh + echo "Sleeping for 3 minutes to ensure that both instances are ready." + sleep 180 fi source .env.sh From c9ddac8fb6d339bd725559205a77f4e343389ca9 Mon Sep 17 00:00:00 2001 From: Sandra Maria Peter <83961684+sandrampeter@users.noreply.github.com> Date: Tue, 5 Jul 2022 12:53:42 -0400 Subject: [PATCH 2/3] No proxy for public tests (#183) * add sleep time * dig only for public * sensitive data --- tests/private-active-active/run-tests.sh | 1 - tests/private-tcp-active-active/run-tests.sh | 1 - tests/public-active-active/run-tests.sh | 6 ++---- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/private-active-active/run-tests.sh b/tests/private-active-active/run-tests.sh index 40d4b050..ded8b376 100644 --- a/tests/private-active-active/run-tests.sh +++ b/tests/private-active-active/run-tests.sh @@ -104,7 +104,6 @@ if [[ -z "$skip_init" ]]; then --proxy socks5://localhost:5000 \ "$admin_url"?token="$iact_token") - echo "$response" tfe_token=$(echo "$response" | jq --raw-output '.token') rm -f payload.json diff --git a/tests/private-tcp-active-active/run-tests.sh b/tests/private-tcp-active-active/run-tests.sh index b4d57dfc..96f2b32b 100644 --- a/tests/private-tcp-active-active/run-tests.sh +++ b/tests/private-tcp-active-active/run-tests.sh @@ -104,7 +104,6 @@ if [[ -z "$skip_init" ]]; then --proxy socks5://localhost:5000 \ "$admin_url"?token="$iact_token") - echo "$response" tfe_token=$(echo "$response" | jq --raw-output '.token') rm -f payload.json diff --git a/tests/public-active-active/run-tests.sh b/tests/public-active-active/run-tests.sh index b40f5cab..1b4230ca 100644 --- a/tests/public-active-active/run-tests.sh +++ b/tests/public-active-active/run-tests.sh @@ -93,17 +93,15 @@ if [[ -z "$skip_init" ]]; then --request POST \ "$admin_url"?token="$iact_token") - echo "$response" tfe_token=$(echo "$response" | jq --raw-output '.token') rm -f payload.json echo "export K6_PATHNAME=$k6_path export TFE_URL=$tfe_url export TFE_API_TOKEN=$tfe_token - export TFE_EMAIL=tf-onprem-team@hashicorp.com - export http_proxy=socks5://localhost:5000/ - export https_proxy=socks5://localhost:5000/" > .env.sh + export TFE_EMAIL=tf-onprem-team@hashicorp.com" > .env.sh echo "Sleeping for 3 minutes to ensure that both instances are ready." + sleep 180 fi From d25776338947069621938e8b9e306ebb9f93cfc7 Mon Sep 17 00:00:00 2001 From: Sandra Maria Peter <83961684+sandrampeter@users.noreply.github.com> Date: Tue, 5 Jul 2022 17:57:08 -0400 Subject: [PATCH 3/3] Add run-tests.sh for standalone tests (#184) * adding test for standalone and minor changes --- tests/private-active-active/run-tests.sh | 5 - tests/private-tcp-active-active/run-tests.sh | 5 - tests/public-active-active/run-tests.sh | 2 - .../run-tests.sh | 108 ++++++++++++++++++ tests/standalone-mounted-disk/run-tests.sh | 108 ++++++++++++++++++ 5 files changed, 216 insertions(+), 12 deletions(-) create mode 100644 tests/standalone-external-rhel8-worker/run-tests.sh create mode 100644 tests/standalone-mounted-disk/run-tests.sh diff --git a/tests/private-active-active/run-tests.sh b/tests/private-active-active/run-tests.sh index ded8b376..24927b08 100644 --- a/tests/private-active-active/run-tests.sh +++ b/tests/private-active-active/run-tests.sh @@ -4,7 +4,6 @@ k6_path="" k6_tests_dir="" bastion_key_file="" skip_init="" -bind_to_localhost="" Help() { @@ -17,7 +16,6 @@ Help() echo "k (required) The path to the k6 binary." echo "t (required) The path to the tfe-load-test repository." echo "s (optional) Skip the admin user initialization and tfe token retrieval (This is useful for secondary / repeated test runs)." - echo "l (optional) Bind the test proxy to localhost instead of the detected ip address (This is useful when testing from within a docker container)." echo } @@ -34,8 +32,6 @@ while getopts ":hk:t:b:sl" option; do k6_tests_dir=$OPTARG;; s) # Skip the admin user boostrapping process? skip_init=1;; - l) # Bind test proxy to localhost - bind_to_localhost=1;; \?) # Invalid option echo "Error: Invalid option" exit;; @@ -59,7 +55,6 @@ Executing tests with the following configuration: k6_path=$k6_path k6_tests_dir=$k6_tests_dir skip_init=$skip_init - bind_to_localhost=$bind_to_localhost " SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )"; diff --git a/tests/private-tcp-active-active/run-tests.sh b/tests/private-tcp-active-active/run-tests.sh index 96f2b32b..1a2d7b23 100644 --- a/tests/private-tcp-active-active/run-tests.sh +++ b/tests/private-tcp-active-active/run-tests.sh @@ -4,7 +4,6 @@ k6_path="" k6_tests_dir="" bastion_key_file="" skip_init="" -bind_to_localhost="" Help() { @@ -17,7 +16,6 @@ Help() echo "k (required) The path to the k6 binary." echo "t (required) The path to the tfe-load-test repository." echo "s (optional) Skip the admin user initialization and tfe token retrieval (This is useful for secondary / repeated test runs)." - echo "l (optional) Bind the test proxy to localhost instead of the detected ip address (This is useful when testing from within a docker container)." echo } @@ -34,8 +32,6 @@ while getopts ":hk:t:b:sl" option; do k6_tests_dir=$OPTARG;; s) # Skip the admin user boostrapping process? skip_init=1;; - l) # Bind test proxy to localhost - bind_to_localhost=1;; \?) # Invalid option echo "Error: Invalid option" exit;; @@ -59,7 +55,6 @@ Executing tests with the following configuration: k6_path=$k6_path k6_tests_dir=$k6_tests_dir skip_init=$skip_init - bind_to_localhost=$bind_to_localhost " SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )"; diff --git a/tests/public-active-active/run-tests.sh b/tests/public-active-active/run-tests.sh index 1b4230ca..274f2038 100644 --- a/tests/public-active-active/run-tests.sh +++ b/tests/public-active-active/run-tests.sh @@ -4,7 +4,6 @@ k6_path="" k6_tests_dir="" bastion_key_file="" skip_init="" -bind_to_localhost="" Help() { @@ -56,7 +55,6 @@ Executing tests with the following configuration: k6_path=$k6_path k6_tests_dir=$k6_tests_dir skip_init=$skip_init - bind_to_localhost=$bind_to_localhost " SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )"; diff --git a/tests/standalone-external-rhel8-worker/run-tests.sh b/tests/standalone-external-rhel8-worker/run-tests.sh new file mode 100644 index 00000000..274f2038 --- /dev/null +++ b/tests/standalone-external-rhel8-worker/run-tests.sh @@ -0,0 +1,108 @@ +#!/bin/bash + +k6_path="" +k6_tests_dir="" +bastion_key_file="" +skip_init="" + +Help() +{ + # Display Help + echo "This script bootstraps the k6 / tfe-load-test environment and executes a smoke-test against an active TFE instance deployed with the terraform-azure-terraform-enterprise module." + echo + echo "Syntax: run-tests.sh [-h|k|t|s]" + echo "options:" + echo "h Print this Help." + echo "k (required) The path to the k6 binary." + echo "t (required) The path to the tfe-load-test repository." + echo "s (optional) Skip the admin user initialization and tfe token retrieval (This is useful for secondary / repeated test runs)." + echo +} + +# Get the options +while getopts ":hk:t:b:sl" option; do + case $option in + h) # display Help + Help + exit;; + k) # Enter a path to the k6 binary + k6_path=$OPTARG;; + + t) # Enter a path to the tfe-load-test repo + k6_tests_dir=$OPTARG;; + s) # Skip the admin user boostrapping process? + skip_init=1;; + \?) # Invalid option + echo "Error: Invalid option" + exit;; + esac +done + +if [[ -z "$k6_path" ]]; then + echo "k6 path missing. Please use the -k option." + Help + exit 1 +fi + +if [[ -z "$k6_tests_dir" ]]; then + echo "The tfe-load-test repository path missing. Please use the -t option." + Help + exit 1 +fi + +echo " +Executing tests with the following configuration: + k6_path=$k6_path + k6_tests_dir=$k6_tests_dir + skip_init=$skip_init +" + +SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )"; + +cd $SCRIPT_DIR +health_check_url=$(terraform output -no-color -raw health_check_url) +echo "health check url: $health_check_url" + +if [[ -z "$skip_init" ]]; then + while ! curl \ + -sfS --max-time 5 \ + $health_check_url; \ + do sleep 5; done + echo " : TFE is healthy and listening." + + tfe_url=$(terraform output -no-color -raw tfe_url) + echo "tfe url: $tfe_url" + iact_url=$(terraform output -no-color -raw iact_url) + echo "iact url: $iact_url" + echo "Fetching iact token.." + iact_token=$(curl --fail --retry 5 "$iact_url") + admin_url=`terraform output -no-color -raw initial_admin_user_url` + echo "admin url: $admin_url" + + TFE_USERNAME="test$(date +%s)" + TFE_PASSWORD=`openssl rand -base64 32` + echo "{\"username\": \"$TFE_USERNAME\", \"email\": \"tf-onprem-team@hashicorp.com\", \"password\": \"$TFE_PASSWORD\"}" \ > ./payload.json + + response=$(\ + curl \ + --retry 5 \ + --header 'Content-Type: application/json' \ + --data @./payload.json \ + --request POST \ + "$admin_url"?token="$iact_token") + + tfe_token=$(echo "$response" | jq --raw-output '.token') + rm -f payload.json + + echo "export K6_PATHNAME=$k6_path + export TFE_URL=$tfe_url + export TFE_API_TOKEN=$tfe_token + export TFE_EMAIL=tf-onprem-team@hashicorp.com" > .env.sh + echo "Sleeping for 3 minutes to ensure that both instances are ready." + + sleep 180 +fi + +source .env.sh +cd $k6_tests_dir +make smoke-test \ No newline at end of file diff --git a/tests/standalone-mounted-disk/run-tests.sh b/tests/standalone-mounted-disk/run-tests.sh new file mode 100644 index 00000000..274f2038 --- /dev/null +++ b/tests/standalone-mounted-disk/run-tests.sh @@ -0,0 +1,108 @@ +#!/bin/bash + +k6_path="" +k6_tests_dir="" +bastion_key_file="" +skip_init="" + +Help() +{ + # Display Help + echo "This script bootstraps the k6 / tfe-load-test environment and executes a smoke-test against an active TFE instance deployed with the terraform-azure-terraform-enterprise module." + echo + echo "Syntax: run-tests.sh [-h|k|t|s]" + echo "options:" + echo "h Print this Help." + echo "k (required) The path to the k6 binary." + echo "t (required) The path to the tfe-load-test repository." + echo "s (optional) Skip the admin user initialization and tfe token retrieval (This is useful for secondary / repeated test runs)." + echo +} + +# Get the options +while getopts ":hk:t:b:sl" option; do + case $option in + h) # display Help + Help + exit;; + k) # Enter a path to the k6 binary + k6_path=$OPTARG;; + + t) # Enter a path to the tfe-load-test repo + k6_tests_dir=$OPTARG;; + s) # Skip the admin user boostrapping process? + skip_init=1;; + \?) # Invalid option + echo "Error: Invalid option" + exit;; + esac +done + +if [[ -z "$k6_path" ]]; then + echo "k6 path missing. Please use the -k option." + Help + exit 1 +fi + +if [[ -z "$k6_tests_dir" ]]; then + echo "The tfe-load-test repository path missing. Please use the -t option." + Help + exit 1 +fi + +echo " +Executing tests with the following configuration: + k6_path=$k6_path + k6_tests_dir=$k6_tests_dir + skip_init=$skip_init +" + +SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )"; + +cd $SCRIPT_DIR +health_check_url=$(terraform output -no-color -raw health_check_url) +echo "health check url: $health_check_url" + +if [[ -z "$skip_init" ]]; then + while ! curl \ + -sfS --max-time 5 \ + $health_check_url; \ + do sleep 5; done + echo " : TFE is healthy and listening." + + tfe_url=$(terraform output -no-color -raw tfe_url) + echo "tfe url: $tfe_url" + iact_url=$(terraform output -no-color -raw iact_url) + echo "iact url: $iact_url" + echo "Fetching iact token.." + iact_token=$(curl --fail --retry 5 "$iact_url") + admin_url=`terraform output -no-color -raw initial_admin_user_url` + echo "admin url: $admin_url" + + TFE_USERNAME="test$(date +%s)" + TFE_PASSWORD=`openssl rand -base64 32` + echo "{\"username\": \"$TFE_USERNAME\", \"email\": \"tf-onprem-team@hashicorp.com\", \"password\": \"$TFE_PASSWORD\"}" \ > ./payload.json + + response=$(\ + curl \ + --retry 5 \ + --header 'Content-Type: application/json' \ + --data @./payload.json \ + --request POST \ + "$admin_url"?token="$iact_token") + + tfe_token=$(echo "$response" | jq --raw-output '.token') + rm -f payload.json + + echo "export K6_PATHNAME=$k6_path + export TFE_URL=$tfe_url + export TFE_API_TOKEN=$tfe_token + export TFE_EMAIL=tf-onprem-team@hashicorp.com" > .env.sh + echo "Sleeping for 3 minutes to ensure that both instances are ready." + + sleep 180 +fi + +source .env.sh +cd $k6_tests_dir +make smoke-test \ No newline at end of file