3 # Test Quorum block driver
5 # Copyright (C) 2013 Nodalink, SARL.
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.
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.
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/>.
22 owner
=benoit@irqsave.net
25 echo "QA output created by $seq"
27 status
=1 # failure is the default!
31 _rm_test_img
"$TEST_DIR/1.raw"
32 _rm_test_img
"$TEST_DIR/2.raw"
33 _rm_test_img
"$TEST_DIR/3.raw"
35 trap "_cleanup; exit \$status" 0 1 2 3 15
37 # get standard environment, filters and checks
44 _require_drivers quorum
48 echo Testing
: "$@" | _filter_imgfmt
49 $QEMU -nographic -qmp stdio
-serial none
"$@"
55 do_run_qemu
"$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_qmp\
56 | _filter_qemu_io | _filter_generated_node_ids
59 quorum
="driver=raw,file.driver=quorum,file.vote-threshold=2"
60 quorum
="$quorum,file.children.0.file.filename=$TEST_DIR/1.raw"
61 quorum
="$quorum,file.children.1.file.filename=$TEST_DIR/2.raw"
62 quorum
="$quorum,file.children.2.file.filename=$TEST_DIR/3.raw"
63 quorum
="$quorum,file.children.0.driver=raw"
64 quorum
="$quorum,file.children.1.driver=raw"
65 quorum
="$quorum,file.children.2.driver=raw"
68 echo "== creating quorum files =="
72 TEST_IMG
="$TEST_DIR/1.raw" _make_test_img
$size
73 TEST_IMG
="$TEST_DIR/2.raw" _make_test_img
$size
74 TEST_IMG
="$TEST_DIR/3.raw" _make_test_img
$size
77 echo "== writing images =="
79 $QEMU_IO -c "open -o $quorum" -c "write -P 0x32 0 $size" | _filter_qemu_io
82 echo "== checking quorum write =="
84 $QEMU_IO -c "read -P 0x32 0 $size" "$TEST_DIR/1.raw" | _filter_qemu_io
85 $QEMU_IO -c "read -P 0x32 0 $size" "$TEST_DIR/2.raw" | _filter_qemu_io
86 $QEMU_IO -c "read -P 0x32 0 $size" "$TEST_DIR/3.raw" | _filter_qemu_io
89 echo "== corrupting image =="
91 $QEMU_IO -c "write -P 0x42 0 $size" "$TEST_DIR/2.raw" | _filter_qemu_io
94 echo "== checking quorum correction =="
96 $QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io
99 echo "== checking mixed reference/option specification =="
102 { "execute": "qmp_capabilities" }
103 { "execute": "blockdev-add",
105 "node-name": "drive2",
109 "filename": "$TEST_DIR/2.raw"
113 { "execute": "blockdev-add",
116 "node-name": "drive0-quorum",
123 "filename": "$TEST_DIR/1.raw"
131 "filename": "$TEST_DIR/3.raw"
137 { "execute": "human-monitor-command",
139 "command-line": 'qemu-io drive0-quorum "read -P 0x32 0 $size"'
142 { "execute": "quit" }
146 echo "== using quorum rewrite corrupted mode =="
148 quorum
="$quorum,file.rewrite-corrupted=on"
150 $QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io
153 echo "== checking that quorum has corrected the corrupted file =="
155 $QEMU_IO -c "read -P 0x32 0 $size" "$TEST_DIR/2.raw" | _filter_qemu_io
158 echo "== breaking quorum =="
160 $QEMU_IO -c "write -P 0x41 0 $size" "$TEST_DIR/1.raw" | _filter_qemu_io
161 $QEMU_IO -c "write -P 0x42 0 $size" "$TEST_DIR/2.raw" | _filter_qemu_io
164 echo "== checking that quorum is broken =="
166 $QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io
169 echo "== checking the blkverify mode with broken content =="
171 quorum
="driver=raw,file.driver=quorum,file.vote-threshold=2,file.blkverify=on"
172 quorum
="$quorum,file.children.0.file.filename=$TEST_DIR/1.raw"
173 quorum
="$quorum,file.children.1.file.filename=$TEST_DIR/2.raw"
174 quorum
="$quorum,file.children.0.driver=raw"
175 quorum
="$quorum,file.children.1.driver=raw"
177 $QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io
180 echo "== writing the same data to both files =="
182 $QEMU_IO -c "write -P 0x32 0 $size" "$TEST_DIR/1.raw" | _filter_qemu_io
183 $QEMU_IO -c "write -P 0x32 0 $size" "$TEST_DIR/2.raw" | _filter_qemu_io
186 echo "== checking the blkverify mode with valid content =="
188 $QEMU_IO -c "open -o $quorum" -c "read -P 0x32 0 $size" | _filter_qemu_io
191 echo "== checking the blkverify mode with invalid settings =="
193 quorum
="$quorum,file.children.2.file.filename=$TEST_DIR/3.raw"
194 quorum
="$quorum,file.children.2.driver=raw"
196 $QEMU_IO -c "open -o $quorum" | _filter_qemu_io
199 echo "== dynamically adding a child to a quorum =="
201 for verify
in false true
; do
203 { "execute": "qmp_capabilities" }
204 { "execute": "blockdev-add",
207 "node-name": "drive0-quorum",
209 "blkverify": ${verify},
215 "filename": "$TEST_DIR/1.raw"
222 "filename": "$TEST_DIR/2.raw"
228 { "execute": "blockdev-add",
230 "node-name": "drive3",
234 "filename": "$TEST_DIR/2.raw"
238 { "execute": "x-blockdev-change",
239 "arguments": { "parent": "drive0-quorum",
241 { "execute": "quit" }
246 echo "== dynamically removing a child from a quorum =="
248 for verify
in false true
; do
249 for vote_threshold
in 1 2; do
251 { "execute": "qmp_capabilities" }
252 { "execute": "blockdev-add",
255 "node-name": "drive0-quorum",
256 "vote-threshold": ${vote_threshold},
257 "blkverify": ${verify},
263 "filename": "$TEST_DIR/1.raw"
270 "filename": "$TEST_DIR/2.raw"
276 { "execute": "x-blockdev-change",
277 "arguments": { "parent": "drive0-quorum",
278 "child": "children.1" } }
279 { "execute": "quit" }