def test_tunneled_property(self):
        fake_vm = FakeVM()

        src = migration.SourceThread(fake_vm)
        assert src.tunneled is not None
        assert not src.tunneled

        src = migration.SourceThread(fake_vm, tunneled=True)
        assert src.tunneled
Beispiel #2
0
    def test_tunneled_property(self):
        fake_vm = FakeVM()

        src = migration.SourceThread(fake_vm)
        self.assertTrue(src.tunneled is not None)
        self.assertFalse(src.tunneled)

        src = migration.SourceThread(fake_vm, tunneled=True)
        self.assertTrue(src.tunneled)
Beispiel #3
0
    def __init__(self, config):
        self._dom = FakeDomain(config)
        self.log = logging.getLogger()
        self.cif = fake.ClientIF()
        self._domain = DomainDescriptor(config.xmls["00-before.xml"])
        self.id = self._domain.id
        self._md_desc = metadata.Descriptor.from_xml(
            config.xmls["00-before.xml"])

        drive = config.values["drive"]
        self._devices = {
            "disk": [
                storage.Drive(**drive,
                              volumeChain=xml_chain(
                                  config.xmls["00-before.xml"]),
                              log=self.log)
            ]
        }

        # Add the drives to to IRS:
        self.cif.irs.prepared_volumes = {
            (drive["domainID"], drive["imageID"], vol_id): vol_info
            for vol_id, vol_info in config.values["volumes"].items()
        }

        self.conf = self._conf_devices(config)
        self.conf["vmId"] = config.values["vm-id"]
        self.conf["xml"] = config.xmls["00-before.xml"]

        self._external = False  # Used when syncing metadata.
        self.volume_monitor = thinp.VolumeMonitor(self, self.log)
        self._confLock = threading.Lock()
        self._drive_merger = DriveMerger(self)
        self._migrationSourceThread = migration.SourceThread(self)
def make_env(mode=migration.MODE_REMOTE):
    dom = FakeMigratingDomain()
    src = migration.SourceThread(FakeVM(dom), mode=mode)
    src.remoteHost = '127.0.0.1'
    src._monitorThread = FakeMonitorThread(FakeProgress())
    src._setupVdsConnection = lambda: None
    src._setupRemoteMachineParams = lambda: None
    return dom, src
 def test_sets_migration_flags(self):
     src = migration.SourceThread(FakeVM(),
                                  tunneled=True,
                                  abortOnError=True,
                                  compressed=True,
                                  autoConverge=True)
     flags = src.migration_flags
     assert flags & libvirt.VIR_MIGRATE_TUNNELLED
     assert flags & libvirt.VIR_MIGRATE_ABORT_ON_ERROR
     assert flags & libvirt.VIR_MIGRATE_COMPRESSED
     assert flags & libvirt.VIR_MIGRATE_AUTO_CONVERGE
    def test_progress_update_on_get_stat(self, steps):
        vm = FakeVM()
        src = migration.SourceThread(vm)
        prog = FakeProgress()
        src._monitorThread = FakeMonitorThread(prog)

        for step in steps:
            prog.percentage = step
            assert src.getStat()['progress'] == prog.percentage

        assert src.getStat()['progress'] == steps[-1]
    def test_progress_not_backwards(self):
        steps = [8, 15, 23, 85, 81]

        vm = FakeVM()
        src = migration.SourceThread(vm)
        prog = FakeProgress()
        src._monitorThread = FakeMonitorThread(prog)

        for step in steps:
            prog.percentage = step
            old_progress = src._progress
            assert src.getStat()['progress'] >= old_progress

        assert src._progress == max(steps)
 def test_has_migration_flags(self):
     src = migration.SourceThread(FakeVM())
     assert src.migration_flags is not None
     assert src.migration_flags & libvirt.VIR_MIGRATE_LIVE
     assert src.migration_flags & libvirt.VIR_MIGRATE_PEER2PEER
 def test_progress_start(self):
     vm = FakeVM()
     src = migration.SourceThread(vm)
     assert src._progress == 0
Beispiel #10
0
 def test_progress_start(self):
     vm = FakeVM()
     src = migration.SourceThread(vm)
     self.assertEqual(src._progress, 0)