Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / test / mgr / mgr-dashboard-smoke.sh
1 #!/bin/bash
2 #
3 # Copyright (C) 2014,2015,2017 Red Hat <contact@redhat.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU Library Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
8 # any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU Library Public License for more details.
14 #
15 source $(dirname $0)/../detect-build-env-vars.sh
16 source $CEPH_ROOT/qa/standalone/ceph-helpers.sh
17
18 function run() {
19     local dir=$1
20
21     setup $dir || return 1
22
23     MON=127.0.0.1:7150  # git grep '\<7150\>' : there must be only one
24     (
25         FSID=$(uuidgen) 
26         export CEPH_ARGS
27         CEPH_ARGS+="--fsid=$FSID --auth-supported=none "
28         CEPH_ARGS+="--mon-initial-members=a --mon-host=$MON "
29         CEPH_ARGS+="--mgr-initial-modules=dashbaord "
30         CEPH_ARGS+="--mon-host=$MON"
31         run_mon $dir a --public-addr $MON || return 1
32     )
33
34     timeout 360 ceph --mon-host $MON mon stat || return 1
35     export CEPH_ARGS="--mon_host $MON "
36     ceph config-key set mgr/x/dashboard/server_port 7001
37     MGR_ARGS+="--mgr_module_path=${CEPH_ROOT}/src/pybind/mgr "
38     run_mgr $dir x ${MGR_ARGS} || return 1
39
40     tries=0
41     while [[ $tries < 30 ]] ; do
42         if [ $(ceph status -f json | jq .mgrmap.available) = "true" ]
43         then
44             break
45         fi
46         tries=$((tries+1))
47         sleep 1
48     done
49
50     tries=0
51     while [[ $tries < 30 ]] ; do
52         if [ curl -s http://127.0.0.1:7001/toplevel_data | \
53              jq '.health.overall_status' | grep HEALTH_ ]
54         then
55             break
56         fi
57         tries=$((tries+1))
58         sleep 0.5
59     done
60
61     teardown $dir || return 1
62 }
63
64 main mgr-dashboard-smoke "$@"
65
66 # Local Variables:
67 # compile-command: "cd ../.. ; make -j4 TESTS=test/mon/mon-dashboard-smoke.sh check"
68 # End: