3 # Copyright (C) 2014 Cloudwatt <libre.licensing@cloudwatt.com>
4 # Copyright (C) 2018 Red Hat <contact@redhat.com>
6 # Author: Josh Durgin <jdurgin@redhat.com>
7 # Author: David Zafman <dzafman@redhat.com>
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU Library Public License as published by
11 # the Free Software Foundation; either version 2, or (at your option)
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU Library Public License for more details.
20 source $CEPH_ROOT/qa
/standalone
/ceph-helpers.sh
26 export CEPH_MON
="127.0.0.1:7100" # git grep '\<7100\>' : there must be only one
28 CEPH_ARGS
+="--fsid=$(uuidgen) --auth-supported=none "
29 CEPH_ARGS
+="--mon-host=$CEPH_MON "
31 local funcs
=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
32 for func
in $funcs ; do
33 setup
$dir ||
return 1
34 $func $dir ||
return 1
35 teardown
$dir ||
return 1
41 function test_log_size
()
45 ceph tell osd.\
* flush_pg_stats
47 ceph pg
$PGID query | jq .info.stats.log_size
48 ceph pg
$PGID query | jq .info.stats.log_size |
grep "${EXPECTED}"
51 function setup_log_test
() {
55 run_mon
$dir a ||
return 1
56 run_mgr
$dir x ||
return 1
57 run_osd
$dir 0 ||
return 1
58 run_osd
$dir 1 ||
return 1
59 run_osd
$dir 2 ||
return 1
61 ceph osd pool create
test 1 1 || true
62 POOL_ID
=$
(ceph osd dump
--format json | jq
'.pools[] | select(.pool_name == "test") | .pool')
65 ceph tell osd.\
* injectargs
-- --osd-min-pg-log-entries 20 ||
return 1
66 ceph tell osd.\
* injectargs
-- --osd-max-pg-log-entries 30 ||
return 1
67 ceph tell osd.\
* injectargs
-- --osd-pg-log-trim-min 10 ||
return 1
68 ceph tell osd.\
* injectargs
-- --osd-pg-log-dups-tracked 10 ||
return 1
73 rados
-p test put foo foo ||
return 1
76 test_log_size
$PGID 20 ||
return 1
78 rados
-p test rm foo ||
return 1
80 # generate error entries
86 # log should have been trimmed down to min_entries with one extra
87 test_log_size
$PGID 21 ||
return 1
90 function TEST_repro_long_log1
()
94 setup_log_test
$dir ||
return 1
95 # regular write should trim the log
96 rados
-p test put foo foo ||
return 1
97 test_log_size
$PGID 22 ||
return 1
100 function TEST_repro_long_log2
()
104 setup_log_test
$dir ||
return 1
105 local PRIMARY
=$
(ceph pg
$PGID query | jq
'.info.stats.up_primary')
106 kill_daemons
$dir TERM osd.
$PRIMARY ||
return 1
107 CEPH_ARGS
="--osd-max-pg-log-entries=2 --no-mon-config" ceph-objectstore-tool
--data-path $dir/$PRIMARY --pgid $PGID --op trim-pg-log ||
return 1
108 run_osd
$dir $PRIMARY ||
return 1
109 wait_for_clean ||
return 1
110 test_log_size
$PGID 2 ||
return 1
113 function TEST_trim_max_entries
()
117 setup_log_test
$dir ||
return 1
119 ceph tell osd.\
* injectargs
-- --osd-min-pg-log-entries 1
120 ceph tell osd.\
* injectargs
-- --osd-pg-log-trim-min 2
121 ceph tell osd.\
* injectargs
-- --osd-pg-log-trim-max 4
123 # adding log entries, should only trim 4 and add one each time
125 test_log_size
$PGID 17
127 test_log_size
$PGID 14
129 test_log_size
$PGID 11
131 test_log_size
$PGID 8
133 test_log_size
$PGID 5
135 test_log_size
$PGID 2
139 test_log_size
$PGID 3
141 test_log_size
$PGID 3
143 test_log_size
$PGID 3
145 test_log_size
$PGID 3
148 main repro-long-log
"$@"
151 # compile-command: "cd ../.. ; make -j4 && ../qa/run-standalone.sh repro_long_log.sh"