]> git.proxmox.com Git - ceph.git/blame - ceph/qa/standalone/scrub/osd-recovery-scrub.sh
buildsys: use download.ceph.com to download source tar ball
[ceph.git] / ceph / qa / standalone / scrub / osd-recovery-scrub.sh
CommitLineData
11fdf7f2 1#! /usr/bin/env bash
b5b8bbf5
FG
2#
3# Copyright (C) 2017 Red Hat <contact@redhat.com>
4#
5# Author: David Zafman <dzafman@redhat.com>
6#
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)
10# any later version.
11#
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.
16#
17source $CEPH_ROOT/qa/standalone/ceph-helpers.sh
18
19function run() {
20 local dir=$1
21 shift
22
23 export CEPH_MON="127.0.0.1:7124" # git grep '\<7124\>' : there must be only one
24 export CEPH_ARGS
25 CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
26 CEPH_ARGS+="--mon-host=$CEPH_MON "
27
11fdf7f2 28 export -n CEPH_CLI_TEST_DUP_COMMAND
b5b8bbf5
FG
29 local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
30 for func in $funcs ; do
31 $func $dir || return 1
32 done
33}
34
35function TEST_recovery_scrub() {
36 local dir=$1
37 local poolname=test
38
39 TESTDATA="testdata.$$"
40 OSDS=8
41 PGS=32
42 OBJECTS=4
43
44 setup $dir || return 1
45 run_mon $dir a --osd_pool_default_size=1 || return 1
46 run_mgr $dir x || return 1
47 for osd in $(seq 0 $(expr $OSDS - 1))
48 do
49 run_osd $dir $osd || return 1
50 done
51
52 # Create a pool with $PGS pgs
53 create_pool $poolname $PGS $PGS
54 wait_for_clean || return 1
55 poolid=$(ceph osd dump | grep "^pool.*[']test[']" | awk '{ print $2 }')
56
57 dd if=/dev/urandom of=$TESTDATA bs=1M count=50
58 for i in $(seq 1 $OBJECTS)
59 do
60 rados -p $poolname put obj${i} $TESTDATA
61 done
62 rm -f $TESTDATA
63
64 ceph osd pool set $poolname size 4
65
66 pids=""
67 for pg in $(seq 0 $(expr $PGS - 1))
68 do
94b18763 69 run_in_background pids pg_scrub $poolid.$(printf "%x" $pg)
b5b8bbf5
FG
70 done
71 ceph pg dump pgs
72 wait_background pids
73 return_code=$?
74 if [ $return_code -ne 0 ]; then return $return_code; fi
75
76 ERRORS=0
77 pidfile=$(find $dir 2>/dev/null | grep $name_prefix'[^/]*\.pid')
78 pid=$(cat $pidfile)
79 if ! kill -0 $pid
80 then
81 echo "OSD crash occurred"
82 tail -100 $dir/osd.0.log
83 ERRORS=$(expr $ERRORS + 1)
84 fi
85
86 kill_daemons $dir || return 1
87
88 declare -a err_strings
89 err_strings[0]="not scheduling scrubs due to active recovery"
90 # Test with these two strings after disabled check in OSD::sched_scrub()
91 #err_strings[0]="handle_scrub_reserve_request: failed to reserve remotely"
92 #err_strings[1]="sched_scrub: failed to reserve locally"
93
94 for osd in $(seq 0 $(expr $OSDS - 1))
95 do
96 grep "failed to reserve\|not scheduling scrubs" $dir/osd.${osd}.log
97 done
98 for err_string in "${err_strings[@]}"
99 do
100 found=false
101 for osd in $(seq 0 $(expr $OSDS - 1))
102 do
103 if grep "$err_string" $dir/osd.${osd}.log > /dev/null;
104 then
105 found=true
106 fi
107 done
108 if [ "$found" = "false" ]; then
109 echo "Missing log message '$err_string'"
110 ERRORS=$(expr $ERRORS + 1)
111 fi
112 done
113
114 teardown $dir || return 1
115
116 if [ $ERRORS != "0" ];
117 then
118 echo "TEST FAILED WITH $ERRORS ERRORS"
119 return 1
120 fi
121
122 echo "TEST PASSED"
123 return 0
124}
125
126main osd-recovery-scrub "$@"
127
128# Local Variables:
129# compile-command: "cd build ; make -j4 && \
130# ../qa/run-standalone.sh osd-recovery-scrub.sh"
28e407b8 131# End: