-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathtest_vaultron
executable file
·116 lines (101 loc) · 3.77 KB
/
test_vaultron
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
106
107
108
109
110
111
112
113
114
115
116
#!/bin/sh
# =======================================================================
# Basic Vaultron lifecycle functionality tests
# NB: This only properly tests a default OSS cluster with Consul storage.
#
# 1. Test ./unform
# 2. Test ./form
# 3. Test Terraform state presence
# 4. Test Consul server data directories presence after forming
# 5. Test Terraform configuration directory presence after forming
# 6. Test Terraform init, plan, apply log output presence after forming
# 7. Test Blazing Sword convenience script
# 8. Test ./unform
# 9. Test Terraform state presence after unforming
# 10. Test Consul server data directories presence after unforming
# 11. Test Terraform configuration directory presence after unforming
# 12. Test Terraform init, plan, apply log output presence after unforming
# =======================================================================
# shellcheck disable=SC1091,SC1117
export txtblu="\033[0;34m" # Blue
export txtgrn="\033[0;32m" # Green
export txtred="\033[0;31m" # Red
export txtylw="\033[0;33m" # Yellow
export txtwht="\033[0;37m" # White
export txtrst="\033[0m" # Text Reset
export CONSUL_HTTP_ADDR="localhost:8500"
export VAULT_ADDR="https://localhost:8200"
if ! ./unform; then
echo "[e] Error unforming any previous Vaultron."
exit 1
fi
if ! ./form; then
echo "${txtred}[e] Error forming Vaultron!${txtrst}"
exit 1
fi
for i in 0 1 2; do
if ! [ -d "./flavors/consul/consul/consuls$i" ]; then
echo "${txtred}[e] Missing directory consul/consuls$i after forming!${txtrst}";
exit 1
fi
if ! [ -d "./flavors/consul/consul/consulc$i" ]; then
echo "${txtred}[e] Missing directory consul/consulc$i after forming!${txtrst}";
exit 1
fi
if ! [ -d "./flavors/consul/vault/vault$i" ]; then
echo "${txtred}[e] Missing directory consul/vault$i after forming!${txtrst}";
exit 1
fi
done
if [ ! -f "./flavors/consul/tfstate/terraform.tfstate" ]; then
echo "${txtred}[e] No Terraform state generated after forming:${txtrst}"
echo "${txtred}tfstate/terraform.tfstate${txtrst}"
exit 1
fi
if [ ! -d "./flavors/consul/.terraform" ]; then
echo "${txtred}[e] No Terraform configuration directory after forming:${txtrst}"
echo "${txtred}.terraform${txtrst}"
exit 1
fi
for l in init plan apply; do
if [ -z "$(find ./flavors/consul/log -type f -name "tf-*-$l.log")" ]; then
echo "${txtred}[e] Should be at least one log file of the form:${txtrst}"
echo "${txtred}log/tf-*-$l.log${txtrst}"
exit 1
fi
done
if ! . ./ion_darts; then
echo "${txtred}[e] Error sourcing Ion Darts!${txtrst}"
exit 1
fi
if ! ./blazing_sword; then
echo "${txtred}[e] Error forming Blazing Sword!${txtrst}"
exit 1
fi
if ! ./unform; then
echo "${txtred}[e] Error unforming any previous Vaultron!${txtrst}"
exit 1
fi
if [ -f "./flavors/consul/tfstate/terraform.tfstate" ]; then
echo "${txtred}[e] Terraform state file still present after unforming!${txtrst}"
exit 1
fi
for i in 0 1 2; do
if [ -d "./flavors/consul/consul/consuls$i" ]; then
echo "${txtred}[e] Directory consul/consuls$i still present after unforming!${txtrst}"
exit 1
fi
if [ -d "./flavors/consul/consul/consulc$i" ]; then
echo "${txtred}[e] Directory consul/consulc$i still present after unforming!${txtrst}"
exit 1
fi
if [ -d "./flavors/consul/vault/vault$i" ]; then
echo "${txtred}[e] Directory consul/vault$i still present after unforming!${txtrst}"
exit 1
fi
done
if [ -z "$(find ./flavors/consul/log -type f -name "tf-*-destroy.log")" ]; then
echo "${txtred}[e] Should be at least one log file after destroy of the form:${txtrst}"
echo "${txtred}./flavors/consul/log/tf-*-destroy.log${txtrst}"
exit 1
fi