3 # Copyright (C) 2017 Red Hat <contact@redhat.com>
5 # Author: David Zafman <dzafman@redhat.com>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU Library Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Library Public License for more details.
17 source $CEPH_ROOT/qa
/standalone
/ceph-helpers.sh
23 export CEPH_MON
="127.0.0.1:7124" # git grep '\<7124\>' : there must be only one
25 CEPH_ARGS
+="--fsid=$(uuidgen) --auth-supported=none "
26 CEPH_ARGS
+="--mon-host=$CEPH_MON "
28 local funcs
=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
29 for func
in $funcs ; do
30 $func $dir ||
return 1
34 function TEST_recovery_scrub
() {
38 TESTDATA
="testdata.$$"
43 setup
$dir ||
return 1
44 run_mon
$dir a
--osd_pool_default_size=1 ||
return 1
45 run_mgr
$dir x ||
return 1
46 for osd
in $
(seq 0 $
(expr $OSDS - 1))
48 run_osd
$dir $osd ||
return 1
51 # Create a pool with $PGS pgs
52 create_pool
$poolname $PGS $PGS
53 wait_for_clean ||
return 1
54 poolid
=$
(ceph osd dump |
grep "^pool.*[']test[']" |
awk '{ print $2 }')
56 dd if=/dev
/urandom of
=$TESTDATA bs
=1M count
=50
57 for i
in $
(seq 1 $OBJECTS)
59 rados
-p $poolname put obj
${i} $TESTDATA
63 ceph osd pool
set $poolname size
4
66 for pg
in $
(seq 0 $
(expr $PGS - 1))
68 run_in_background pids pg_scrub
$poolid.$
(printf "%x" $pg)
73 if [ $return_code -ne 0 ]; then return $return_code; fi
76 pidfile
=$
(find $dir 2>/dev
/null |
grep $name_prefix'[^/]*\.pid')
80 echo "OSD crash occurred"
81 tail -100 $dir/osd
.0.log
82 ERRORS
=$
(expr $ERRORS + 1)
85 kill_daemons
$dir ||
return 1
87 declare -a err_strings
88 err_strings
[0]="not scheduling scrubs due to active recovery"
89 # Test with these two strings after disabled check in OSD::sched_scrub()
90 #err_strings[0]="handle_scrub_reserve_request: failed to reserve remotely"
91 #err_strings[1]="sched_scrub: failed to reserve locally"
93 for osd
in $
(seq 0 $
(expr $OSDS - 1))
95 grep "failed to reserve\|not scheduling scrubs" $dir/osd.
${osd}.log
97 for err_string
in "${err_strings[@]}"
100 for osd
in $
(seq 0 $
(expr $OSDS - 1))
102 if grep "$err_string" $dir/osd.
${osd}.log
> /dev
/null
;
107 if [ "$found" = "false" ]; then
108 echo "Missing log message '$err_string'"
109 ERRORS
=$
(expr $ERRORS + 1)
113 teardown
$dir ||
return 1
115 if [ $ERRORS != "0" ];
117 echo "TEST FAILED WITH $ERRORS ERRORS"
125 main osd-recovery-scrub
"$@"
128 # compile-command: "cd build ; make -j4 && \
129 # ../qa/run-standalone.sh osd-recovery-scrub.sh"