-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·118 lines (103 loc) · 3.35 KB
/
start.sh
File metadata and controls
executable file
·118 lines (103 loc) · 3.35 KB
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
117
118
#!/bin/bash
# Bank of Anthos - Failure Scenarios Injection System
# Main entry point providing a unified interface for batch scenario operations
set -euo pipefail
# Get the script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Source common helper functions
# shellcheck source=lib/common-helpers.sh
source "${SCRIPT_DIR}/lib/common-helpers.sh"
# Function to display main menu
display_menu() {
echo ""
echo "=========================================="
echo " Failure Scenarios Scenario Management"
echo "=========================================="
echo ""
echo "Setup & Deployment:"
echo " 1) Setup All Scenarios - Deploy Bank of Anthos to all scenario namespaces"
echo " 2) Check All Scenarios - Check status of all scenario namespaces"
echo ""
echo "Failure Injection:"
echo " 3) Inject All Scenarios - Inject failures in all namespaces (parallel)"
echo " 4) Inject by Namespace - Inject failure in specific namespace (interactive)"
echo ""
echo "Restoration:"
echo " 5) Restore All Scenarios - Restore all namespaces to normal state (parallel)"
echo " 6) Restore by Namespace - Restore specific namespace (interactive)"
echo ""
echo "Cleanup:"
echo " 7) Cleanup All Scenarios - Delete all scenario namespaces (parallel)"
echo ""
echo " 8) Exit"
echo ""
echo -n "Enter your choice [1-8]: "
}
# Function to run a script and wait for user
run_script() {
local script_path=$1
local script_name=$(basename "$script_path")
echo ""
print_info "Launching: ${script_name}"
echo ""
# Run the script
"$script_path"
local exit_code=$?
echo ""
if [ $exit_code -eq 0 ]; then
print_success "${script_name} completed successfully"
else
print_error "${script_name} failed with exit code ${exit_code}"
fi
echo ""
echo "Press Enter to return to menu..."
read -r
}
# Main script execution
main() {
# Check if batch directory exists
if [ ! -d "${SCRIPT_DIR}/batch" ]; then
print_error "batch directory not found at ${SCRIPT_DIR}/batch"
exit 1
fi
while true; do
clear
display_menu
read -r choice
case $choice in
1)
run_script "${SCRIPT_DIR}/batch/setup-all-scenarios.sh"
;;
2)
run_script "${SCRIPT_DIR}/batch/check-all-scenarios.sh"
;;
3)
run_script "${SCRIPT_DIR}/batch/inject-all-scenarios.sh"
;;
4)
run_script "${SCRIPT_DIR}/batch/inject-failure-by-namespace.sh"
;;
5)
run_script "${SCRIPT_DIR}/batch/restore-all-scenarios.sh"
;;
6)
run_script "${SCRIPT_DIR}/batch/restore-by-namespace.sh"
;;
7)
run_script "${SCRIPT_DIR}/batch/cleanup-all-scenarios.sh"
;;
8)
print_info "Exiting..."
exit 0
;;
*)
print_error "Invalid choice. Please select 1-8."
echo ""
echo "Press Enter to continue..."
read -r
;;
esac
done
}
# Run main function
main "$@"