mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-02 09:47:16 +03:00
tests: Open a new connection for each test
To ensure we are testing each time from a clean state. Isn't causing obvious issues in practice at the moment but it may with future changes
This commit is contained in:
parent
d3074141c8
commit
e241f4c957
@ -41,7 +41,6 @@ DISKPOOL = "/dev/disk-pool"
|
||||
local_files = [FILE1, FILE2]
|
||||
|
||||
clonexml_dir = os.path.join(os.getcwd(), "tests/clone-xml")
|
||||
conn = utils.open_testdriver()
|
||||
|
||||
|
||||
class TestClone(unittest.TestCase):
|
||||
@ -55,13 +54,15 @@ class TestClone(unittest.TestCase):
|
||||
os.unlink(f)
|
||||
|
||||
def _clone_helper(self, filebase, disks=None, force_list=None,
|
||||
skip_list=None, compare=True, useconn=None,
|
||||
skip_list=None, compare=True, conn=None,
|
||||
clone_disks_file=None):
|
||||
"""Helper for comparing clone input/output from 2 xml files"""
|
||||
infile = os.path.join(clonexml_dir, filebase + "-in.xml")
|
||||
in_content = utils.read_file(infile)
|
||||
|
||||
cloneobj = Cloner(useconn or conn)
|
||||
if not conn:
|
||||
conn = utils.open_testdriver()
|
||||
cloneobj = Cloner(conn)
|
||||
cloneobj.original_xml = in_content
|
||||
for force in force_list or []:
|
||||
cloneobj.force_target = force
|
||||
@ -112,26 +113,27 @@ class TestClone(unittest.TestCase):
|
||||
connection to ensure we don't get any errors"""
|
||||
outfile = os.path.join(clonexml_dir, filebase + "-out.xml")
|
||||
outxml = utils.read_file(outfile)
|
||||
conn = utils.open_testdriver()
|
||||
utils.test_create(conn, outxml)
|
||||
|
||||
def testRemoteNoStorage(self):
|
||||
"""Test remote clone where VM has no storage that needs cloning"""
|
||||
useconn = utils.open_test_remote()
|
||||
conn = utils.open_test_remote()
|
||||
for base in ["nostorage", "noclone-storage"] :
|
||||
self._clone_helper(base, disks=[], useconn=useconn)
|
||||
self._clone_helper(base, disks=[], conn=conn)
|
||||
|
||||
def testRemoteWithStorage(self):
|
||||
"""
|
||||
Test remote clone with storage needing cloning. Should fail,
|
||||
since libvirt has no storage clone api.
|
||||
"""
|
||||
useconn = utils.open_test_remote()
|
||||
conn = utils.open_test_remote()
|
||||
for base in ["general-cfg"] :
|
||||
try:
|
||||
self._clone_helper(base,
|
||||
disks=["%s/1.img" % POOL1,
|
||||
"%s/2.img" % POOL1],
|
||||
useconn=useconn)
|
||||
conn=conn)
|
||||
|
||||
# We shouldn't succeed, so test fails
|
||||
raise AssertionError("Remote clone with storage passed "
|
||||
@ -147,12 +149,12 @@ class TestClone(unittest.TestCase):
|
||||
|
||||
def testCloneStorageCrossPool(self):
|
||||
base = "cross-pool"
|
||||
useconn = utils.open_test_remote()
|
||||
conn = utils.open_test_remote()
|
||||
clone_disks_file = os.path.join(clonexml_dir, base + "-disks-out.xml")
|
||||
self._clone_helper(base, ["%s/new1.img" % POOL2,
|
||||
"%s/new2.img" % POOL1],
|
||||
clone_disks_file=clone_disks_file,
|
||||
useconn=useconn)
|
||||
conn=conn)
|
||||
|
||||
def testCloneStorageForce(self):
|
||||
base = "force"
|
||||
|
@ -28,7 +28,6 @@ from tests import utils
|
||||
|
||||
base_dir = os.getcwd() + "/tests/virtconv-files/"
|
||||
out_dir = base_dir + "libvirt_output"
|
||||
conn = utils.open_kvm()
|
||||
|
||||
|
||||
class TestVirtConv(unittest.TestCase):
|
||||
@ -37,6 +36,7 @@ class TestVirtConv(unittest.TestCase):
|
||||
def print_cb(msg):
|
||||
print(msg, file=outbuf)
|
||||
|
||||
conn = utils.open_kvm()
|
||||
converter = VirtConverter(conn, infile, print_cb=print_cb)
|
||||
|
||||
if converter.parser.name != in_type:
|
||||
@ -57,7 +57,7 @@ class TestVirtConv(unittest.TestCase):
|
||||
self.skipTest("Not comparing XML because vmport isn't supported")
|
||||
|
||||
utils.diff_compare(out_expect, outfile)
|
||||
utils.test_create(converter.conn, out_xml)
|
||||
utils.test_create(conn, out_xml)
|
||||
|
||||
def _compare_single_file(self, in_path, in_type, disk_format=None):
|
||||
cwd = os.getcwd()
|
||||
|
Loading…
x
Reference in New Issue
Block a user