2 # vim: ts=8 sw=2 smarttab
4 # run_seed_to.sh - Run ceph_test_filestore_idempotent_sequence up until an
5 # injection point, generating a sequence of operations based on a
8 # We also perform three additional tests, focused on assessing if
9 # replaying a larger chunck of the journal affects the expected store
10 # behavior. These tests will be performed by increasing the store's
11 # journal sync interval to a very large value, allowing the store to
12 # finish execution before the first sync (unless the store runs for
13 # over 10 hours, case on which the interval variables must be changed
14 # to an appropriate value). Unless the '--no-journal-test' option is
15 # specified, we will run the 3 following scenarios:
17 # 1) journal sync'ing for both stores is good as disabled
18 # (we call it '00', for store naming purposes)
19 # 2) journal sync'ing for store A is as good as disabled
20 # (we call it '01', for store naming purposes)
21 # 3) journal sync'ing for store B is as good as disabled
22 # (we call it '10', for store naming purposes)
24 # All log files are also appropriately named accordingly (i.e., a.00.fail,
25 # a.10.recover, or b.01.clean).
27 # By default, the test will not exit on error, although it will show the
28 # fail message. This behavior is so defined so we run the whole battery of
29 # tests, and obtain as many mismatches as possible in one go. We may force
30 # the test to exit on error by specifying the '--exit-on-error' option.
38 echo "usage: $1 [options..] <seed> <kill-at>"
41 echo " -c, --colls <VAL> # of collections"
42 echo " -o, --objs <VAL> # of objects"
43 echo " -b, --btrfs <VAL> seq number for btrfs stores"
44 echo " --no-journal-test don't perform journal replay tests"
45 echo " -e, --exit-on-error exit with 1 on error"
46 echo " -v, --valgrind run commands through valgrind"
49 echo " OPTS_STORE additional opts for both stores"
50 echo " OPTS_STORE_A additional opts for store A"
51 echo " OPTS_STORE_B additional opts for store B"
57 die_on_missing_arg
() {
58 if [[ "$2" == "" ]]; then
59 echo "$1: missing required parameter"
73 min_sync_interval
="36000" # ten hours, yes.
74 max_sync_interval
="36001"
79 if [[ $on_btrfs -eq 0 ]]; then
85 if [[ $1 -eq 1 ]]; then
87 elif [[ $1 -eq 2 ]]; then
90 echo "error: unknown purpose for '$2'"
100 die_on_missing_arg
"$1" "$2"
101 test_opts
="$test_opts --test-num-colls $2"
105 die_on_missing_arg
"$1" "$2"
106 test_opts
="$test_opts --test-num-objs $2"
114 die_on_missing_arg
"$1" "$2"
123 -e |
--exit-on-error)
128 v
="valgrind --leak-check=full"
136 echo "$1: unknown option" >&2
141 obtained_args
=$
(($obtained_args+1))
142 set_arg
$obtained_args $1
148 if [[ $obtained_args -ne $required_args ]]; then
149 echo "error: missing argument"
154 if [[ "$OPTS_STORE" != "" ]]; then
155 test_opts
="$test_opts $OPTS_STORE"
158 test_opts_a
="$test_opts"
159 test_opts_b
="$test_opts"
161 if [[ "$OPTS_STORE_A" != "" ]]; then
162 test_opts_a
="$test_opts_a $OPTS_STORE_A"
164 if [[ "$OPTS_STORE_B" != "" ]]; then
165 test_opts_b
="$test_opts_b $OPTS_STORE_B"
171 # run forever, until $killat...
177 # We need these for two reasons:
178 # 1) if we are running the tests on a btrfs volume, then we need to use
179 # a seq number for each run. Being on btrfs means we will fail when
180 # removing the store's directories and it's far more simple to just
181 # specify differente store names such as 'a.$seq' or 'b.$seq'.
183 # 2) unless the '--no-journal-test' option is specified, we will run
184 # three additional tests for each store, and we will reuse the same
185 # command for each one of the runs, but varying the store's name and
191 if [[ $on_btrfs -eq 1 ]]; then
192 store_a
="$store_a.$on_btrfs_seq"
193 store_b
="$store_b.$on_btrfs_seq"
198 if [[ $journal_test -eq 1 ]]; then
199 total_runs
=$
(($total_runs + 3))
204 opt_min_sync
="--filestore-min-sync-interval $min_sync_interval"
205 opt_max_sync
="--filestore-max-sync-interval $max_sync_interval"
209 while [[ $num_runs -lt $total_runs ]];
213 tmp_opts_a
=$test_opts_a
214 tmp_opts_b
=$test_opts_b
217 # We have already tested whether there are diffs when both journals
218 # are properly working. Now let's try on three other scenarios:
219 # 1) journal sync'ing for both stores is good as disabled
221 # 2) journal sync'ing for store A is as good as disabled
223 # 3) journal sync'ing for store B is as good as disabled
226 if [[ $num_runs -gt 0 && $journal_test -eq 1 ]]; then
227 echo "run #$num_runs"
230 tmp_name_a
="$tmp_name_a.00"
231 tmp_name_b
="$tmp_name_b.00"
232 tmp_opts_a
="$tmp_opts_a $opt_min_sync $opt_max_sync"
233 tmp_opts_b
="$tmp_opts_b $opt_min_sync $opt_max_sync"
236 tmp_name_a
="$tmp_name_a.01"
237 tmp_name_b
="$tmp_name_b.01"
238 tmp_opts_a
="$tmp_opts_a $opt_min_sync $opt_max_sync"
241 tmp_name_a
="$tmp_name_a.10"
242 tmp_name_b
="$tmp_name_b.10"
243 tmp_opts_b
="$tmp_opts_b $opt_min_sync $opt_max_sync"
248 do_rm
$tmp_name_a $tmp_name_a.fail
$tmp_name_a.recover
249 $v ceph_test_filestore_idempotent_sequence run-sequence-to
$to \
250 $tmp_name_a $tmp_name_a/journal \
251 --test-seed $seed --osd-journal-size 100 \
252 --filestore-kill-at $killat $tmp_opts_a \
253 --log-file $tmp_name_a.fail
--debug-filestore 20 --no-log-to-stderr || true
255 stop_at
=`ceph_test_filestore_idempotent_sequence get-last-op \
256 $tmp_name_a $tmp_name_a/journal \
257 --log-file $tmp_name_a.recover \
258 --debug-filestore 20 --debug-journal 20 --no-log-to-stderr`
260 if [[ "`expr $stop_at - $stop_at 2>/dev/null`" != "0" ]]; then
261 echo "error: get-last-op returned '$stop_at'"
265 echo stopped
at $stop_at
267 do_rm
$tmp_name_b $tmp_name_b.clean
268 $v ceph_test_filestore_idempotent_sequence run-sequence-to \
269 $stop_at $tmp_name_b $tmp_name_b/journal \
270 --test-seed $seed --osd-journal-size 100 \
271 --log-file $tmp_name_b.clean
--debug-filestore 20 --no-log-to-stderr \
274 if $v ceph_test_filestore_idempotent_sequence
diff \
275 $tmp_name_a $tmp_name_a/journal
$tmp_name_b $tmp_name_b/journal
--no-log-to-stderr --log-file $tmp_name_a.
diff.log
--debug-filestore 20 ; then
280 echo " $tmp_name_a.fail -- leading up to failure"
281 echo " $tmp_name_a.recover -- journal replay"
282 echo " $tmp_name_b.clean -- the clean reference"
285 if [[ $exit_on_error -eq 1 ]]; then
290 num_runs
=$
(($num_runs+1))