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