tests: Drop dead test-parallel-nbd requirement
[nbdkit/ericb.git] / tests / test-parallel-nbd.sh
blob36088fa1fd2f81c87f4d0f5dcb7f59f112ca6304
1 #!/usr/bin/env bash
2 # nbdkit
3 # Copyright (C) 2017-2018 Red Hat Inc.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
7 # met:
9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
12 # * Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
16 # * Neither the name of Red Hat nor the names of its contributors may be
17 # used to endorse or promote products derived from this software without
18 # specific prior written permission.
20 # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND
21 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR
24 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
27 # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30 # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 # SUCH DAMAGE.
33 source ./functions.sh
35 # Check file-data was created by Makefile and qemu-io exists.
36 requires test -f file-data
37 requires qemu-io --version
39 sock=`mktemp -u`
40 files="test-parallel-nbd.out $sock test-parallel-nbd.data test-parallel-nbd.pid"
41 rm -f $files
42 cleanup_fn rm -f $files
44 # Populate file, and sanity check that qemu-io can issue parallel requests
45 printf '%1024s' . > test-parallel-nbd.data
46 qemu-io -f raw -c "aio_write -P 1 0 512" -c "aio_write -P 2 512 512" \
47 -c aio_flush test-parallel-nbd.data ||
48 { echo "'qemu-io' can't drive parallel requests"; exit 77; }
50 # Set up the file plugin to delay both reads and writes (for a good chance
51 # that parallel requests are in flight), and with writes longer than reads
52 # (to more easily detect if out-of-order completion happens). This test
53 # may have spurious failures under heavy loads on the test machine, where
54 # tuning the delays may help.
56 start_nbdkit -P test-parallel-nbd.pid \
57 -U $sock \
58 --filter=delay \
59 file test-parallel-nbd.data wdelay=2 rdelay=1
61 # With --threads=1, the write should complete first because it was issued first
62 nbdkit -v -t 1 -U - nbd socket=$sock --run '
63 qemu-io -f raw -c "aio_write -P 2 512 512" -c "aio_read -P 1 0 512" \
64 -c aio_flush $nbd' | tee test-parallel-nbd.out
65 if test "$(grep '512/512' test-parallel-nbd.out)" != \
66 "wrote 512/512 bytes at offset 512
67 read 512/512 bytes at offset 0"; then
68 exit 1
71 # With default --threads, the faster read should complete first
72 nbdkit -v -U - nbd socket=$sock --run '
73 qemu-io -f raw -c "aio_write -P 2 512 512" -c "aio_read -P 1 0 512" \
74 -c aio_flush $nbd' | tee test-parallel-nbd.out
75 if test "$(grep '512/512' test-parallel-nbd.out)" != \
76 "read 512/512 bytes at offset 0
77 wrote 512/512 bytes at offset 512"; then
78 exit 1