tests: Add our own test:///default driver XML

test:///default saves changes for the lifetime of the connecting
process, which can cause weird interdependent issues in the test
suite. Duplicating it with driver XML will avoid those issues
popping up.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson 2020-09-04 11:13:29 -04:00
parent f06325904b
commit 8f60e4af47
4 changed files with 152 additions and 4 deletions

View File

@ -0,0 +1,143 @@
<node>
<!-- driver content roughly matching what test:///default provides -->
<cpu>
<nodes>2</nodes>
<sockets>2</sockets>
<cores>2</cores>
<threads>2</threads>
<active>16</active>
<mhz>4000</mhz>
<model>i686</model>
</cpu>
<memory>10000000</memory>
<domain type='test' id='1'>
<name>test</name>
<uuid>6695eb01-f6a4-8304-79aa-97f2502e193f</uuid>
<memory unit='KiB'>8388608</memory>
<currentMemory unit='KiB'>2097152</currentMemory>
<vcpu placement='static'>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>
<disk type='file' device='disk'>
<source file='/guest/diskimage1'/>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
</disk>
<interface type='network'>
<mac address='aa:bb:cc:dd:ee:ff'/>
<source network='default'/>
<target dev='testnet0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
</interface>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</memballoon>
</devices>
</domain>
<network>
<name>default</name>
<uuid>dd8fe884-6c02-601e-7551-cca97df1c5df</uuid>
<forward mode='nat'/>
<bridge name='virbr0' stp='on' delay='0'/>
<ip address='192.168.122.1' netmask='255.255.255.0'>
<dhcp>
<range start='192.168.122.2' end='192.168.122.254'/>
</dhcp>
</ip>
</network>
<pool type='dir'>
<name>default-pool</name>
<uuid>dfe224cb-28fb-8dd0-c4b2-64eb3f0f4566</uuid>
<capacity unit='bytes'>107374182400</capacity>
<allocation unit='bytes'>0</allocation>
<available unit='bytes'>107374182400</available>
<source>
</source>
<target>
<path>/default-pool</path>
</target>
</pool>
<device>
<name>computer</name>
<capability type='system'>
<hardware>
<vendor>Libvirt</vendor>
<version>Test driver</version>
<serial>123456</serial>
<uuid>11111111-2222-3333-4444-555555555555</uuid>
</hardware>
<firmware>
<vendor>Libvirt</vendor>
<version>Test Driver</version>
<release_date>01/22/2007</release_date>
</firmware>
</capability>
</device>
<device>
<name>scsi_host1</name>
<parent>computer</parent>
<capability type='scsi_host'>
<host>1</host>
<unique_id>0</unique_id>
<capability type='fc_host'>
<wwnn>2000000012341234</wwnn>
<wwpn>1000000012341234</wwpn>
<fabric_wwn>2000000043214321</fabric_wwn>
</capability>
<capability type='vport_ops'>
<max_vports>0</max_vports>
<vports>0</vports>
</capability>
</capability>
</device>
<device>
<name>scsi_host2</name>
<parent>computer</parent>
<capability type='scsi_host'>
<host>2</host>
<unique_id>1</unique_id>
<capability type='fc_host'>
<wwnn>2000000056785678</wwnn>
<wwpn>1000000056785678</wwpn>
<fabric_wwn>2000000087658765</fabric_wwn>
</capability>
<capability type='vport_ops'>
<max_vports>0</max_vports>
<vports>0</vports>
</capability>
</capability>
</device>
<device>
<name>scsi_host11</name>
<parent>scsi_host1</parent>
<capability type='scsi_host'>
<host>11</host>
<unique_id>10</unique_id>
<capability type='fc_host'>
<wwnn>2000000034563456</wwnn>
<wwpn>1000000034563456</wwpn>
<fabric_wwn>2000000043214321</fabric_wwn>
</capability>
</capability>
</device>
</node>

View File

@ -20,7 +20,7 @@ def test_clone_unmanaged():
actually copies data
"""
xmlpath = CLI_XMLDIR + "clone-disk.xml"
conn = utils.URIs.open_testdriver_cached()
conn = utils.URIs.open_testdefault_cached()
xml = open(xmlpath).read()
tmp1 = tempfile.NamedTemporaryFile()

View File

@ -62,7 +62,7 @@ class TestURI(unittest.TestCase):
self.assertEqual(conn.conn_version(), 1)
self.assertEqual(conn.local_libvirt_version(), 2)
conn = tests.utils.URIs.open_testdefault_cached()
conn = tests.utils.URIs.openconn("test:///default")
# Add some support tests with it
with self.assertRaises(ValueError) as cm:
conn.support.domain_xml_inactive("foo")

View File

@ -64,9 +64,14 @@ class _URIs(object):
return ",caps=" + _capspath + path
_testtmpl = "__virtinst_test__test://%s,predictable"
self.test_default = _testtmpl % "/default"
_testdriverdir = DATADIR + "/testdriver/"
# We don't use actual test:///default, which saves state
# for the lifetime of the process which can cause weird
# trickling effects for the testsuite. We use our own
# test XML which roughly matches test:///default, and then
# fake the URI
self.test_default = _testtmpl % (_testdriverdir + "testdefault.xml") + ",fakeuri=test:///default"
self.test_full = _testtmpl % (_testdriverdir + "testdriver.xml")
self.test_suite = _testtmpl % (_testdriverdir + "testsuite.xml")
self.test_defaultpool_collision = _testtmpl % (