[PATCH 2/2] tests: cli: test serial file clone

Oleg Vasilev oleg.vasilev at virtuozzo.com
Fri Dec 2 08:45:11 UTC 2022


Previous commit added serial file clone, now we test it.

Signed-off-by: Oleg Vasilev <oleg.vasilev at virtuozzo.com>
---
 tests/data/cli/compare/virt-clone-serial.xml | 31 ++++++++++++++++++++
 tests/data/cli/virtclone/clone-serial.xml    | 31 ++++++++++++++++++++
 tests/test_cli.py                            |  5 ++--
 3 files changed, 65 insertions(+), 2 deletions(-)
 create mode 100644 tests/data/cli/compare/virt-clone-serial.xml
 create mode 100644 tests/data/cli/virtclone/clone-serial.xml

diff --git a/tests/data/cli/compare/virt-clone-serial.xml b/tests/data/cli/compare/virt-clone-serial.xml
new file mode 100644
index 00000000..9116840d
--- /dev/null
+++ b/tests/data/cli/compare/virt-clone-serial.xml
@@ -0,0 +1,31 @@
+<domain type="test">
+  <name>test-clone1</name>
+  <uuid>00000000-1111-2222-3333-444444444444</uuid>
+  <memory>8388608</memory>
+  <currentMemory>2097152</currentMemory>
+  <vcpu>2</vcpu>
+  <os>
+    <type arch="i686">hvm</type>
+    <boot dev="hd"/>
+  </os>
+  <clock offset="utc"/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <serial type="file">
+      <source path="/tmp/test-clone1.file">
+        <seclabel model="dac" relabel="no"/>
+      </source>
+    </serial>
+    <serial type="file">
+      <source path="/tmp/other-serial-clone.file"/>
+    </serial>
+    <serial type="unix">
+      <source mode="connect" path="/tmp/serial.sock"/>
+    </serial>
+    <console type="file">
+      <source path="/tmp/test-clone.file"/>
+    </console>
+  </devices>
+</domain>
diff --git a/tests/data/cli/virtclone/clone-serial.xml b/tests/data/cli/virtclone/clone-serial.xml
new file mode 100644
index 00000000..17295d48
--- /dev/null
+++ b/tests/data/cli/virtclone/clone-serial.xml
@@ -0,0 +1,31 @@
+<domain type="test">
+  <name>test-clone</name>
+  <uuid>00000000-1111-2222-3333-444444444444</uuid>
+  <memory>8388608</memory>
+  <currentMemory>2097152</currentMemory>
+  <vcpu>2</vcpu>
+  <os>
+    <type arch="i686">hvm</type>
+    <boot dev="hd"/>
+  </os>
+  <clock offset="utc"/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <serial type="file">
+      <source path="/tmp/test-clone.file">
+        <seclabel model="dac" relabel="no"/>
+      </source>
+    </serial>
+    <serial type="file">
+      <source path="/tmp/other-serial.file"/>
+    </serial>
+    <serial type="unix">
+      <source mode="connect" path="/tmp/serial.sock"/>
+    </serial>
+    <console type="file">
+      <source path="/tmp/test.file"/>
+    </console>
+  </devices>
+</domain>
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 3d299c12..d2dab69d 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -1484,6 +1484,7 @@ _CLONE_NVRAM_MISSING = "--original-xml %s/clone-nvram-missing.xml" % _CLONEXMLDI
 _CLONE_EMPTY = "--original-xml %s/clone-empty.xml" % _CLONEXMLDIR
 _CLONE_NET_RBD = "--original-xml %s/clone-net-rbd.xml" % _CLONEXMLDIR
 _CLONE_NET_HTTP = "--original-xml %s/clone-net-http.xml" % _CLONEXMLDIR
+_CLONE_SERIAL = "--original-xml %s/clone-serial.xml" % _CLONEXMLDIR
 
 
 vclon = App("virt-clone")
@@ -1507,6 +1508,7 @@ c.add_compare(_CLONE_EMPTY + " --auto-clone --print-xml", "empty")  # Auto flag,
 c.add_compare("--connect %(URI-KVM-X86)s -o test-clone-simple --auto -f /foo.img --print-xml", "pool-test-cross-pool")  # cross pool cloning which fails with test driver but let's confirm the XML
 c.add_compare(_CLONE_MANAGED + " --auto-clone", "auto-managed")  # Auto flag w/ managed storage
 c.add_compare(_CLONE_UNMANAGED + " --auto-clone", "auto-unmanaged")  # Auto flag w/ local storage
+c.add_compare(_CLONE_SERIAL + " --auto-clone", "serial")  # Auto flag w/ serial console
 c.add_valid("--connect %(URI-TEST-FULL)s -o test-clone --auto-clone --nonsparse")  # Auto flag, actual VM, skip state check
 c.add_valid("--connect %(URI-TEST-FULL)s -o test-clone-simple -n newvm --preserve-data --file %(EXISTIMG1)s")  # Preserve data shouldn't complain about existing volume
 c.add_valid("-n clonetest " + _CLONE_UNMANAGED + " --file %(EXISTIMG3)s --file %(EXISTIMG4)s --check path_exists=off")  # Skip existing file check
@@ -1521,8 +1523,7 @@ c.add_invalid("--connect %(URI-TEST-REMOTE)s -o test-clone-simple --auto-clone -
 c.add_invalid("--connect %(URI-TEST-FULL)s -o test-clone-full --auto-clone", grep="not enough free space")  # catch failure of clone path setting
 c.add_invalid(_CLONE_NET_HTTP + " --auto-clone", grep="'http' is not cloneable")
 c.add_invalid(_CLONE_NET_RBD + " --connect %(URI-TEST-FULL)s --auto-clone", grep="Cloning rbd volumes is not yet supported")
-
-
+c.add_invalid(_CLONE_SERIAL + " -n clonetest --file serial", grep="Can't figure out serial file paths for the new guest")
 c = vclon.add_category("general", "-n clonetest")
 c.add_valid(_CLONE_EMPTY + " --auto-clone --replace")  # --replace but it doesn't matter, should be safely ignored
 c.add_valid(_CLONE_EMPTY + " --file %(NEWCLONEIMG1)s --file %(NEWCLONEIMG2)s")  # Nodisk, but with spurious files passed
-- 
2.38.1



More information about the virt-tools-list mailing list