]>
Commit | Line | Data |
---|---|---|
b5b8bbf5 FG |
1 | #! /bin/bash |
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 | # | |
17 | source $CEPH_ROOT/qa/standalone/ceph-helpers.sh | |
18 | ||
19 | function 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 | ||
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 | |
31 | done | |
32 | } | |
33 | ||
34 | function TEST_recovery_scrub() { | |
35 | local dir=$1 | |
36 | local poolname=test | |
37 | ||
38 | TESTDATA="testdata.$$" | |
39 | OSDS=8 | |
40 | PGS=32 | |
41 | OBJECTS=4 | |
42 | ||
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)) | |
47 | do | |
48 | run_osd $dir $osd || return 1 | |
49 | done | |
50 | ||
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 }') | |
55 | ||
56 | dd if=/dev/urandom of=$TESTDATA bs=1M count=50 | |
57 | for i in $(seq 1 $OBJECTS) | |
58 | do | |
59 | rados -p $poolname put obj${i} $TESTDATA | |
60 | done | |
61 | rm -f $TESTDATA | |
62 | ||
63 | ceph osd pool set $poolname size 4 | |
64 | ||
65 | pids="" | |
66 | for pg in $(seq 0 $(expr $PGS - 1)) | |
67 | do | |
94b18763 | 68 | run_in_background pids pg_scrub $poolid.$(printf "%x" $pg) |
b5b8bbf5 FG |
69 | done |
70 | ceph pg dump pgs | |
71 | wait_background pids | |
72 | return_code=$? | |
73 | if [ $return_code -ne 0 ]; then return $return_code; fi | |
74 | ||
75 | ERRORS=0 | |
76 | pidfile=$(find $dir 2>/dev/null | grep $name_prefix'[^/]*\.pid') | |
77 | pid=$(cat $pidfile) | |
78 | if ! kill -0 $pid | |
79 | then | |
80 | echo "OSD crash occurred" | |
81 | tail -100 $dir/osd.0.log | |
82 | ERRORS=$(expr $ERRORS + 1) | |
83 | fi | |
84 | ||
85 | kill_daemons $dir || return 1 | |
86 | ||
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" | |
92 | ||
93 | for osd in $(seq 0 $(expr $OSDS - 1)) | |
94 | do | |
95 | grep "failed to reserve\|not scheduling scrubs" $dir/osd.${osd}.log | |
96 | done | |
97 | for err_string in "${err_strings[@]}" | |
98 | do | |
99 | found=false | |
100 | for osd in $(seq 0 $(expr $OSDS - 1)) | |
101 | do | |
102 | if grep "$err_string" $dir/osd.${osd}.log > /dev/null; | |
103 | then | |
104 | found=true | |
105 | fi | |
106 | done | |
107 | if [ "$found" = "false" ]; then | |
108 | echo "Missing log message '$err_string'" | |
109 | ERRORS=$(expr $ERRORS + 1) | |
110 | fi | |
111 | done | |
112 | ||
113 | teardown $dir || return 1 | |
114 | ||
115 | if [ $ERRORS != "0" ]; | |
116 | then | |
117 | echo "TEST FAILED WITH $ERRORS ERRORS" | |
118 | return 1 | |
119 | fi | |
120 | ||
121 | echo "TEST PASSED" | |
122 | return 0 | |
123 | } | |
124 | ||
125 | main osd-recovery-scrub "$@" | |
126 | ||
127 | # Local Variables: | |
128 | # compile-command: "cd build ; make -j4 && \ | |
129 | # ../qa/run-standalone.sh osd-recovery-scrub.sh" | |
28e407b8 | 130 | # End: |