Exemplo n.º 1
0
 def test_acquire_release(self):
     sdcache = FakeStorageDomainCache()
     manifest = FakeSDManifest()
     sdcache.domains['dom'] = FakeSD(manifest)
     expected = [('acquireVolumeLease', (HOST_ID, 'img', 'vol'), {}),
                 ('releaseVolumeLease', ('img', 'vol'), {})]
     with MonkeyPatchScope([(volume, 'sdCache', sdcache)]):
         lock = volume.VolumeLease(HOST_ID, 'dom', 'img', 'vol')
         lock.acquire()
         self.assertEqual(expected[:1], manifest.__calls__)
         lock.release()
         self.assertEqual(expected, manifest.__calls__)
Exemplo n.º 2
0
 def test_acquire_release(self):
     sdcache = FakeStorageDomainCache()
     manifest = FakeSDManifest()
     sdcache.domains['dom'] = FakeSD(manifest)
     expected = [('acquireVolumeLease', (HOST_ID, 'img', 'vol'), {}),
                 ('releaseVolumeLease', ('img', 'vol'), {})]
     with MonkeyPatchScope([(volume, 'sdCache', sdcache)]):
         lock = volume.VolumeLease(HOST_ID, 'dom', 'img', 'vol')
         lock.acquire()
         self.assertEqual(expected[:1], manifest.__calls__)
         lock.release()
         self.assertEqual(expected, manifest.__calls__)
Exemplo n.º 3
0
def fake_file_env(obj=None):
    with namedTemporaryDir() as tmpdir:
        sd_manifest = make_filesd_manifest(tmpdir)
        fake_sdc = FakeStorageDomainCache()
        with MonkeyPatchScope([
            [sd, 'storage_repository', tmpdir],
            [volume, 'sdCache', fake_sdc],
        ]):
            fake_sdc.domains[sd_manifest.sdUUID] = FakeSD(sd_manifest)
            yield FakeEnv(sd_manifest)
Exemplo n.º 4
0
def fake_file_env(obj=None, sd_version=3):
    with namedTemporaryDir() as tmpdir:
        sd_manifest = make_filesd_manifest(tmpdir, sd_version=sd_version)
        fake_sdc = FakeStorageDomainCache()
        with MonkeyPatchScope([
            [sd, 'storage_repository', tmpdir],
            [volume, 'sdCache', fake_sdc],
            [hsm, 'sdCache', fake_sdc],
        ]):
            fake_sdc.domains[sd_manifest.sdUUID] = FakeSD(sd_manifest)
            try:
                yield FakeFileEnv(tmpdir, sd_manifest, fake_sdc)
            finally:
                oop.stop()
Exemplo n.º 5
0
def fake_block_env(obj=None):
    with namedTemporaryDir() as tmpdir:
        lvm = FakeLVM(tmpdir)
        fake_sdc = FakeStorageDomainCache()
        with MonkeyPatchScope([
            (blockSD, 'lvm', lvm),
            (blockVolume, 'lvm', lvm),
            (volume_artifacts, 'lvm', lvm),
            (sd, 'storage_repository', tmpdir),
            (volume, 'sdCache', fake_sdc),
        ]):
            sd_manifest = make_blocksd_manifest(tmpdir, lvm)
            fake_sdc.domains[sd_manifest.sdUUID] = FakeSD(sd_manifest)
            yield FakeEnv(sd_manifest, lvm=lvm)
Exemplo n.º 6
0
def monitor_env(shutdown=False, refresh=300):
    config = make_config([("irs", "repo_stats_cache_refresh_timeout",
                           str(refresh))])
    with MonkeyPatchScope([
        (monitor, "sdCache", FakeStorageDomainCache()),
        (monitor, 'config', config),
    ]):
        event = FakeEvent()
        checker = FakeCheckService()
        thread = monitor.MonitorThread('uuid', 'host_id', MONITOR_INTERVAL,
                                       event, checker)
        try:
            yield MonitorEnv(thread, event, checker)
        finally:
            thread.stop(shutdown=shutdown)
            try:
                thread.join()
            except RuntimeError as e:
                log.error("Error joining thread: %s", e)
Exemplo n.º 7
0
def fake_block_env(obj=None, sd_version=3):
    with namedTemporaryDir() as tmpdir:
        lvm = FakeLVM(tmpdir)
        fake_sdc = FakeStorageDomainCache()
        with MonkeyPatchScope([
            (blockSD, 'lvm', lvm),
            (blockVolume, 'lvm', lvm),
            (volume_artifacts, 'lvm', lvm),
            (sd, 'storage_repository', tmpdir),
            (volume, 'sdCache', fake_sdc),
            (hsm, 'sdCache', fake_sdc),
        ]):
            sd_manifest = make_blocksd_manifest(tmpdir,
                                                lvm,
                                                sd_version=sd_version)
            fake_sdc.domains[sd_manifest.sdUUID] = FakeSD(sd_manifest)
            try:
                yield FakeBlockEnv(tmpdir, sd_manifest, fake_sdc, lvm)
            finally:
                oop.stop()
Exemplo n.º 8
0
 def test_manually_remove_domain(self):
     sdc = FakeStorageDomainCache()
     sdc.domains["uuid"] = "fake domain"
     sdc.manuallyRemoveDomain("uuid")
     self.assertRaises(se.StorageDomainDoesNotExist, sdc.produce, "uuid")
Exemplo n.º 9
0
 def test_produce_manifest(self):
     sdc = FakeStorageDomainCache()
     sdc.domains["uuid"] = FakeSD("fake manifest")
     self.assertEqual("fake manifest", sdc.produce_manifest("uuid"))
Exemplo n.º 10
0
 def test_produce(self):
     sdc = FakeStorageDomainCache()
     sdc.domains["uuid"] = "fake domain"
     self.assertEqual("fake domain", sdc.produce("uuid"))
Exemplo n.º 11
0
 def test_domain_does_not_exist(self):
     sdc = FakeStorageDomainCache()
     self.assertRaises(se.StorageDomainDoesNotExist, sdc.produce, "uuid")