mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-29 09:42:25 +00:00
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:
@@ -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"]
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user