root / tests / qemu-iotests / 081 @ 6141f3bd
History | View | Annotate | Download (3.6 kB)
1 |
#!/bin/bash |
---|---|
2 |
# |
3 |
# Test Quorum block driver |
4 |
# |
5 |
# Copyright (C) 2013 Nodalink, SARL. |
6 |
# |
7 |
# This program is free software; you can redistribute it and/or modify |
8 |
# it under the terms of the GNU General Public License as published by |
9 |
# the Free Software Foundation; either version 2 of the License, or |
10 |
# (at your option) any later version. |
11 |
# |
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 General Public License for more details. |
16 |
# |
17 |
# You should have received a copy of the GNU General Public License |
18 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 |
# |
20 |
|
21 |
# creator |
22 |
owner=benoit@irqsave.net |
23 |
|
24 |
seq=`basename $0` |
25 |
echo "QA output created by $seq" |
26 |
|
27 |
here=`pwd` |
28 |
tmp=/tmp/$$ |
29 |
status=1 # failure is the default! |
30 |
|
31 |
_cleanup() |
32 |
{ |
33 |
rm -rf $TEST_DIR/1.raw |
34 |
rm -rf $TEST_DIR/2.raw |
35 |
rm -rf $TEST_DIR/3.raw |
36 |
} |
37 |
trap "_cleanup; exit \$status" 0 1 2 3 15 |
38 |
|
39 |
# get standard environment, filters and checks |
40 |
. ./common.rc |
41 |
. ./common.filter |
42 |
|
43 |
_supported_fmt raw |
44 |
_supported_proto generic |
45 |
_supported_os Linux |
46 |
|
47 |
function do_run_qemu() |
48 |
{ |
49 |
echo Testing: "$@" | _filter_imgfmt |
50 |
$QEMU -nographic -qmp stdio -serial none "$@" |
51 |
echo |
52 |
} |
53 |
|
54 |
function run_qemu() |
55 |
{ |
56 |
do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp | _filter_qemu_io |
57 |
} |
58 |
|
59 |
quorum="file.driver=quorum,file.children.0.file.filename=$TEST_DIR/1.raw" |
60 |
quorum="$quorum,file.children.1.file.filename=$TEST_DIR/2.raw" |
61 |
quorum="$quorum,file.children.2.file.filename=$TEST_DIR/3.raw,file.vote-threshold=2" |
62 |
|
63 |
echo |
64 |
echo "== creating quorum files ==" |
65 |
|
66 |
size=10M |
67 |
|
68 |
TEST_IMG="$TEST_DIR/1.raw" _make_test_img $size |
69 |
TEST_IMG="$TEST_DIR/2.raw" _make_test_img $size |
70 |
TEST_IMG="$TEST_DIR/3.raw" _make_test_img $size |
71 |
|
72 |
echo |
73 |
echo "== writing images ==" |
74 |
|
75 |
$QEMU_IO -c "open -o $quorum" -c "write -P 0x32 0 $size" | _filter_qemu_io |
76 |
|
77 |
echo |
78 |
echo "== checking quorum write ==" |
79 |
|
80 |
$QEMU_IO -c "read -P 0x32 0 $size" "$TEST_DIR/1.raw" | _filter_qemu_io |
81 |
$QEMU_IO -c "read -P 0x32 0 $size" "$TEST_DIR/2.raw" | _filter_qemu_io |
82 |
$QEMU_IO -c "read -P 0x32 0 $size" "$TEST_DIR/3.raw" | _filter_qemu_io |
83 |
|
84 |
echo |
85 |
echo "== corrupting image ==" |
86 |
|
87 |
$QEMU_IO -c "write -P 0x42 0 $size" "$TEST_DIR/2.raw" | _filter_qemu_io |
88 |
|
89 |
echo |
90 |
echo "== checking quorum correction ==" |
91 |
|
92 |
$QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io |
93 |
|
94 |
echo |
95 |
echo "== checking mixed reference/option specification ==" |
96 |
|
97 |
run_qemu -drive "file=$TEST_DIR/2.raw,format=$IMGFMT,if=none,id=drive2" <<EOF |
98 |
{ "execute": "qmp_capabilities" } |
99 |
{ "execute": "blockdev-add", |
100 |
"arguments": { |
101 |
"options": { |
102 |
"driver": "quorum", |
103 |
"id": "drive0-quorum", |
104 |
"vote-threshold": 2, |
105 |
"children": [ |
106 |
{ |
107 |
"driver": "raw", |
108 |
"file": { |
109 |
"driver": "file", |
110 |
"filename": "$TEST_DIR/1.raw" |
111 |
} |
112 |
}, |
113 |
"drive2", |
114 |
{ |
115 |
"driver": "raw", |
116 |
"file": { |
117 |
"driver": "file", |
118 |
"filename": "$TEST_DIR/3.raw" |
119 |
} |
120 |
} |
121 |
] |
122 |
} |
123 |
} |
124 |
} |
125 |
{ "execute": "human-monitor-command", |
126 |
"arguments": { |
127 |
"command-line": 'qemu-io drive0-quorum "read -P 0x32 0 $size"' |
128 |
} |
129 |
} |
130 |
{ "execute": "quit" } |
131 |
EOF |
132 |
|
133 |
echo |
134 |
echo "== breaking quorum ==" |
135 |
|
136 |
$QEMU_IO -c "write -P 0x41 0 $size" "$TEST_DIR/1.raw" | _filter_qemu_io |
137 |
echo |
138 |
echo "== checking that quorum is broken ==" |
139 |
|
140 |
$QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io |
141 |
|
142 |
|
143 |
# success, all done |
144 |
echo "*** done" |
145 |
rm -f $seq.full |
146 |
status=0 |