Skip to contentSkip to conversation

enhance iotest 223 coverage

PATCH In review Eric Blake 3 participants 10 messages Sep 24, 2019 – Oct 8, 2019

lore
Share & tools
lore

Eric Blake

author
#0 lore raw

cover enhance iotest 223 coverage

Commit 506902c6 dropped non-iothread coverage in order to test iothread, better is to run things twice. In doing this, I found it easier to edit the test when the log shows what commands were triggering various responses.

Eric Blake (2):
tests: Make iotest 223 easier to edit
tests: More iotest 223 improvements

 tests/qemu-iotests/223     | 114 ++++++++++++++++++++++++------
 tests/qemu-iotests/223.out | 138 +++++++++++++++++++++++++++++++++++++
 2 files changed, 231 insertions(+), 21 deletions(-)
Signature · 1 line
2.21.0
author
#1 lore raw

PATCH 1/2 tests: Make iotest 223 easier to edit

Log the QMP input to qemu, not just the QMP output.

---
 tests/qemu-iotests/223     | 48 +++++++++++++++++++++-----------------
 tests/qemu-iotests/223.out | 40 +++++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+), 21 deletions(-)
tests/qemu-iotests/223 +27 -21
index 2ba3d8124b4f..2bcf922df8c4 100755
@@ -58,6 +58,12 @@ run_qemu()
                           | _filter_actual_image_size
 }
 
+qemu_cmd()
+{
+    echo " $1" | _filter_testdir
+    _send_qemu_cmd $QEMU_HANDLE "$@"
+}
+
 echo
 echo "=== Create partially sparse image, then add dirty bitmaps ==="
 echo
@@ -110,39 +116,39 @@ echo "=== End dirty bitmaps, and start serving image over NBD ==="
 echo
 
 _launch_qemu -object iothread,id=io0 2> >(_filter_nbd)
-
-# Intentionally provoke some errors as well, to check error handling
 silent=
-_send_qemu_cmd $QEMU_HANDLE '{"execute":"qmp_capabilities"}' "return"
-_send_qemu_cmd $QEMU_HANDLE '{"execute":"blockdev-add",
+
+# Intentionally provoke some errors as well, to check error handling
+qemu_cmd '{"execute":"qmp_capabilities"}' "return"
+qemu_cmd '{"execute":"blockdev-add",
   "arguments":{"driver":"qcow2", "node-name":"n",
     "file":{"driver":"file", "filename":"'"$TEST_IMG"'"}}}' "return"
-_send_qemu_cmd $QEMU_HANDLE '{"execute":"x-blockdev-set-iothread",
+qemu_cmd '{"execute":"x-blockdev-set-iothread",
   "arguments":{"node-name":"n", "iothread":"io0"}}' "return"
-_send_qemu_cmd $QEMU_HANDLE '{"execute":"block-dirty-bitmap-disable",
+qemu_cmd '{"execute":"block-dirty-bitmap-disable",
   "arguments":{"node":"n", "name":"b"}}' "return"
-_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-add",
+qemu_cmd '{"execute":"nbd-server-add",
   "arguments":{"device":"n"}}' "error" # Attempt add without server
-_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-start",
+qemu_cmd '{"execute":"nbd-server-start",
   "arguments":{"addr":{"type":"unix",
     "data":{"path":"'"$TEST_DIR/nbd"'"}}}}' "return"
-_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-start",
+qemu_cmd '{"execute":"nbd-server-start",
   "arguments":{"addr":{"type":"unix",
     "data":{"path":"'"$TEST_DIR/nbd"1'"}}}}' "error" # Attempt second server
 $QEMU_NBD_PROG -L -k "$TEST_DIR/nbd"
-_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-add",
+qemu_cmd '{"execute":"nbd-server-add",
   "arguments":{"device":"n", "bitmap":"b"}}' "return"
-_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-add",
+qemu_cmd '{"execute":"nbd-server-add",
   "arguments":{"device":"nosuch"}}' "error" # Attempt to export missing node
-_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-add",
+qemu_cmd '{"execute":"nbd-server-add",
   "arguments":{"device":"n"}}' "error" # Attempt to export same name twice
-_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-add",
+qemu_cmd '{"execute":"nbd-server-add",
   "arguments":{"device":"n", "name":"n2",
   "bitmap":"b2"}}' "error" # enabled vs. read-only
-_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-add",
+qemu_cmd '{"execute":"nbd-server-add",
   "arguments":{"device":"n", "name":"n2",
   "bitmap":"b3"}}' "error" # Missing bitmap
-_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-add",
+qemu_cmd '{"execute":"nbd-server-add",
   "arguments":{"device":"n", "name":"n2", "writable":true,
   "bitmap":"b2"}}' "return"
 $QEMU_NBD_PROG -L -k "$TEST_DIR/nbd"
@@ -172,15 +178,15 @@ echo
 echo "=== End qemu NBD server ==="
 echo
 
-_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-remove",
+qemu_cmd '{"execute":"nbd-server-remove",
   "arguments":{"name":"n"}}' "return"
-_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-remove",
+qemu_cmd '{"execute":"nbd-server-remove",
   "arguments":{"name":"n2"}}' "return"
-_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-remove",
+qemu_cmd '{"execute":"nbd-server-remove",
   "arguments":{"name":"n2"}}' "error" # Attempt duplicate clean
-_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-stop"}' "return"
-_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-stop"}' "error" # Again
-_send_qemu_cmd $QEMU_HANDLE '{"execute":"quit"}' "return"
+qemu_cmd '{"execute":"nbd-server-stop"}' "return"
+qemu_cmd '{"execute":"nbd-server-stop"}' "error" # Again
+qemu_cmd '{"execute":"quit"}' "return"
 wait=yes _cleanup_qemu
 
 echo
tests/qemu-iotests/223.out +40 -0
index 23b34fcd202e..8895ea838cbb 100644
@@ -24,19 +24,50 @@ wrote 2097152/2097152 bytes at offset 2097152
 
 === End dirty bitmaps, and start serving image over NBD ===
 
+ {"execute":"qmp_capabilities"}
 {"return": {}}
+ {"execute":"blockdev-add",
+  "arguments":{"driver":"qcow2", "node-name":"n",
+    "file":{"driver":"file", "filename":"TEST_DIR/t.qcow2"}}}
 {"return": {}}
+ {"execute":"x-blockdev-set-iothread",
+  "arguments":{"node-name":"n", "iothread":"io0"}}
 {"return": {}}
+ {"execute":"block-dirty-bitmap-disable",
+  "arguments":{"node":"n", "name":"b"}}
 {"return": {}}
+ {"execute":"nbd-server-add",
+  "arguments":{"device":"n"}}
 {"error": {"class": "GenericError", "desc": "NBD server not running"}}
+ {"execute":"nbd-server-start",
+  "arguments":{"addr":{"type":"unix",
+    "data":{"path":"TEST_DIR/nbd"}}}}
 {"return": {}}
+ {"execute":"nbd-server-start",
+  "arguments":{"addr":{"type":"unix",
+    "data":{"path":"TEST_DIR/nbd1"}}}}
 {"error": {"class": "GenericError", "desc": "NBD server already running"}}
 exports available: 0
+ {"execute":"nbd-server-add",
+  "arguments":{"device":"n", "bitmap":"b"}}
 {"return": {}}
+ {"execute":"nbd-server-add",
+  "arguments":{"device":"nosuch"}}
 {"error": {"class": "GenericError", "desc": "Cannot find device=nosuch nor node_name=nosuch"}}
+ {"execute":"nbd-server-add",
+  "arguments":{"device":"n"}}
 {"error": {"class": "GenericError", "desc": "NBD server already has export named 'n'"}}
+ {"execute":"nbd-server-add",
+  "arguments":{"device":"n", "name":"n2",
+  "bitmap":"b2"}}
 {"error": {"class": "GenericError", "desc": "Enabled bitmap 'b2' incompatible with readonly export"}}
+ {"execute":"nbd-server-add",
+  "arguments":{"device":"n", "name":"n2",
+  "bitmap":"b3"}}
 {"error": {"class": "GenericError", "desc": "Bitmap 'b3' is not found"}}
+ {"execute":"nbd-server-add",
+  "arguments":{"device":"n", "name":"n2", "writable":true,
+  "bitmap":"b2"}}
 {"return": {}}
 exports available: 2
  export: 'n'
@@ -84,11 +115,20 @@ read 2097152/2097152 bytes at offset 2097152
 
 === End qemu NBD server ===
 
+ {"execute":"nbd-server-remove",
+  "arguments":{"name":"n"}}
 {"return": {}}
+ {"execute":"nbd-server-remove",
+  "arguments":{"name":"n2"}}
 {"return": {}}
+ {"execute":"nbd-server-remove",
+  "arguments":{"name":"n2"}}
 {"error": {"class": "GenericError", "desc": "Export 'n2' is not found"}}
+ {"execute":"nbd-server-stop"}
 {"return": {}}
+ {"execute":"nbd-server-stop"}
 {"error": {"class": "GenericError", "desc": "NBD server not running"}}
+ {"execute":"quit"}
 {"return": {}}
 {"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}}
 
Signature · 1 line
2.21.0
#2 lore raw

Re: [PATCH 1/2] tests: Make iotest 223 easier to edit

Quoted 1 line · Eric Blake

Log the QMP input to qemu, not just the QMP output.

Why not just add this functionality to _send_qemu_cmd directly? (Like silent already does for replies, although it’s inverted.)

(Although I’m not quite sold on the indentation for commands, because
(1) we don’t do that in other tests, (2) I’d prefer some prefix like ->/<-, and (3) there is generally no need because commands start with “execute” and replies start with “return”, “error”, or “event”, so they already have clear prefixes to distinguish the two classes.)

Max

Quoted 5 lines
---
 tests/qemu-iotests/223     | 48 +++++++++++++++++++++-----------------
 tests/qemu-iotests/223.out | 40 +++++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+), 21 deletions(-)
author
#3 lore raw

Re: [PATCH 1/2] tests: Make iotest 223 easier to edit

Quoted 5 lines · Max Reitz
Quoted 1 line · Eric Blake

Log the QMP input to qemu, not just the QMP output.

Why not just add this functionality to _send_qemu_cmd directly? (Like silent already does for replies, although it’s inverted.)

Interesting idea. I'll give it a shot (it may have a larger effect on more .out files, but that's probably a good thing).

Quoted 6 lines

(Although I’m not quite sold on the indentation for commands, because
(1) we don’t do that in other tests, (2) I’d prefer some prefix like ->/<-, and (3) there is generally no need because commands start with “execute” and replies start with “return”, “error”, or “event”, so they already have clear prefixes to distinguish the two classes.)

I don't mind avoiding indentation; as you say, direction can be inferred by contents.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#4 lore raw

Re: [PATCH 1/2] tests: Make iotest 223 easier to edit

Quoted 9 lines · Eric Blake
Quoted 5 lines · Max Reitz
Quoted 1 line · Eric Blake

Log the QMP input to qemu, not just the QMP output.

Why not just add this functionality to _send_qemu_cmd directly?  (Like silent already does for replies, although it’s inverted.)

Interesting idea.  I'll give it a shot (it may have a larger effect on more .out files, but that's probably a good thing).

I was thinking about making it conditional, like it’s done with the $silent parameter. But I mean, there is actually no good reason for it to print the output but omit the input, I suppose... (Other than that this change will affect many .out files, as you say)

Max

Quoted 9 lines
Quoted 5 lines

(Although I’m not quite sold on the indentation for commands, because
(1) we don’t do that in other tests, (2) I’d prefer some prefix like ->/<-, and (3) there is generally no need because commands start with “execute” and replies start with “return”, “error”, or “event”, so they already have clear prefixes to distinguish the two classes.)

I don't mind avoiding indentation; as you say, direction can be inferred by contents.

author
#5 lore raw

PATCH 2/2 tests: More iotest 223 improvements

In reply to Eric Blake

Run the test twice, once without iothreads, and again with, for more coverage of both setups.

---
 tests/qemu-iotests/223     | 66 +++++++++++++++++++++++++
 tests/qemu-iotests/223.out | 98 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 164 insertions(+)
tests/qemu-iotests/223 +66 -0
index 2bcf922df8c4..2aa428d406f5 100755
@@ -123,6 +123,72 @@ qemu_cmd '{"execute":"qmp_capabilities"}' "return"
 qemu_cmd '{"execute":"blockdev-add",
   "arguments":{"driver":"qcow2", "node-name":"n",
     "file":{"driver":"file", "filename":"'"$TEST_IMG"'"}}}' "return"
+qemu_cmd '{"execute":"block-dirty-bitmap-disable",
+  "arguments":{"node":"n", "name":"b"}}' "return"
+qemu_cmd '{"execute":"nbd-server-add",
+  "arguments":{"device":"n"}}' "error" # Attempt add without server
+qemu_cmd '{"execute":"nbd-server-start",
+  "arguments":{"addr":{"type":"unix",
+    "data":{"path":"'"$TEST_DIR/nbd"'"}}}}' "return"
+qemu_cmd '{"execute":"nbd-server-start",
+  "arguments":{"addr":{"type":"unix",
+    "data":{"path":"'"$TEST_DIR/nbd"1'"}}}}' "error" # Attempt second server
+$QEMU_NBD_PROG -L -k "$TEST_DIR/nbd"
+qemu_cmd '{"execute":"nbd-server-add",
+  "arguments":{"device":"n", "bitmap":"b"}}' "return"
+qemu_cmd '{"execute":"nbd-server-add",
+  "arguments":{"device":"nosuch"}}' "error" # Attempt to export missing node
+qemu_cmd '{"execute":"nbd-server-add",
+  "arguments":{"device":"n"}}' "error" # Attempt to export same name twice
+qemu_cmd '{"execute":"nbd-server-add",
+  "arguments":{"device":"n", "name":"n2",
+  "bitmap":"b2"}}' "error" # enabled vs. read-only
+qemu_cmd '{"execute":"nbd-server-add",
+  "arguments":{"device":"n", "name":"n2",
+  "bitmap":"b3"}}' "error" # Missing bitmap
+qemu_cmd '{"execute":"nbd-server-add",
+  "arguments":{"device":"n", "name":"n2", "writable":true,
+  "bitmap":"b2"}}' "return"
+$QEMU_NBD_PROG -L -k "$TEST_DIR/nbd"
+
+echo
+echo "=== Contrast normal status to large granularity dirty-bitmap ==="
+echo
+
+QEMU_IO_OPTIONS=$QEMU_IO_OPTIONS_NO_FMT
+IMG="driver=nbd,export=n,server.type=unix,server.path=$TEST_DIR/nbd"
+$QEMU_IO -r -c 'r -P 0x22 512 512' -c 'r -P 0 512k 512k' -c 'r -P 0x11 1m 1m' \
+  -c 'r -P 0x33 2m 2m' --image-opts "$IMG" | _filter_qemu_io
+$QEMU_IMG map --output=json --image-opts \
+  "$IMG" | _filter_qemu_img_map
+$QEMU_IMG map --output=json --image-opts \
+  "$IMG,x-dirty-bitmap=qemu:dirty-bitmap:b" | _filter_qemu_img_map
+
+echo
+echo "=== Contrast to small granularity dirty-bitmap ==="
+echo
+
+IMG="driver=nbd,export=n2,server.type=unix,server.path=$TEST_DIR/nbd"
+$QEMU_IMG map --output=json --image-opts \
+  "$IMG,x-dirty-bitmap=qemu:dirty-bitmap:b2" | _filter_qemu_img_map
+
+echo
+echo "=== End qemu NBD server ==="
+echo
+
+qemu_cmd '{"execute":"nbd-server-remove",
+  "arguments":{"name":"n"}}' "return"
+qemu_cmd '{"execute":"nbd-server-remove",
+  "arguments":{"name":"n2"}}' "return"
+qemu_cmd '{"execute":"nbd-server-remove",
+  "arguments":{"name":"n2"}}' "error" # Attempt duplicate clean
+qemu_cmd '{"execute":"nbd-server-stop"}' "return"
+qemu_cmd '{"execute":"nbd-server-stop"}' "error" # Again
+
+echo
+echo "=== Repeat, but using iothreads ==="
+echo
+
 qemu_cmd '{"execute":"x-blockdev-set-iothread",
   "arguments":{"node-name":"n", "iothread":"io0"}}' "return"
 qemu_cmd '{"execute":"block-dirty-bitmap-disable",
tests/qemu-iotests/223.out +98 -0

104 lines not on this page · raw message

Signature · 1 line
2.21.0
#6 lore raw

Re: [PATCH 2/2] tests: More iotest 223 improvements

Quoted 9 lines · Eric Blake

Run the test twice, once without iothreads, and again with, for more coverage of both setups.

---
 tests/qemu-iotests/223     | 66 +++++++++++++++++++++++++
 tests/qemu-iotests/223.out | 98 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 164 insertions(+)

I think this can be done easier by just having a “for i in 0 1” loop span the range from block-dirty-bitmap-disable to nbd-server-stop (and then, at the end of the first iteration, do the x-blockdev-set-iothread).

Max

#7 lore raw
In reply to Eric Blake
Quoted 4 lines · Eric Blake

Commit 506902c6 dropped non-iothread coverage in order to test iothread, better is to run things twice. In doing this, I found it easier to edit the test when the log shows what commands were triggering various responses.

Did you consider adding -iothread to tests/qemu-iotests/check instead, to be able to run any (or some) tests with or without iothread?

Quoted 9 lines

Eric Blake (2):
tests: Make iotest 223 easier to edit
tests: More iotest 223 improvements

  tests/qemu-iotests/223     | 114 ++++++++++++++++++++++++------
  tests/qemu-iotests/223.out | 138 +++++++++++++++++++++++++++++++++++++
  2 files changed, 231 insertions(+), 21 deletions(-)
Signature · 2 lines
Best regards,
Vladimir
author
#8 lore raw
Quoted 8 lines · Vladimir Sementsov-Ogievskiy
Quoted 4 lines · Eric Blake

Commit 506902c6 dropped non-iothread coverage in order to test iothread, better is to run things twice. In doing this, I found it easier to edit the test when the log shows what commands were triggering various responses.

Did you consider adding -iothread to tests/qemu-iotests/check instead, to be able to run any (or some) tests with or without iothread?

I don't know how many of the existing iotests would benefit from the ability supply iothread as an option, nor how likely it is that someone would actually remember to run the testsuite twice to cover the use of that option. I also don't know how hard it would be to retrofit the addition of optional iothread support into all the tests. Rather, I addressed the more immediate concern of the fact that my recent addition to using iothread in 223 lost the previous ability of that test to cover non-iothread, and where this patch series now makes it cover both scenarios with a single iotests run.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#9 lore raw
Quoted 7 lines · Eric Blake
Quoted 6 lines · Vladimir Sementsov-Ogievskiy
Quoted 4 lines · Eric Blake

Commit 506902c6 dropped non-iothread coverage in order to test iothread, better is to run things twice. In doing this, I found it easier to edit the test when the log shows what commands were triggering various responses.

Quoted 7 lines
Quoted 2 lines

Did you consider adding -iothread to tests/qemu-iotests/check instead, to be able to run any (or some) tests with or without iothread?

I don't know how many of the existing iotests would benefit from the ability supply iothread as an option, nor how likely it is that someone would actually remember to run the testsuite twice to cover the use of that option.

I would, because I already run all qcow2 tests without any creation options, with compat=0.10, and with refcount_bits=1. (And plan to add data_file=$TEST_IMG.data_file in the future.)

(And I let the iotests run through a script from some json description files, so I won’t forget.)

Quoted 2 lines

I also don't know how hard it would be to retrofit the addition of optional iothread support into all the tests.

That I don’t know either. Though I think the point wouldn’t be to retrofit iothread support into all tests, but just start with some. (For example, 262 uses “an iothread just for fun”. So it could clearly run with both configurations.)

I do think it’s an interesting idea, but I don’t think it’s important right now.

Max

Quoted 6 lines

Rather, I
addressed the more immediate concern of the fact that my recent addition to using iothread in 223 lost the previous ability of that test to cover non-iothread, and where this patch series now makes it cover both scenarios with a single iotests run.