3 # Copyright (C) 2019 Red Hat <contact@redhat.com>
5 # Author: David Zafman <dzafman@redhat.com>
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)
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.
18 source $CEPH_ROOT/qa
/standalone
/ceph-helpers.sh
25 export CEPH_MON
="127.0.0.1:7129" # git grep '\<7129\>' : there must be only one
27 CEPH_ARGS
+="--fsid=$(uuidgen) --auth-supported=none "
28 CEPH_ARGS
+="--mon-host=$CEPH_MON --osd_max_backfills=1 --debug_reserver=20 "
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
39 function _common_test
() {
45 local moreobjects
=${6:-0}
49 run_mon
$dir a ||
return 1
50 run_mgr
$dir x ||
return 1
52 export EXTRA_OPTS
=" $extra_opts"
54 for osd
in $
(seq 0 $
(expr $OSDS - 1))
56 run_osd
$dir $osd ||
return 1
61 for j
in $
(seq 1 $objects)
63 rados
-p test put obj-
${j} /etc
/passwd
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)
71 rados
-p test put obj-more-
${j} /etc
/passwd
79 newprimary
=$
(ceph pg dump pgs
--format=json | jq
'.pg_stats[0].up_primary')
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)
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)
94 grep "copy_up_to\|copy_after" $dir/osd.
*.log
96 if [ $ERRORS != "0" ]; then
103 # Cause copy_up_to() to only partially copy logs, copy additional dups, and trim dups
104 function TEST_backfill_log_1
() {
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
111 # Cause copy_up_to() to only partially copy logs, copy additional dups
112 function TEST_backfill_log_2
() {
115 _common_test
$dir "--osd_min_pg_log_entries=1 --osd_max_pg_log_entries=2" 2 148 150
119 # Cause copy_after() to only copy logs, no dups
120 function TEST_recovery_1
() {
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
127 # Cause copy_after() to copy logs with dups
128 function TEST_recovery_2
() {
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
134 main osd-backfill-recovery-log
"$@"
137 # compile-command: "make -j4 && ../qa/run-standalone.sh osd-backfill-recovery-log.sh"