Blame SOURCES/kvm-nbd-Add-some-error-case-testing-to-iotests-223.patch

7711c0
From 0237c861ddbb4584443c45436c53e0282ecc10fd Mon Sep 17 00:00:00 2001
7711c0
From: John Snow <jsnow@redhat.com>
7711c0
Date: Wed, 27 Mar 2019 17:22:26 +0100
7711c0
Subject: [PATCH 087/163] nbd: Add some error case testing to iotests 223
7711c0
7711c0
RH-Author: John Snow <jsnow@redhat.com>
7711c0
Message-id: <20190327172308.31077-14-jsnow@redhat.com>
7711c0
Patchwork-id: 85175
7711c0
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 13/55] nbd: Add some error case testing to iotests 223
7711c0
Bugzilla: 1691009
7711c0
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
7711c0
RH-Acked-by: Max Reitz <mreitz@redhat.com>
7711c0
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
7711c0
From: Eric Blake <eblake@redhat.com>
7711c0
7711c0
Testing success paths is important, but it's also nice to highlight
7711c0
expected failure handling, to show that we don't crash, and so that
7711c0
upcoming tests that change behavior can demonstrate the resulting
7711c0
effects on error paths.
7711c0
7711c0
Add the following errors:
7711c0
Attempting to export without a running server
7711c0
Attempting to start a second server
7711c0
Attempting to export a bad node name
7711c0
Attempting to export a name that is already exported
7711c0
Attempting to export an enabled bitmap
7711c0
Attempting to remove an already removed export
7711c0
Attempting to quit server a second time
7711c0
7711c0
All of these properly complain except for a second server-stop,
7711c0
which will be fixed next.
7711c0
7711c0
Signed-off-by: Eric Blake <eblake@redhat.com>
7711c0
Message-Id: <20190111194720.15671-2-eblake@redhat.com>
7711c0
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
7711c0
(cherry picked from commit 2d2fd67428f0cfbffea16969d2635af3e2d78d3d)
7711c0
Signed-off-by: John Snow <jsnow@redhat.com>
7711c0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
---
7711c0
 tests/qemu-iotests/223     | 19 +++++++++++++++++--
7711c0
 tests/qemu-iotests/223.out |  7 +++++++
7711c0
 2 files changed, 24 insertions(+), 2 deletions(-)
7711c0
7711c0
diff --git a/tests/qemu-iotests/223 b/tests/qemu-iotests/223
7711c0
index 5513dc6..61b46a2 100755
7711c0
--- a/tests/qemu-iotests/223
7711c0
+++ b/tests/qemu-iotests/223
7711c0
@@ -107,6 +107,7 @@ echo
7711c0
 
7711c0
 _launch_qemu 2> >(_filter_nbd)
7711c0
 
7711c0
+# Intentionally provoke some errors as well, to check error handling
7711c0
 silent=
7711c0
 _send_qemu_cmd $QEMU_HANDLE '{"execute":"qmp_capabilities"}' "return"
7711c0
 _send_qemu_cmd $QEMU_HANDLE '{"execute":"blockdev-add",
7711c0
@@ -114,18 +115,29 @@ _send_qemu_cmd $QEMU_HANDLE '{"execute":"blockdev-add",
7711c0
     "file":{"driver":"file", "filename":"'"$TEST_IMG"'"}}}' "return"
7711c0
 _send_qemu_cmd $QEMU_HANDLE '{"execute":"block-dirty-bitmap-disable",
7711c0
   "arguments":{"node":"n", "name":"b"}}' "return"
7711c0
-_send_qemu_cmd $QEMU_HANDLE '{"execute":"block-dirty-bitmap-disable",
7711c0
-  "arguments":{"node":"n", "name":"b2"}}' "return"
7711c0
+_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-add",
7711c0
+  "arguments":{"device":"n"}}' "error" # Attempt add without server
7711c0
 _send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-start",
7711c0
   "arguments":{"addr":{"type":"unix",
7711c0
     "data":{"path":"'"$TEST_DIR/nbd"'"}}}}' "return"
7711c0
+_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-start",
7711c0
+  "arguments":{"addr":{"type":"unix",
7711c0
+    "data":{"path":"'"$TEST_DIR/nbd"1'"}}}}' "error" # Attempt second server
7711c0
 _send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-add",
7711c0
   "arguments":{"device":"n"}}' "return"
7711c0
+_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-add",
7711c0
+  "arguments":{"device":"nosuch"}}' "error" # Attempt to export missing node
7711c0
+_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-add",
7711c0
+  "arguments":{"device":"n"}}' "error" # Attempt to export same name twice
7711c0
 _send_qemu_cmd $QEMU_HANDLE '{"execute":"x-nbd-server-add-bitmap",
7711c0
   "arguments":{"name":"n", "bitmap":"b"}}' "return"
7711c0
 _send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-add",
7711c0
   "arguments":{"device":"n", "name":"n2"}}' "return"
7711c0
 _send_qemu_cmd $QEMU_HANDLE '{"execute":"x-nbd-server-add-bitmap",
7711c0
+  "arguments":{"name":"n2", "bitmap":"b2"}}' "error" # Attempt enabled bitmap
7711c0
+_send_qemu_cmd $QEMU_HANDLE '{"execute":"block-dirty-bitmap-disable",
7711c0
+  "arguments":{"node":"n", "name":"b2"}}' "return"
7711c0
+_send_qemu_cmd $QEMU_HANDLE '{"execute":"x-nbd-server-add-bitmap",
7711c0
   "arguments":{"name":"n2", "bitmap":"b2"}}' "return"
7711c0
 
7711c0
 echo
7711c0
@@ -157,7 +169,10 @@ _send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-remove",
7711c0
   "arguments":{"name":"n"}}' "return"
7711c0
 _send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-remove",
7711c0
   "arguments":{"name":"n2"}}' "return"
7711c0
+_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-remove",
7711c0
+  "arguments":{"name":"n2"}}' "error" # Attempt duplicate clean
7711c0
 _send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-stop"}' "return"
7711c0
+_send_qemu_cmd $QEMU_HANDLE '{"execute":"nbd-server-stop"}' "return" # Oops
7711c0
 _send_qemu_cmd $QEMU_HANDLE '{"execute":"quit"}' "return"
7711c0
 
7711c0
 # success, all done
7711c0
diff --git a/tests/qemu-iotests/223.out b/tests/qemu-iotests/223.out
7711c0
index de41747..c1eed62 100644
7711c0
--- a/tests/qemu-iotests/223.out
7711c0
+++ b/tests/qemu-iotests/223.out
7711c0
@@ -27,10 +27,15 @@ wrote 2097152/2097152 bytes at offset 2097152
7711c0
 {"return": {}}
7711c0
 {"return": {}}
7711c0
 {"return": {}}
7711c0
+{"error": {"class": "GenericError", "desc": "NBD server not running"}}
7711c0
 {"return": {}}
7711c0
+{"error": {"class": "GenericError", "desc": "NBD server already running"}}
7711c0
 {"return": {}}
7711c0
+{"error": {"class": "GenericError", "desc": "Cannot find device=nosuch nor node_name=nosuch"}}
7711c0
+{"error": {"class": "GenericError", "desc": "NBD server already has export named 'n'"}}
7711c0
 {"return": {}}
7711c0
 {"return": {}}
7711c0
+{"error": {"class": "GenericError", "desc": "Bitmap 'b2' is enabled"}}
7711c0
 {"return": {}}
7711c0
 {"return": {}}
7711c0
 
7711c0
@@ -62,6 +67,8 @@ read 2097152/2097152 bytes at offset 2097152
7711c0
 
7711c0
 {"return": {}}
7711c0
 {"return": {}}
7711c0
+{"error": {"class": "GenericError", "desc": "Export 'n2' is not found"}}
7711c0
+{"return": {}}
7711c0
 {"return": {}}
7711c0
 {"return": {}}
7711c0
 *** done
7711c0
-- 
7711c0
1.8.3.1
7711c0