forked from canonical/opensearch-snap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-dev-cluster.sh
68 lines (53 loc) · 1.67 KB
/
test-dev-cluster.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
#!/usr/bin/env bash
set -eu
usage() {
cat << EOF
usage: test-dev-cluster.sh --admin-auth-password admin
Tests if the OpenSearch cluster is well configured.
--admin-auth-password (Optional) Password for basic auth with the opensearch rest api, default "admin"
--help Shows help menu
EOF
}
# Args
admin_auth_password=""
# Args handling
function parse_args () {
# init-security boolean - from the charm, this should be based on a flag on the app data bag.
local LONG_OPTS_LIST=(
"admin-auth-password"
"help"
)
local opts=$(getopt \
--longoptions "$(printf "%s:," "${LONG_OPTS_LIST[@]}")" \
--name "$(readlink -f "${BASH_SOURCE}")" \
--options "" \
-- "$@"
)
eval set -- "${opts}"
while [ $# -gt 0 ]; do
case $1 in
--admin-auth-password) shift
admin_auth_password=$1
;;
--help) usage
exit
;;
esac
shift
done
}
function run_tests () {
# Check if cluster is healthy (green):
echo "Running: test-cluster-health-green..."
sudo snap run opensearch.test-cluster-health-green --admin-auth-password "${admin_auth_password}"
echo -e "\n\n---------------\n\n"
# Check if node is up:
echo "Running: test-node-up..."
sudo snap run opensearch.test-node-up --admin-auth-password "${admin_auth_password}"
echo -e "\n\n---------------\n\n"
# Check if the security index is well initialised:
echo "Running: test-security-index-created..."
sudo snap run opensearch.test-security-index-created --admin-auth-password "${admin_auth_password}"
}
parse_args "$@"
run_tests