1
1
#! /usr/bin/env bash
2
2
set -euo pipefail
3
3
4
- AU_FROM_SEED=" true"
4
+ # AU_FROM_SEED="true"
5
5
# OS_IMAGE="Rocky9"
6
- TAINT_REBUILD=" true"
6
+ # TAINT_REBUILD="true"
7
7
8
8
echo " Starting AUFN test action with:"
9
9
echo " AU_FROM_SEED: $AU_FROM_SEED "
88
88
# echo >> failed-labs.txt
89
89
}
90
90
91
+ function validate_universe_from_seed() {
92
+ echo && echo
93
+ echo " Validating Lab VMs setup..."
94
+ index=0
95
+ rm -f failed-labs.txt
96
+
97
+ while IFS= read -r line; do
98
+ ip=$( echo " $line " | awk ' {print $3}' )
99
+ name=$( echo " $line " | awk ' {print $2}' )
100
+ password=$( echo " $line " | awk ' {print $5}' )
101
+
102
+ echo && echo
103
+ echo " Validating $name at $ip ..." && echo
104
+
105
+ sshpass -p " $password " ssh -o StrictHostKeyChecking=no\
106
+ " lab@${ip} " << 'EOF '
107
+ output=$(sudo virsh list --all)
108
+ echo "$output"
109
+ if ! echo "$output" | grep -q 'seed.*running'; then echo "'seed' not running"; fi
110
+ if ! echo "$output" | grep -q 'compute0.*running'; then echo "'compute0' not running"; fi
111
+ if ! echo "$output" | grep -q 'controller0.*running'; then echo "'controller0' not running"; fi
112
+
113
+ echo && echo
114
+ echo "$(ssh stack@192.168.33.5 'sudo docker ps')"
115
+ if ! ssh stack@192.168.33.5 'sudo docker ps' | grep -q bifrost_deploy; then echo "Bifrost container isn't deployed"; fi
116
+ if ! tail -n 1 a-universe-from-seed.out | grep -q 'demo1'; then echo "There was an error in running 'a-universe-from-seed'"; fi
117
+ EOF
118
+
119
+ set +e
120
+
121
+ sshpass -p " $password " ssh -o StrictHostKeyChecking=no \
122
+ " lab@${ip} " << 'EOF '
123
+ output=$(sudo virsh list --all)
124
+ if ! echo "$output" | grep -q 'seed.*running'; then exit 1; fi
125
+ if ! echo "$output" | grep -q 'compute0.*running'; then exit 1; fi
126
+ if ! echo "$output" | grep -q 'controller0.*running'; then exit 1; fi
127
+
128
+ if ! ssh stack@192.168.33.5 'sudo docker ps' | grep -q bifrost_deploy; then exit 1; fi
129
+ if ! tail -n 1 a-universe-from-seed.out | grep -q 'demo1'; then exit 1; fi
130
+
131
+ exit 0
132
+ EOF
133
+ taint_res=$?
134
+ echo " exit error is -> $taint_res "
135
+ if [ $taint_res -gt 0 ]; then echo " $index " >> failed-labs.txt ; fi
136
+ index=$(( index + 1 ))
137
+ set -euo pipefail
138
+ done < ssh_list.txt
139
+ # echo >> failed-labs.txt
140
+ }
141
+
142
+
91
143
function taint_and_reapply() {
92
144
if [ ! -s failed-labs.txt ]; then
93
145
echo " No failed VMs detected"
@@ -107,50 +159,47 @@ function taint_and_reapply() {
107
159
108
160
# function run_universe_from_seed() {
109
161
# if [[ "$AU_FROM_SEED" != "true" ]]; then return; fi
110
- # echo "Launching a-universe-from-seed..."
111
- # mapfile -t ssh_lines < ssh_list.txt
112
- # for i in "${!ssh_lines[@]}"; do
113
- # line="${ssh_lines[$i]}"
162
+ # echo "Running a-universe-from-seed..."
163
+ # while IFS= read -r line; do
114
164
# ip=$(echo "$line" | awk '{print $3}')
115
165
# name=$(echo "$line" | awk '{print $2}')
116
166
# password=$(echo "$line" | awk '{print $5}')
117
167
118
168
# sshpass -p "$password" ssh -o StrictHostKeyChecking=no \
119
169
# "lab@${ip}" \
120
170
# "tmux new-session -d -s aus-run './a-universe-from-seed.sh'"
121
- # done
171
+ # done < ssh_list.txt
122
172
# }
123
173
124
- function run_universe_from_seed() {
125
- if [[ " $AU_FROM_SEED " != " true" ]]; then return ; fi
126
- echo " Launching a-universe-from-seed..."
127
- while IFS= read -r line; do
128
- ip=$( echo " $line " | awk ' {print $3}' )
129
- name=$( echo " $line " | awk ' {print $2}' )
130
- password=$( echo " $line " | awk ' {print $5}' )
131
174
132
- sshpass -p " $password " ssh -o StrictHostKeyChecking=no \
133
- " lab@${ip} " \
134
- " tmux new-session -d -s aus-run './a-universe-from-seed.sh'"
135
- done < ssh_list.txt
136
- }
137
175
138
176
# === RUN STEPS ===
139
177
sleep 90 # Wait for VMs to be ready
140
178
141
179
check_lab_vm_connections
142
- validate_lab_vms
143
180
181
+ if [[ " $AU_FROM_SEED " = " false" ]]; then
182
+ validate_lab_vms
183
+ else
184
+ validate_universe_from_seed
185
+ fi
144
186
145
187
if [[ " $TAINT_REBUILD " = " true" && ! -s failed-labs.txt ]]; then
146
188
taint_and_reapply
189
+
147
190
terraform output -json > tf-outputs.json
148
191
terraform output -raw labs > ssh_list.txt
149
- validate_lab_vms
192
+ sed -i ' s/"//g' ssh_list.txt
193
+ echo >> ssh_list.txt
194
+
195
+ if [[ " $AU_FROM_SEED " = " false" ]]; then
196
+ validate_lab_vms
197
+ else
198
+ validate_universe_from_seed
199
+ fi
200
+
150
201
else
151
202
echo " Tainting and rebuilding is disabled, skipping..."
152
203
fi
153
204
154
- run_universe_from_seed
155
-
156
205
echo " AUFN Test completed successfully!"
0 commit comments