]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
unittests: fail early when low on disk 1143/head
authorLoic Dachary <loic@dachary.org>
Sun, 26 Jan 2014 12:32:57 +0000 (13:32 +0100)
committerLoic Dachary <loic@dachary.org>
Sun, 26 Jan 2014 12:32:57 +0000 (13:32 +0100)
Scripts from qa that are run as unittests via test/vstart_wrapper.sh may
fail because the partition on which it runs is low on space ( 95% full
). When it happens the cause of the problem may be unclear because it
is likely to show only as a client not being able to reach the mon.

A test is added in test/vstart_wrapper.sh to verify the disk space usage
using the same method as the mon would and fail with a detailed error if
it is the case.

Signed-off-by: Loic Dachary <loic@dachary.org>
src/test/vstart_wrapper.sh

index b9e1772d052426755d1701bec540f9c69f30ecd7..42458564c78e42a36d027b48fd1b1e0a20a0fd02 100755 (executable)
@@ -25,20 +25,34 @@ function vstart_setup()
     mkdir -p dev
     trap "vstart_teardown ; rm -f $TMPFILE" EXIT
     export LC_ALL=C # some tests are vulnerable to i18n
-    MON=1 OSD=3 ./vstart.sh -n -X -l mon osd
+    MON=1 OSD=3 ./vstart.sh -n -X -l mon osd || return 1
     export PATH=.:$PATH
     export CEPH_CONF=ceph.conf
+
+    crit=$(expr 100 - $(ceph-conf --show-config-value mon_data_avail_crit))
+    if [ $(df . | perl -ne 'print if(s/.*\s(\d+)%.*/\1/)') -ge $crit ] ; then
+        df . 
+        cat <<EOF
+error: not enough free disk space for mon to run
+The mon will shutdown with a message such as 
+ "reached critical levels of available space on local monitor storage -- shutdown!"
+as soon as it finds the disk has is more than ${crit}% full. 
+This is a limit determined by
+ ceph-conf --show-config-value mon_data_avail_crit
+EOF
+        return 1
+    fi
 }
 
 function main()
 {
     if [[ $(pwd) =~ /src$ ]] && [ -d .libs ] && [ -d pybind ] ; then
-        vstart_setup
+        vstart_setup || return 1
     else
         trap "rm -f $TMPFILE" EXIT
     fi
     
-    "$@"
+    "$@" || return 1
 }
 
 main "$@"