]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | #!/usr/bin/env bash |
2 | set -ex | |
7c673cae FG |
3 | |
4 | # create a snapshot, then export it and check that setting read flags works | |
5 | # by looking at --debug-ms output | |
6 | ||
7 | function clean_up { | |
8 | rm -f test.log || true | |
9 | rbd snap remove test@snap || true | |
10 | rbd rm test || true | |
11 | } | |
12 | ||
13 | function test_read_flags { | |
14 | local IMAGE=$1 | |
15 | local SET_BALANCED=$2 | |
16 | local SET_LOCALIZED=$3 | |
17 | local EXPECT_BALANCED=$4 | |
18 | local EXPECT_LOCALIZED=$5 | |
19 | ||
20 | local EXTRA_ARGS="--log-file test.log --debug-ms 1 --no-log-to-stderr" | |
21 | if [ "$SET_BALANCED" = 'y' ]; then | |
22 | EXTRA_ARGS="$EXTRA_ARGS --rbd-balance-snap-reads" | |
23 | elif [ "$SET_LOCALIZED" = 'y' ]; then | |
24 | EXTRA_ARGS="$EXTRA_ARGS --rbd-localize-snap-reads" | |
25 | fi | |
26 | ||
27 | rbd export $IMAGE - $EXTRA_ARGS > /dev/null | |
28 | if [ "$EXPECT_BALANCED" = 'y' ]; then | |
29 | grep -q balance_reads test.log | |
30 | else | |
31 | grep -L balance_reads test.log | grep -q test.log | |
32 | fi | |
33 | if [ "$EXPECT_LOCALIZED" = 'y' ]; then | |
34 | grep -q localize_reads test.log | |
35 | else | |
36 | grep -L localize_reads test.log | grep -q test.log | |
37 | fi | |
38 | rm -f test.log | |
39 | ||
40 | } | |
41 | ||
42 | clean_up | |
43 | ||
44 | trap clean_up INT TERM EXIT | |
45 | ||
46 | rbd create --image-feature layering -s 10 test | |
47 | rbd snap create test@snap | |
48 | ||
49 | # export from non snapshot with or without settings should not have flags | |
50 | test_read_flags test n n n n | |
51 | test_read_flags test y y n n | |
52 | ||
53 | # export from snapshot should have read flags in log if they are set | |
54 | test_read_flags test@snap n n n n | |
55 | test_read_flags test@snap y n y n | |
56 | test_read_flags test@snap n y n y | |
57 | ||
58 | # balanced_reads happens to take priority over localize_reads | |
59 | test_read_flags test@snap y y y n | |
60 | ||
61 | echo OK |