]> git.proxmox.com Git - ceph.git/blame - ceph/qa/standalone/scrub/osd-scrub-test.sh
update sources to 12.2.7
[ceph.git] / ceph / qa / standalone / scrub / osd-scrub-test.sh
CommitLineData
94b18763
FG
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#
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: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 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
34function TEST_scrub_test() {
35 local dir=$1
36 local poolname=test
37 local OSDS=3
38 local objects=15
39
40 TESTDATA="testdata.$$"
41
42 setup $dir || return 1
43 run_mon $dir a --osd_pool_default_size=3 || return 1
44 run_mgr $dir x || return 1
45 for osd in $(seq 0 $(expr $OSDS - 1))
46 do
47 run_osd $dir $osd || return 1
48 done
49
50 # Create a pool with a single pg
51 create_pool $poolname 1 1
52 wait_for_clean || return 1
53 poolid=$(ceph osd dump | grep "^pool.*[']${poolname}[']" | awk '{ print $2 }')
54
55 dd if=/dev/urandom of=$TESTDATA bs=1032 count=1
56 for i in `seq 1 $objects`
57 do
58 rados -p $poolname put obj${i} $TESTDATA
59 done
60 rm -f $TESTDATA
61
62 local primary=$(get_primary $poolname obj1)
63 local otherosd=$(get_not_primary $poolname obj1)
64 if [ "$otherosd" = "2" ];
65 then
66 local anotherosd="0"
67 else
68 local anotherosd="2"
69 fi
70
71 objectstore_tool $dir $anotherosd obj1 set-bytes /etc/fstab
72
73 local pgid="${poolid}.0"
74 pg_deep_scrub "$pgid" || return 1
75
76 ceph pg dump pgs | grep ^${pgid} | grep -q -- +inconsistent || return 1
77 test "$(ceph pg $pgid query | jq '.info.stats.stat_sum.num_scrub_errors')" = "2" || return 1
78
79 ceph osd out $primary
80 wait_for_clean || return 1
81
82 pg_deep_scrub "$pgid" || return 1
83
84 test "$(ceph pg $pgid query | jq '.info.stats.stat_sum.num_scrub_errors')" = "2" || return 1
85 test "$(ceph pg $pgid query | jq '.peer_info[0].stats.stat_sum.num_scrub_errors')" = "2" || return 1
86 ceph pg dump pgs | grep ^${pgid} | grep -q -- +inconsistent || return 1
87
88 ceph osd in $primary
89 wait_for_clean || return 1
90
91 repair "$pgid" || return 1
92 wait_for_clean || return 1
93
94 # This sets up the test after we've repaired with previous primary has old value
95 test "$(ceph pg $pgid query | jq '.peer_info[0].stats.stat_sum.num_scrub_errors')" = "2" || return 1
96 ceph pg dump pgs | grep ^${pgid} | grep -vq -- +inconsistent || return 1
97
98 ceph osd out $primary
99 wait_for_clean || return 1
100
101 test "$(ceph pg $pgid query | jq '.info.stats.stat_sum.num_scrub_errors')" = "0" || return 1
102 test "$(ceph pg $pgid query | jq '.peer_info[0].stats.stat_sum.num_scrub_errors')" = "0" || return 1
103 test "$(ceph pg $pgid query | jq '.peer_info[1].stats.stat_sum.num_scrub_errors')" = "0" || return 1
104 ceph pg dump pgs | grep ^${pgid} | grep -vq -- +inconsistent || return 1
105
106 teardown $dir || return 1
107}
108
109main osd-scrub-test "$@"
110
111# Local Variables:
28e407b8
AA
112# compile-command: "cd build ; make -j4 && \
113# ../qa/run-standalone.sh osd-scrub-test.sh"
114# End: