New upstream development version 1.21.5.

This commit is contained in:
Richard W.M. Jones 2020-05-30 11:14:26 +01:00
parent be87a1d07c
commit 40ac24d0d5
3 changed files with 5 additions and 172 deletions

View File

@ -1,167 +0,0 @@
From 0632acc76bfeb7d70d3eefa42fc842ce6b7be4f8 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Wed, 20 May 2020 13:27:27 +0100
Subject: [PATCH] tests/test-truncate4.sh: Rewrite to use nbdsh.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The old test relied on issuing an asynchronous command to a qemu-io
subprocess, requiring a sleep to ensure that the command had been
carried out. sleep 1 was not long enough on s390x as you can see
from this partial trace:
+ exec
+ qemu-io -f raw nbd:unix:/tmp/tmp.jqOZGj6dnX
+ exec
+ echo 'Reading from connection A, try 1'
Reading from connection A, try 1
+ echo 'r -P 1 0 1024'
+ sleep 1
Above we issue the command and sleep while it executes. However:
nbdkit: debug: accepted connection
nbdkit: file[1]: debug: truncate: preconnect
nbdkit: file[1]: debug: file: preconnect
nbdkit: file[1]: debug: newstyle negotiation: flags: global 0x3
+ echo 'Resizing down'
Resizing down
+ truncate -s 512 truncate4.data
nbdkit: file[1]: debug: newstyle negotiation: client flags: 0x3
nbdkit: file[1]: debug: newstyle negotiation: NBD_OPT_STRUCTURED_REPLY: client requested structured replies
Here are still connecting to nbdkit from "connection A", long after
the sleep has finished and the truncate has been done.
Instead of increasing the sleep and hoping for the best, I chose to
rewrite the test to use nbdsh. This allows us to control both
connections from a single process, making the test predicatable and
easier to understand.
---
tests/test-truncate4.sh | 85 +++++++++++++++++++++++++----------------
1 file changed, 53 insertions(+), 32 deletions(-)
diff --git a/tests/test-truncate4.sh b/tests/test-truncate4.sh
index e4be626b..36b2743c 100755
--- a/tests/test-truncate4.sh
+++ b/tests/test-truncate4.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# nbdkit
-# Copyright (C) 2019 Red Hat Inc.
+# Copyright (C) 2019-2020 Red Hat Inc.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -31,55 +31,76 @@
# SUCH DAMAGE.
# Regression test when next_ops->get_size changes between connections.
+#
# For now, NBD does not support dynamic resize; but the file plugin
# reads size from the file system for each new connection, at which
# point the client remembers that size for the life of the connection.
+#
# We are testing that connection A can still see the tail of a file,
# even when connection B is opened while the file was temporarily
-# shorter (if the actions of connection B affect the size visible
-# through connection A, we didn't isolate per-connection state).
+# shorter. If the actions of connection B affect the size visible
+# through connection A, we didn't isolate per-connection state.
source ./functions.sh
set -e
set -x
-requires qemu-io --version
+requires nbdsh --version
sock=`mktemp -u`
-files="truncate4.out truncate4.pid $sock truncate4.data"
+data=truncate4.data
+files="truncate4.pid $sock $data"
rm -f $files
cleanup_fn rm -f $files
-# Initial file contents: 1k of pattern 1
-truncate -s 1024 truncate4.data
-qemu-io -c 'w -P 1 0 1024' -f raw truncate4.data
+# Create and truncate the file.
+: > $data
# Run nbdkit with file plugin and truncate filter in front.
start_nbdkit -P truncate4.pid -U $sock \
--filter=truncate \
- file truncate4.data \
+ file $data \
round-up=1024
-fail=0
-exec 4>&1 # Save original stdout
-{
- exec 5>&1 >&4 # Save connection A, set stdout back to original
- echo 'Reading from connection A, try 1'
- echo 'r -P 1 0 1024' >&5
- sleep 1
- echo 'Resizing down'
- truncate -s 512 truncate4.data
- echo 'Reading from connection B'
- echo 'r -P 1 0 512' | qemu-io -f raw nbd:unix:$sock >> truncate4.out
- echo 'Restoring size'
- truncate -s 1024 truncate4.data
- qemu-io -c 'w -P 2 0 1024' -f raw truncate4.data
- echo 'Reading from connection A, try 2'
- echo 'r -P 2 512 512' >&5
- echo 'quit' >&5
-} | qemu-io -f raw nbd:unix:$sock >> truncate4.out || fail=1
-exec 4>&-
-
-cat truncate4.out
-grep 'Pattern verification failed' truncate4.out && fail=1
-exit $fail
+export data sock
+nbdsh -c '
+import os
+
+data = os.environ["data"]
+sock = os.environ["sock"]
+
+def restore_file():
+ # Original test data, 1024 bytes of "TEST" repeated.
+ with open (data, "w") as file:
+ file.write ("TEST"*256)
+
+restore_file ()
+
+print ("Connection A.", flush=True)
+connA = nbd.NBD ()
+connA.set_handle_name ("A")
+connA.connect_unix (sock)
+print ("Check the size.", flush=True)
+assert connA.get_size () == 1024
+
+print ("Truncate %s to 512 bytes." % data, flush=True)
+os.truncate (data, 512)
+
+print ("Connection B.", flush=True)
+connB = nbd.NBD ()
+connB.set_handle_name ("B")
+connB.connect_unix (sock)
+print ("Check the size.", flush=True)
+assert connB.get_size () == 1024 # because of the round-up parameter
+print ("Read data from connection B.", flush=True)
+buf = connB.pread (1024, 0)
+assert buf == b"TEST"*128 + b"\0"*512
+
+print ("Restore the file size and original data.", flush=True)
+restore_file ()
+
+print ("Read data from connection A.", flush=True)
+buf = connA.pread (1024, 0)
+assert 1024 == len (buf)
+assert buf == b"TEST"*256
+'
--
2.25.0

View File

@ -58,9 +58,6 @@ Source1: http://libguestfs.org/download/nbdkit/%{source_directory}/%{name
Source2: libguestfs.keyring
%endif
# Upstream patch to make tests/test-truncate4.sh more stable on s390x.
Patch1: 0001-tests-test-truncate4.sh-Rewrite-to-use-nbdsh.patch
%if 0%{patches_touch_autotools}
BuildRequires: autoconf, automake, libtool
%endif
@ -984,6 +981,9 @@ make %{?_smp_mflags} check || {
%changelog
* Sat May 30 2020 Richard W.M. Jones <rjones@redhat.com> - 1.21.5-1
- New upstream development version 1.21.5.
* Tue May 26 2020 Miro Hrončok <mhroncok@redhat.com> - 1.21.4-3
- Rebuilt for Python 3.9

View File

@ -1,2 +1,2 @@
SHA512 (nbdkit-1.21.4.tar.gz) = fd0865b33975df3d3851b9da3ac78d098e4491fc679f4a4c5c82c4952a6e3b7d581a10a81f5bf2d523c9c2663688385ebdf1eb533ca5e05b2f25674ac28987ff
SHA512 (nbdkit-1.21.4.tar.gz.sig) = 166b0f842a548c1a22eff2f3f0c03c456114e2eba44e5c5be2fa2e12546fc19d2716fa05c8e78f57ccee7711ef6ea29ed7854f55566f459537d0f44203293473
SHA512 (nbdkit-1.21.5.tar.gz) = ccd3d4fe4acbc2756ebaebd8c2fd186ed3620ecff813abd7e50c4262aa453cee0f9e1e0120434d0daa0d70d3f512bb568fceb36dfebb2b247633ee12f7411993
SHA512 (nbdkit-1.21.5.tar.gz.sig) = 7e10439b82b34e78689bff8c3f6cb09bdbb546457342a287bfb41e2e80de0a1be24e333ca14a8c497115e0136edb665285bf2265d6733462d6a28a778620f139