Update replication verification to check connection status (#18921)

* Update replication verification to check connection status

Signed-off-by: Jaymala Sinha <jaymala@hashicorp.com>

* Output replication status after verifying connection

Signed-off-by: Jaymala Sinha <jaymala@hashicorp.com>

---------

Signed-off-by: Jaymala Sinha <jaymala@hashicorp.com>
This commit is contained in:
Jaymala
2023-01-31 16:23:46 -05:00
committed by GitHub
parent b9bc687360
commit 748ee9c7d5
2 changed files with 15 additions and 4 deletions

View File

@@ -52,6 +52,7 @@ resource "enos_remote_exec" "verify_replication_on_primary" {
environment = {
VAULT_ADDR = "http://127.0.0.1:8200"
VAULT_INSTALL_DIR = var.vault_install_dir
REPLICATION_MODE = "primary"
}
scripts = ["${path.module}/scripts/verify-performance-replication.sh"]
@@ -76,6 +77,7 @@ resource "enos_remote_exec" "verify_replication_on_secondary" {
environment = {
VAULT_ADDR = "http://127.0.0.1:8200"
VAULT_INSTALL_DIR = var.vault_install_dir
REPLICATION_MODE = "secondary"
}
scripts = ["${path.module}/scripts/verify-performance-replication.sh"]

View File

@@ -28,17 +28,26 @@ retry() {
return 0
}
test -x "$binpath" || fail "unable to locate vault binary at $binpath"
check_pr_status() {
pr_status=$($binpath read -format=json sys/replication/performance/status)
cluster_state=$($binpath read -format=json sys/replication/performance/status | jq -r '.data.state')
if [[ "${REPLICATION_MODE}" == "primary" ]]; then
connection_status=$($binpath read -format=json sys/replication/performance/status | jq -r '.data.secondaries[0].connection_status')
else
connection_status=$($binpath read -format=json sys/replication/performance/status | jq -r '.data.primaries[0].connection_status')
fi
if [[ "$connection_status" == 'disconnected' ]]; then
fail "expected connection status to be connected"
fi
if [[ "$cluster_state" == 'idle' ]]; then
fail "expected cluster state to be not idle"
fi
}
test -x "$binpath" || fail "unable to locate vault binary at $binpath"
# Retry a few times because it can take some time for replication to sync
retry 5 check_pr_status
echo $pr_status
echo $($binpath read -format=json sys/replication/performance/status)