~ubuntu-branches/ubuntu/quantal/virtinst/quantal-proposed

« back to all changes in this revision

Viewing changes to tests/clonetest.py

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-07-24 08:52:01 UTC
  • mfrom: (1.6.8 sid)
  • Revision ID: package-import@ubuntu.com-20120724085201-q3h0cbabg4t46gfm
Tags: 0.600.2-1ubuntu1
* Merge from debian unstable. Remaining changes:
  - debian/patches/9003-fix-path-to-hvmloader-in-testsuite.patch: adjust
    testsuite for 0001-fix-path-to-hvmloader.patch and
    0002-Fix-path-to-pygrub.patch.
  - debian/patches/9004_ubuntu_fix_tree_support.patch: Fix tree detection
    for all ISO/HTTP source, to not longer fail with cobbler/koan.
  - debian/patches/0004-Fix-path-to-qemu-dm.patch: fix the path to the
    qemu-dm binary.
  - debian/{control,rules,pyversions}: Build using dh_python2, use
    debhelper v8 instead of cdbs; for some reason the package build an
    empty binary package when using dh_python2.
  - debian/control: added acl package to depends.
  - debian/control: added libvirt-bin to recommends
* Dropped patches:
  - debian/patches/9005_ubuntu_releases.patch: Upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
 
54
54
conn = utils.open_testdriver()
55
55
 
56
 
def fake_is_uri_remote(ignore):
57
 
    return True
58
 
 
59
56
class TestClone(unittest.TestCase):
60
57
 
61
58
    def setUp(self):
67
64
            os.unlink(f)
68
65
 
69
66
    def _clone_helper(self, filebase, disks=None, force_list=None,
70
 
                      skip_list=None, compare=True):
 
67
                      skip_list=None, compare=True, useconn=None):
71
68
        """Helper for comparing clone input/output from 2 xml files"""
72
69
        infile = os.path.join(clonexml_dir, filebase + "-in.xml")
73
70
        in_content = utils.read_file(infile)
74
71
 
75
 
        cloneobj = CloneDesign(conn=conn)
 
72
        cloneobj = CloneDesign(conn=useconn or conn)
76
73
        cloneobj.original_xml = in_content
77
74
        for force in force_list or []:
78
75
            cloneobj.force_target = force
92
89
        cloneobj.clone_name = "clone-new"
93
90
        cloneobj.clone_uuid = "12345678-1234-1234-1234-123456789012"
94
91
 
95
 
        cloneobj.clone_mac = "01:23:45:67:89:00"
96
 
        cloneobj.clone_mac = "01:23:45:67:89:01"
 
92
        cloneobj.clone_mac = "22:23:45:67:89:00"
 
93
        cloneobj.clone_mac = "22:23:45:67:89:01"
97
94
 
98
95
        if disks != None:
99
96
            for disk in disks:
151
148
 
152
149
    def testRemoteNoStorage(self):
153
150
        """Test remote clone where VM has no storage that needs cloning"""
154
 
        oldfunc = CloneManager._util.is_uri_remote
155
 
        try:
156
 
            CloneManager._util.is_uri_remote = fake_is_uri_remote
157
 
 
158
 
            for base in [ "nostorage", "noclone-storage" ] :
159
 
                self._clone_helper(base, disks=[])
160
 
 
161
 
        finally:
162
 
            CloneManager._util.is_uri_remote = oldfunc
 
151
        useconn = utils.open_test_remote()
 
152
        for base in [ "nostorage", "noclone-storage" ] :
 
153
            self._clone_helper(base, disks=[], useconn=useconn)
163
154
 
164
155
    def testRemoteWithStorage(self):
165
156
        """
166
157
        Test remote clone with storage needing cloning. Should fail,
167
158
        since libvirt has no storage clone api.
168
159
        """
169
 
        oldfunc = CloneManager._util.is_uri_remote
170
 
        try:
171
 
            CloneManager._util.is_uri_remote = fake_is_uri_remote
172
 
 
173
 
            for base in [ "general-cfg" ] :
174
 
                try:
175
 
                    self._clone_helper(base, disks=["%s/1.img" % POOL1,
176
 
                                                    "%s/2.img" % POOL1])
177
 
 
178
 
                    # We shouldn't succeed, so test fails
179
 
                    raise AssertionError("Remote clone with storage passed "
180
 
                                         "when it shouldn't.")
181
 
                except (ValueError, RuntimeError), e:
182
 
                    # Exception expected
183
 
                    logging.debug("Received expected exception: %s", str(e))
184
 
        finally:
185
 
            CloneManager._util.is_uri_remote = oldfunc
 
160
        useconn = utils.open_test_remote()
 
161
        for base in [ "general-cfg" ] :
 
162
            try:
 
163
                self._clone_helper(base,
 
164
                                   disks=["%s/1.img" % POOL1,
 
165
                                          "%s/2.img" % POOL1],
 
166
                                   useconn=useconn)
 
167
 
 
168
                # We shouldn't succeed, so test fails
 
169
                raise AssertionError("Remote clone with storage passed "
 
170
                                     "when it shouldn't.")
 
171
            except (ValueError, RuntimeError), e:
 
172
                # Exception expected
 
173
                logging.debug("Received expected exception: %s", str(e))
186
174
 
187
175
    def testCloneStorage(self):
188
176
        base = "managed-storage"