3 # create a snapshot, then export it and check that setting read flags works
4 # by looking at --debug-ms output
8 rbd snap remove test@snap || true
12 function test_read_flags {
15 local SET_LOCALIZED=$3
16 local EXPECT_BALANCED=$4
17 local EXPECT_LOCALIZED=$5
19 local EXTRA_ARGS="--log-file test.log --debug-ms 1 --no-log-to-stderr"
20 if [ "$SET_BALANCED" = 'y' ]; then
21 EXTRA_ARGS="$EXTRA_ARGS --rbd-balance-snap-reads"
22 elif [ "$SET_LOCALIZED" = 'y' ]; then
23 EXTRA_ARGS="$EXTRA_ARGS --rbd-localize-snap-reads"
26 rbd export $IMAGE - $EXTRA_ARGS > /dev/null
27 if [ "$EXPECT_BALANCED" = 'y' ]; then
28 grep -q balance_reads test.log
30 grep -L balance_reads test.log | grep -q test.log
32 if [ "$EXPECT_LOCALIZED" = 'y' ]; then
33 grep -q localize_reads test.log
35 grep -L localize_reads test.log | grep -q test.log
43 trap clean_up INT TERM EXIT
45 rbd create --image-feature layering -s 10 test
46 rbd snap create test@snap
48 # export from non snapshot with or without settings should not have flags
49 test_read_flags test n n n n
50 test_read_flags test y y n n
52 # export from snapshot should have read flags in log if they are set
53 test_read_flags test@snap n n n n
54 test_read_flags test@snap y n y n
55 test_read_flags test@snap n y n y
57 # balanced_reads happens to take priority over localize_reads
58 test_read_flags test@snap y y y n