]> git.proxmox.com Git - ceph.git/blob - ceph/qa/standalone/scrub/osd-scrub-test.sh
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / qa / standalone / scrub / osd-scrub-test.sh
1 #!/usr/bin/env bash
2 #
3 # Copyright (C) 2018 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:7138" # git grep '\<7138\>' : 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 export -n CEPH_CLI_TEST_DUP_COMMAND
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
35 function TEST_scrub_test() {
36 local dir=$1
37 local poolname=test
38 local OSDS=3
39 local objects=15
40
41 TESTDATA="testdata.$$"
42
43 setup $dir || return 1
44 run_mon $dir a --osd_pool_default_size=3 || 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 a single pg
52 create_pool $poolname 1 1
53 wait_for_clean || return 1
54 poolid=$(ceph osd dump | grep "^pool.*[']${poolname}[']" | awk '{ print $2 }')
55
56 dd if=/dev/urandom of=$TESTDATA bs=1032 count=1
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 local primary=$(get_primary $poolname obj1)
64 local otherosd=$(get_not_primary $poolname obj1)
65 if [ "$otherosd" = "2" ];
66 then
67 local anotherosd="0"
68 else
69 local anotherosd="2"
70 fi
71
72 objectstore_tool $dir $anotherosd obj1 set-bytes /etc/fstab
73
74 local pgid="${poolid}.0"
75 pg_deep_scrub "$pgid" || return 1
76
77 ceph pg dump pgs | grep ^${pgid} | grep -q -- +inconsistent || return 1
78 test "$(ceph pg $pgid query | jq '.info.stats.stat_sum.num_scrub_errors')" = "2" || return 1
79
80 ceph osd out $primary
81 wait_for_clean || return 1
82
83 pg_deep_scrub "$pgid" || return 1
84
85 test "$(ceph pg $pgid query | jq '.info.stats.stat_sum.num_scrub_errors')" = "2" || return 1
86 test "$(ceph pg $pgid query | jq '.peer_info[0].stats.stat_sum.num_scrub_errors')" = "2" || return 1
87 ceph pg dump pgs | grep ^${pgid} | grep -q -- +inconsistent || return 1
88
89 ceph osd in $primary
90 wait_for_clean || return 1
91
92 repair "$pgid" || return 1
93 wait_for_clean || return 1
94
95 # This sets up the test after we've repaired with previous primary has old value
96 test "$(ceph pg $pgid query | jq '.peer_info[0].stats.stat_sum.num_scrub_errors')" = "2" || return 1
97 ceph pg dump pgs | grep ^${pgid} | grep -vq -- +inconsistent || return 1
98
99 ceph osd out $primary
100 wait_for_clean || return 1
101
102 test "$(ceph pg $pgid query | jq '.info.stats.stat_sum.num_scrub_errors')" = "0" || return 1
103 test "$(ceph pg $pgid query | jq '.peer_info[0].stats.stat_sum.num_scrub_errors')" = "0" || return 1
104 test "$(ceph pg $pgid query | jq '.peer_info[1].stats.stat_sum.num_scrub_errors')" = "0" || return 1
105 ceph pg dump pgs | grep ^${pgid} | grep -vq -- +inconsistent || return 1
106
107 teardown $dir || return 1
108 }
109
110 main osd-scrub-test "$@"
111
112 # Local Variables:
113 # compile-command: "cd build ; make -j4 && \
114 # ../qa/run-standalone.sh osd-scrub-test.sh"
115 # End: