forked from hashicorp/vault
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[QT-554] Remove Terraform validations from Enos replication scenario (h…
…ashicorp#20570) Signed-off-by: Jaymala Sinha <[email protected]>
- Loading branch information
Jaymala
authored
May 12, 2023
1 parent
e9bcff0
commit 1d5325f
Showing
3 changed files
with
93 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 0 additions & 53 deletions
53
enos/modules/vault_verify_performance_replication/scripts/get-replication-status.sh
This file was deleted.
Oops, something went wrong.
75 changes: 75 additions & 0 deletions
75
enos/modules/vault_verify_performance_replication/scripts/verify-replication-status.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/usr/bin/env bash | ||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: MPL-2.0 | ||
|
||
|
||
# This script waits for the replication status to be established | ||
# then verifies the performance replication between primary and | ||
# secondary clusters | ||
|
||
set -e | ||
|
||
binpath=${VAULT_INSTALL_DIR}/vault | ||
|
||
function fail() { | ||
echo "$1" 1>&2 | ||
exit 1 | ||
} | ||
|
||
retry() { | ||
local retries=$1 | ||
shift | ||
local count=0 | ||
|
||
until "$@"; do | ||
exit=$? | ||
wait=$((2 ** count)) | ||
count=$((count + 1)) | ||
if [ "$count" -lt "$retries" ]; then | ||
sleep "$wait" | ||
else | ||
return "$exit" | ||
fi | ||
done | ||
} | ||
|
||
test -x "$binpath" || exit 1 | ||
|
||
check_pr_status() { | ||
pr_status=$($binpath read -format=json sys/replication/performance/status) | ||
cluster_state=$(echo $pr_status | jq -r '.data.state') | ||
connection_mode=$(echo $pr_status | jq -r '.data.mode') | ||
|
||
if [[ "$cluster_state" == 'idle' ]]; then | ||
fail "replication cluster state is $cluster_state" | ||
fi | ||
|
||
if [[ "$connection_mode" == "primary" ]]; then | ||
connection_status=$(echo $pr_status | jq -r '.data.secondaries[0].connection_status') | ||
if [[ "$connection_status" == 'disconnected' ]]; then | ||
fail "replication connection status of secondaries is $connection_status" | ||
fi | ||
secondary_cluster_addr=$(echo $pr_status | jq -r '.data.secondaries[0].cluster_address') | ||
if [[ "$secondary_cluster_addr" != "https://"${SECONDARY_LEADER_PRIV_IP}":8201" ]]; then | ||
fail "Expected secondary cluster address $SECONDARY_LEADER_PRIV_IP got $secondary_cluster_addr " | ||
fi | ||
else | ||
connection_status=$(echo $pr_status | jq -r '.data.primaries[0].connection_status') | ||
if [[ "$connection_status" == 'disconnected' ]]; then | ||
fail "replication connection status of secondaries is $connection_status" | ||
fi | ||
primary_cluster_addr=$(echo $pr_status | jq -r '.data.primaries[0].cluster_address') | ||
if [[ "$primary_cluster_addr" != "https://"${PRIMARY_LEADER_PRIV_IP}":8201" ]]; then | ||
fail "Expected primary cluster address $PRIMARY_LEADER_PRIV_IP got $primary_cluster_addr" | ||
fi | ||
known_primary_cluster_addrs=$(echo $pr_status | jq -r '.data.known_primary_cluster_addrs') | ||
# IFS="," read -a cluster_addr <<< ${known_primary_cluster_addrs} | ||
if ! $(echo $known_primary_cluster_addrs |grep -q $PRIMARY_LEADER_PRIV_IP); then | ||
fail "Primary leader address $PRIMARY_LEADER_PRIV_IP not found in Known primary cluster addresses $known_primary_cluster_addrs" | ||
fi | ||
fi | ||
echo $pr_status | ||
} | ||
|
||
# Retry a few times because it can take some time for replication to sync | ||
retry 5 check_pr_status |