]> git.proxmox.com Git - ceph.git/blob - ceph/src/test/vstart_wrapper.sh
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / test / vstart_wrapper.sh
1 #!/usr/bin/env bash
2 #
3 # Copyright (C) 2013 Cloudwatt <libre.licensing@cloudwatt.com>
4 # Copyright (C) 2015 Red Hat <contact@redhat.com>
5 #
6 # Author: Loic Dachary <loic@dachary.org>
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU Library Public License as published by
10 # the Free Software Foundation; either version 2, or (at your option)
11 # any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU Library Public License for more details.
17 #
18
19 source $CEPH_ROOT/qa/standalone/ceph-helpers.sh
20
21 export CEPH_VSTART_WRAPPER=1
22 export CEPH_DIR="${TMPDIR:-$PWD}/td/t-$CEPH_PORT"
23 export CEPH_DEV_DIR="$CEPH_DIR/dev"
24 export CEPH_OUT_DIR="$CEPH_DIR/out"
25 export CEPH_ASOK_DIR="$CEPH_DIR/out"
26
27 export MGR_PYTHON_PATH=$CEPH_ROOT/src/pybind/mgr
28
29 function vstart_setup()
30 {
31 rm -fr $CEPH_DEV_DIR $CEPH_OUT_DIR
32 mkdir -p $CEPH_DEV_DIR
33 trap "teardown $CEPH_DIR" EXIT
34 export LC_ALL=C # some tests are vulnerable to i18n
35 export PATH="$(pwd):${PATH}"
36 OBJSTORE_ARGS=""
37 if [ "bluestore" = "${CEPH_OBJECTSTORE}" ]; then
38 OBJSTORE_ARGS="-b"
39 fi
40 $CEPH_ROOT/src/vstart.sh \
41 --short \
42 $OBJSTORE_ARGS \
43 -o 'paxos propose interval = 0.01' \
44 -d -n -l || return 1
45 export CEPH_CONF=$CEPH_DIR/ceph.conf
46
47 crit=$(expr 100 - $(ceph-conf --show-config-value mon_data_avail_crit))
48 if [ $(df . | perl -ne 'print if(s/.*\s(\d+)%.*/\1/)') -ge $crit ] ; then
49 df .
50 cat <<EOF
51 error: not enough free disk space for mon to run
52 The mon will shutdown with a message such as
53 "reached critical levels of available space on local monitor storage -- shutdown!"
54 as soon as it finds the disk has is more than ${crit}% full.
55 This is a limit determined by
56 ceph-conf --show-config-value mon_data_avail_crit
57 EOF
58 return 1
59 fi
60 }
61
62 function main()
63 {
64 teardown $CEPH_DIR
65 vstart_setup || return 1
66 if CEPH_CONF=$CEPH_DIR/ceph.conf "$@"; then
67 code=0
68 else
69 code=1
70 display_logs $CEPH_OUT_DIR
71 fi
72 return $code
73 }
74
75 main "$@"