[virt-tools-list] [virt-manager PATCH] cloudinit: Add basic testing for cli option --cloud-init

Athina Plaskasoviti athina.plaskasoviti at gmail.com
Thu Jul 11 05:27:53 UTC 2019


Tests now cover default --cloud-init behavior, and
root-password=(generate and given password),disable=no.

Signed-off-by: Athina Plaskasoviti <athina.plaskasoviti at gmail.com>
---
 .../virt-install-cloud-init-default.xml       | 51 +++++++++++++++++++
 .../virt-install-cloud-init-options.xml       | 51 +++++++++++++++++++
 tests/clitest.py                              |  3 ++
 virtinst/install/cloudinit.py                 |  2 -
 4 files changed, 105 insertions(+), 2 deletions(-)
 create mode 100644 tests/cli-test-xml/compare/virt-install-cloud-init-default.xml
 create mode 100644 tests/cli-test-xml/compare/virt-install-cloud-init-options.xml

diff --git a/tests/cli-test-xml/compare/virt-install-cloud-init-default.xml b/tests/cli-test-xml/compare/virt-install-cloud-init-default.xml
new file mode 100644
index 00000000..7201f446
--- /dev/null
+++ b/tests/cli-test-xml/compare/virt-install-cloud-init-default.xml
@@ -0,0 +1,51 @@
+<domain type="test">
+  <name>fedora28</name>
+  <uuid>00000000-1111-2222-3333-444444444444</uuid>
+  <metadata>
+    <libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
+      <libosinfo:os id="http://fedoraproject.org/fedora/28"/>
+    </libosinfo:libosinfo>
+  </metadata>
+  <memory>65536</memory>
+  <currentMemory>65536</currentMemory>
+  <vcpu>2</vcpu>
+  <os>
+    <type arch="i686">hvm</type>
+    <boot dev="hd"/>
+  </os>
+  <features>
+    <pae/>
+  </features>
+  <clock offset="utc"/>
+  <pm>
+    <suspend-to-mem enabled="no"/>
+    <suspend-to-disk enabled="no"/>
+  </pm>
+  <devices>
+    <emulator>/usr/bin/test-hv</emulator>
+    <disk type="file" device="disk">
+      <source file="/dev/default-pool/testvol1.img"/>
+      <target dev="hda" bus="ide"/>
+    </disk>
+    <disk type="file" device="cdrom">
+      <source file="/VIRTINST-TESTSUITE/cloudinit.iso"/>
+      <target dev="hdb" bus="ide"/>
+      <readonly/>
+    </disk>
+    <controller type="usb" index="0" model="ich9-ehci1"/>
+    <controller type="usb" index="0" model="ich9-uhci1">
+      <master startport="0"/>
+    </controller>
+    <controller type="usb" index="0" model="ich9-uhci2">
+      <master startport="2"/>
+    </controller>
+    <controller type="usb" index="0" model="ich9-uhci3">
+      <master startport="4"/>
+    </controller>
+    <interface type="user">
+      <mac address="00:11:22:33:44:55"/>
+      <model type="e1000"/>
+    </interface>
+    <console type="pty"/>
+  </devices>
+</domain>
diff --git a/tests/cli-test-xml/compare/virt-install-cloud-init-options.xml b/tests/cli-test-xml/compare/virt-install-cloud-init-options.xml
new file mode 100644
index 00000000..7201f446
--- /dev/null
+++ b/tests/cli-test-xml/compare/virt-install-cloud-init-options.xml
@@ -0,0 +1,51 @@
+<domain type="test">
+  <name>fedora28</name>
+  <uuid>00000000-1111-2222-3333-444444444444</uuid>
+  <metadata>
+    <libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
+      <libosinfo:os id="http://fedoraproject.org/fedora/28"/>
+    </libosinfo:libosinfo>
+  </metadata>
+  <memory>65536</memory>
+  <currentMemory>65536</currentMemory>
+  <vcpu>2</vcpu>
+  <os>
+    <type arch="i686">hvm</type>
+    <boot dev="hd"/>
+  </os>
+  <features>
+    <pae/>
+  </features>
+  <clock offset="utc"/>
+  <pm>
+    <suspend-to-mem enabled="no"/>
+    <suspend-to-disk enabled="no"/>
+  </pm>
+  <devices>
+    <emulator>/usr/bin/test-hv</emulator>
+    <disk type="file" device="disk">
+      <source file="/dev/default-pool/testvol1.img"/>
+      <target dev="hda" bus="ide"/>
+    </disk>
+    <disk type="file" device="cdrom">
+      <source file="/VIRTINST-TESTSUITE/cloudinit.iso"/>
+      <target dev="hdb" bus="ide"/>
+      <readonly/>
+    </disk>
+    <controller type="usb" index="0" model="ich9-ehci1"/>
+    <controller type="usb" index="0" model="ich9-uhci1">
+      <master startport="0"/>
+    </controller>
+    <controller type="usb" index="0" model="ich9-uhci2">
+      <master startport="2"/>
+    </controller>
+    <controller type="usb" index="0" model="ich9-uhci3">
+      <master startport="4"/>
+    </controller>
+    <interface type="user">
+      <mac address="00:11:22:33:44:55"/>
+      <model type="e1000"/>
+    </interface>
+    <console type="pty"/>
+  </devices>
+</domain>
diff --git a/tests/clitest.py b/tests/clitest.py
index 1165baed..e412dbee 100644
--- a/tests/clitest.py
+++ b/tests/clitest.py
@@ -858,6 +858,9 @@ c = vinst.add_category("misc-install", "--nographics --noautoconsole")
 c.add_compare("--connect %s" % (utils.URIs.test_suite), "noargs-fail", use_default_args=False)  # No arguments
 c.add_compare("--connect %s --os-variant fedora26" % (utils.URIs.test_suite), "osvariant-noargs-fail", use_default_args=False)  # No arguments
 c.add_compare("--connect %s --os-variant fedora26 --pxe --print-xml" % (utils.URIs.test_suite), "osvariant-defaults-pxe", use_default_args=False)  # No arguments
+c.add_compare("--disk %(EXISTIMG1)s --os-variant fedora28 --cloud-init", "cloud-init-default")  # default --cloud-init behavior is root-password=generate,disable=yes
+c.add_compare("--disk %(EXISTIMG1)s --os-variant fedora28 --cloud-init root-password=generate,disable=no", "cloud-init-options")  # --cloud-init options
+c.add_compare("--disk %(EXISTIMG1)s --os-variant fedora28 --cloud-init root-password=a1b2c3d4,disable=no", "cloud-init-options")  #--cloud-init-options
 c.add_valid("--panic help --disk=? --check=help", grep="path_in_use")  # Make sure introspection doesn't blow up
 c.add_valid("--connect test:///default --test-stub-command", use_default_args=False)  # --test-stub-command
 c.add_valid("--nodisks --pxe", grep="VM performance may suffer")  # os variant warning
diff --git a/virtinst/install/cloudinit.py b/virtinst/install/cloudinit.py
index 032d65e4..91a131c1 100644
--- a/virtinst/install/cloudinit.py
+++ b/virtinst/install/cloudinit.py
@@ -1,7 +1,6 @@
 import tempfile
 import random
 import string
-import time
 from ..logger import log
 
 
@@ -33,7 +32,6 @@ def create_userdata(scratchdir, cloudinit_data):
         for dummy in range(16):
             rootpass += random.choice(string.ascii_letters + string.digits)
         log.warning("Generated password for first boot: %s", rootpass)
-        time.sleep(20)
 
     if rootpass:
         content += "chpasswd:\n"
-- 
2.20.1




More information about the virt-tools-list mailing list