]>
Commit | Line | Data |
---|---|---|
81eedcae TL |
1 | #!/usr/bin/env bash |
2 | # | |
3 | # Copyright (C) 2019 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 | ||
18 | source $CEPH_ROOT/qa/standalone/ceph-helpers.sh | |
19 | ||
20 | function run() { | |
21 | local dir=$1 | |
22 | shift | |
23 | ||
24 | # Fix port???? | |
25 | export CEPH_MON="127.0.0.1:7129" # git grep '\<7129\>' : there must be only one | |
26 | export CEPH_ARGS | |
27 | CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none " | |
28 | CEPH_ARGS+="--mon-host=$CEPH_MON --osd_max_backfills=1 --debug_reserver=20 " | |
29 | ||
30 | local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')} | |
31 | for func in $funcs ; do | |
32 | setup $dir || return 1 | |
33 | $func $dir || return 1 | |
34 | teardown $dir || return 1 | |
35 | done | |
36 | } | |
37 | ||
38 | ||
39 | function _common_test() { | |
40 | local dir=$1 | |
41 | local extra_opts="$2" | |
42 | local loglen="$3" | |
43 | local dupslen="$4" | |
44 | local objects="$5" | |
45 | local moreobjects=${6:-0} | |
46 | ||
47 | local OSDS=6 | |
48 | ||
49 | run_mon $dir a || return 1 | |
50 | run_mgr $dir x || return 1 | |
51 | export CEPH_ARGS | |
52 | export EXTRA_OPTS=" $extra_opts" | |
53 | ||
54 | for osd in $(seq 0 $(expr $OSDS - 1)) | |
55 | do | |
56 | run_osd $dir $osd || return 1 | |
57 | done | |
58 | ||
59 | create_pool test 1 1 | |
60 | ||
61 | for j in $(seq 1 $objects) | |
62 | do | |
63 | rados -p test put obj-${j} /etc/passwd | |
64 | done | |
65 | ||
66 | # Mark out all OSDs for this pool | |
67 | ceph osd out $(ceph pg dump pgs --format=json | jq '.pg_stats[0].up[]') | |
68 | if [ "$moreobjects" != "0" ]; then | |
69 | for j in $(seq 1 $moreobjects) | |
70 | do | |
71 | rados -p test put obj-more-${j} /etc/passwd | |
72 | done | |
73 | fi | |
74 | sleep 1 | |
75 | wait_for_clean | |
76 | ||
801d1391 TL |
77 | flush_pg_stats |
78 | ||
81eedcae TL |
79 | newprimary=$(ceph pg dump pgs --format=json | jq '.pg_stats[0].up_primary') |
80 | kill_daemons | |
81 | ||
82 | ERRORS=0 | |
83 | _objectstore_tool_nodown $dir $newprimary --no-mon-config --pgid 1.0 --op log | tee $dir/result.log | |
84 | LOGLEN=$(jq '.pg_log_t.log | length' $dir/result.log) | |
85 | if [ $LOGLEN != "$loglen" ]; then | |
86 | echo "FAILED: Wrong log length got $LOGLEN (expected $loglen)" | |
87 | ERRORS=$(expr $ERRORS + 1) | |
88 | fi | |
89 | DUPSLEN=$(jq '.pg_log_t.dups | length' $dir/result.log) | |
90 | if [ $DUPSLEN != "$dupslen" ]; then | |
91 | echo "FAILED: Wrong dups length got $DUPSLEN (expected $dupslen)" | |
92 | ERRORS=$(expr $ERRORS + 1) | |
93 | fi | |
94 | grep "copy_up_to\|copy_after" $dir/osd.*.log | |
95 | rm -f $dir/result.log | |
96 | if [ $ERRORS != "0" ]; then | |
97 | echo TEST FAILED | |
98 | return 1 | |
99 | fi | |
100 | } | |
101 | ||
102 | ||
103 | # Cause copy_up_to() to only partially copy logs, copy additional dups, and trim dups | |
104 | function TEST_backfill_log_1() { | |
105 | local dir=$1 | |
106 | ||
9f95a23c | 107 | _common_test $dir "--osd_min_pg_log_entries=1 --osd_max_pg_log_entries=2 --osd_pg_log_dups_tracked=10" 2 8 150 |
81eedcae TL |
108 | } |
109 | ||
110 | ||
111 | # Cause copy_up_to() to only partially copy logs, copy additional dups | |
112 | function TEST_backfill_log_2() { | |
113 | local dir=$1 | |
114 | ||
9f95a23c | 115 | _common_test $dir "--osd_min_pg_log_entries=1 --osd_max_pg_log_entries=2" 2 148 150 |
81eedcae TL |
116 | } |
117 | ||
118 | ||
119 | # Cause copy_after() to only copy logs, no dups | |
120 | function TEST_recovery_1() { | |
121 | local dir=$1 | |
122 | ||
123 | _common_test $dir "--osd_min_pg_log_entries=50 --osd_max_pg_log_entries=50 --osd_pg_log_dups_tracked=60 --osd_pg_log_trim_min=10" 40 0 40 | |
124 | } | |
125 | ||
126 | ||
127 | # Cause copy_after() to copy logs with dups | |
128 | function TEST_recovery_2() { | |
129 | local dir=$1 | |
130 | ||
131 | _common_test $dir "--osd_min_pg_log_entries=150 --osd_max_pg_log_entries=150 --osd_pg_log_dups_tracked=3000 --osd_pg_log_trim_min=10" 151 10 141 20 | |
132 | } | |
133 | ||
134 | main osd-backfill-recovery-log "$@" | |
135 | ||
136 | # Local Variables: | |
137 | # compile-command: "make -j4 && ../qa/run-standalone.sh osd-backfill-recovery-log.sh" | |
138 | # End: |