-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest-workflows.sh
executable file
·105 lines (80 loc) · 2.35 KB
/
test-workflows.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
set -e
usage() {
cat <<EOF
Test Disaster Recovery GitHub Actions workflows as a whole and ensure the data integrity.
Steps:
1. trigger 'deploy.yml' workflow.
2. create a set of test Keycloak realms via Gold Keycloak API.
3. trigger 'switch-to-golddr.yml' workflow.
4. ensure test Keycloak realms created by Gold Keycloak are found in Golddr Keycloak.
5. create a set of test Keycloak realms via Golddr Keycloak API.
6. trigger 'switch-to-gold.yml' workflow.
7. ensure test Keycloak realms created by Golddr Keycloak are found in Gold Keycloak.
Usages:
$0 <gh_token> <namespace>
Available namespaces:
- e4ca1d-dev
- e4ca1d-test
- e4ca1d-prod
Examples:
$ $0 ghp_xxxx e4ca1d-dev
EOF
}
if [ "$#" -lt 2 ]; then
usage
exit 1
fi
gh_token=$1
namespace=$2
pwd="$(dirname "$0")"
source "$pwd/helpers/_all.sh"
if [ "$(get_ocp_plate "$namespace")" != "e4ca1d" ]; then
error "must run test scripts in sandbox environments"
exit 1
fi
TEST_REALM_PREFIX="test-realm"
declare -a realms_gold=()
declare -a realms_golddr=()
i=0
while [ $i -ne 5 ]; do
i=$((i + 1))
realms_gold+=("$TEST_REALM_PREFIX-$i")
done
while [ $i -ne 5 ]; do
i=$((i + 1))
realms_golddr+=("$TEST_REALM_PREFIX-$i")
done
trigger_github_dispatcher "$gh_token" "deploy.yml" "$namespace" 300
ensure_kube_context "gold"
wait_for_keycloak_healthy "gold" "$namespace"
remove_all_realms "gold" "$namespace"
for realm in "${realms_gold[@]}"; do
create_keycloak_realm "gold" "$namespace" "$realm"
done
trigger_github_dispatcher "$gh_token" "switch-to-golddr.yml" "$namespace" 900
ensure_kube_context "golddr"
wait_for_keycloak_healthy "golddr" "$namespace"
for realm in "${realms_gold[@]}"; do
info "checking realm $realm..."
data=$(get_keycloak_realm "golddr" "$namespace" "$realm")
if [ -z "$data" ]; then
echo "$data"
exit 1
fi
done
for realm in "${realms_golddr[@]}"; do
create_keycloak_realm "golddr" "$namespace" "$realm"
done
trigger_github_dispatcher "$gh_token" "switch-to-gold.yml" "$namespace" 900
ensure_kube_context "gold"
wait_for_keycloak_healthy "gold" "$namespace"
for realm in "${realms_golddr[@]}"; do
info "checking realm $realm..."
data=$(get_keycloak_realm "gold" "$namespace" "$realm")
if [ -z "$data" ]; then
echo "$data"
exit 1
fi
done
info "done"