]> git.proxmox.com Git - ceph.git/blob - ceph/src/test/mgr/mgr-dashboard-smoke.sh
update source to Ceph Pacific 16.2.2
[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 mon_port=$(get_unused_port)
20 dashboard_port=$((mon_port+1))
21
22 function run() {
23 local dir=$1
24 shift
25
26 export CEPH_MON=127.0.0.1:$mon_port
27 export CEPH_ARGS
28 CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
29 CEPH_ARGS+="--mon-initial-members=a --mon-host=$MON "
30 CEPH_ARGS+="--mgr-initial-modules=dashboard "
31 CEPH_ARGS+="--mon-host=$CEPH_MON"
32
33 setup $dir || return 1
34 TEST_dashboard $dir || return 1
35 teardown $dir || return 1
36 }
37
38 function TEST_dashboard() {
39 local dir=$1
40 shift
41
42 run_mon $dir a || return 1
43 timeout 30 ceph mon stat || return 1
44 ceph config-key set mgr/dashboard/x/server_port $dashboard_port
45 MGR_ARGS+="--mgr_module_path=${CEPH_ROOT}/src/pybind/mgr "
46 run_mgr $dir x ${MGR_ARGS} || return 1
47
48 tries=0
49 while [[ $tries < 30 ]] ; do
50 if [ $(ceph status -f json | jq .mgrmap.available) = "true" ]
51 then
52 break
53 fi
54 tries=$((tries+1))
55 sleep 1
56 done
57
58 DASHBOARD_ADMIN_SECRET_FILE="/tmp/dashboard-admin-secret.txt"
59 printf 'admin' > "${DASHBOARD_ADMIN_SECRET_FILE}"
60 ceph_adm dashboard ac-user-create admin -i "${DASHBOARD_ADMIN_SECRET_FILE}" --force-password
61
62 tries=0
63 while [[ $tries < 30 ]] ; do
64 if curl -c $dir/cookiefile -X POST -d '{"username":"admin","password":"admin"}' http://127.0.0.1:$dashboard_port/api/auth
65 then
66 if curl -b $dir/cookiefile -s http://127.0.0.1:$dashboard_port/api/summary | \
67 jq '.health.overall_status' | grep HEALTH_
68 then
69 break
70 fi
71 fi
72 tries=$((tries+1))
73 sleep 0.5
74 done
75 }
76
77 main mgr-dashboard-smoke "$@"
78
79 # Local Variables:
80 # compile-command: "cd ../.. ; make -j4 TESTS=test/mgr/mgr-dashboard-smoke.sh check"
81 # End: