]> git.proxmox.com Git - ceph.git/blame - 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
CommitLineData
11fdf7f2 1#!/usr/bin/env bash
31f18b77
FG
2#
3# Copyright (C) 2014,2015,2017 Red Hat <contact@redhat.com>
11fdf7f2 4# Copyright (C) 2018 SUSE LLC
31f18b77
FG
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#
16source $(dirname $0)/../detect-build-env-vars.sh
c07f9fc5 17source $CEPH_ROOT/qa/standalone/ceph-helpers.sh
31f18b77 18
f67539c2
TL
19mon_port=$(get_unused_port)
20dashboard_port=$((mon_port+1))
21
31f18b77
FG
22function run() {
23 local dir=$1
11fdf7f2
TL
24 shift
25
f67539c2 26 export CEPH_MON=127.0.0.1:$mon_port
11fdf7f2
TL
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"
31f18b77
FG
32
33 setup $dir || return 1
11fdf7f2
TL
34 TEST_dashboard $dir || return 1
35 teardown $dir || return 1
36}
31f18b77 37
11fdf7f2
TL
38function TEST_dashboard() {
39 local dir=$1
40 shift
31f18b77 41
11fdf7f2
TL
42 run_mon $dir a || return 1
43 timeout 30 ceph mon stat || return 1
f67539c2 44 ceph config-key set mgr/dashboard/x/server_port $dashboard_port
31f18b77 45 MGR_ARGS+="--mgr_module_path=${CEPH_ROOT}/src/pybind/mgr "
31f18b77
FG
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
cd265ab1
TL
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
31f18b77
FG
61
62 tries=0
63 while [[ $tries < 30 ]] ; do
f67539c2 64 if curl -c $dir/cookiefile -X POST -d '{"username":"admin","password":"admin"}' http://127.0.0.1:$dashboard_port/api/auth
31f18b77 65 then
f67539c2 66 if curl -b $dir/cookiefile -s http://127.0.0.1:$dashboard_port/api/summary | \
11fdf7f2
TL
67 jq '.health.overall_status' | grep HEALTH_
68 then
69 break
70 fi
31f18b77
FG
71 fi
72 tries=$((tries+1))
73 sleep 0.5
74 done
31f18b77
FG
75}
76
77main mgr-dashboard-smoke "$@"
78
79# Local Variables:
11fdf7f2 80# compile-command: "cd ../.. ; make -j4 TESTS=test/mgr/mgr-dashboard-smoke.sh check"
31f18b77 81# End: