Пример #1
0
 def test_cow_vm_conf_disk(self):
     """
     When a VM configuration disk is actually COW format report it correctly
     """
     with fake_file_env() as env:
         vol = make_volume(env, VM_CONF_SIZE, md_fmt='cow', real_fmt='cow')
         self.assertFalse(workarounds.invalid_vm_conf_disk(vol))
Пример #2
0
 def fake_volume(self, vol_fmt, sd_version=3):
     with fake_file_env(sd_version=sd_version) as env:
         img_id = make_uuid()
         vol_id = make_uuid()
         make_file_volume(env.sd_manifest, self.SIZE, img_id, vol_id,
                          vol_format=vol_fmt)
         yield env.sd_manifest.produceVolume(img_id, vol_id)
Пример #3
0
 def test_getallimages(self):
     with fake_file_env() as env:
         self.assertEqual(set(), env.sd_manifest.getAllImages())
         img_id = str(uuid.uuid4())
         vol_id = str(uuid.uuid4())
         make_file_volume(env.sd_manifest, VOLSIZE, img_id, vol_id)
         self.assertIn(img_id, env.sd_manifest.getAllImages())
Пример #4
0
 def fake_volume(self, vol_fmt):
     with fake_file_env() as env:
         img_id = str(uuid.uuid4())
         vol_id = str(uuid.uuid4())
         make_file_volume(env.sd_manifest, self.SIZE, img_id, vol_id,
                          vol_format=vol_fmt)
         yield env.sd_manifest.produceVolume(img_id, vol_id)
Пример #5
0
 def test_volume_type(self, vol_type):
     with fake_file_env() as env:
         img_id = make_uuid()
         vol_id = make_uuid()
         make_file_volume(env.sd_manifest, 0, img_id, vol_id,
                          vol_type=vol_type)
         vol = env.sd_manifest.produceVolume(img_id, vol_id)
         self.assertEqual(vol.getVolType(), sc.type2name(vol_type))
Пример #6
0
    def test_domain_metadata_io(self):
        with fake_file_env() as env:
            desc = 'foo'
            set_domain_metaparams(env.sd_manifest, {sd.DMDK_DESCRIPTION: desc})

            # Test that metadata is persisted to our temporary storage area
            domain_dir = env.sd_manifest.domaindir
            manifest = fileSD.FileStorageDomainManifest(domain_dir)
            self.assertEqual(desc, manifest.getMetaParam(sd.DMDK_DESCRIPTION))
Пример #7
0
 def test_bad_format_other_size(self):
     """
     When the volume size does not match the VM configuration disk size then
     the workaround will not be activated even when the formats don't match
     """
     size = 2 * VM_CONF_SIZE
     with fake_file_env() as env:
         vol = make_volume(env, size, md_fmt='cow', real_fmt='raw')
         self.assertFalse(workarounds.invalid_vm_conf_disk(vol))
Пример #8
0
 def test_bad_format_vm_conf_disk(self):
     """
     When the volume size matches the VM configuration disk size and the
     source volume reports COW even though qemuimg reports RAW then we
     expect the workaround to report both volumes as RAW.
     """
     with fake_file_env() as env:
         vol = make_volume(env, VM_CONF_SIZE, md_fmt='cow', real_fmt='raw')
         self.assertTrue(workarounds.invalid_vm_conf_disk(vol))
Пример #9
0
 def test_getallvolumes(self):
     # Artifacts must not be recognized as volumes until commit is called.
     with fake_file_env() as env:
         self.assertEqual({}, env.sd_manifest.getAllVolumes())
         artifacts = env.sd_manifest.get_volume_artifacts(
             self.img_id, self.vol_id)
         artifacts.create(*BASE_RAW_PARAMS)
         self.assertEqual({}, env.sd_manifest.getAllVolumes())
         artifacts.commit()
         self.assertIn(self.vol_id, env.sd_manifest.getAllVolumes())
Пример #10
0
 def test_volume_structure(self):
     with fake_file_env() as env:
         img_id = make_uuid()
         vol_id = make_uuid()
         make_file_volume(env.sd_manifest, 0, img_id, vol_id)
         image_dir = env.sd_manifest.getImagePath(img_id)
         files = (vol_id, vol_id + sc.LEASE_FILEEXT,
                  vol_id + fileVolume.META_FILEEXT)
         for f in files:
             path = os.path.join(image_dir, f)
             self.assertTrue(os.path.exists(path))
 def test_getallimages(self):
     # The current behavior of getAllImages is to report garbage image
     # directories (perhaps this should be changed).
     with fake_file_env() as env:
         garbage_img_id = sd.REMOVED_IMAGE_PREFIX + self.img_id
         self.assertEqual(set(), env.sd_manifest.getAllImages())
         artifacts = env.sd_manifest.get_volume_artifacts(
             self.img_id, self.vol_id)
         artifacts.create(*BASE_PARAMS[sc.RAW_FORMAT])
         self.assertEqual({garbage_img_id}, env.sd_manifest.getAllImages())
         artifacts.commit()
         self.assertEqual({self.img_id}, env.sd_manifest.getAllImages())
Пример #12
0
    def test_volume_metadata_io(self):
        with fake_file_env() as env:
            size = 1 * MB
            img_id = make_uuid()
            vol_id = make_uuid()
            make_file_volume(env.sd_manifest, size, img_id, vol_id)
            vol = env.sd_manifest.produceVolume(img_id, vol_id)
            desc = 'foo'
            vol.setDescription(desc)

            # Test that metadata is persisted to our temporary storage area
            vol = env.sd_manifest.produceVolume(img_id, vol_id)
            self.assertEqual(desc, vol.getDescription())
Пример #13
0
 def test_domain_structure(self):
     with fake_file_env() as env:
         self.assertTrue(os.path.exists(env.sd_manifest.metafile))
         images_dir = os.path.dirname(env.sd_manifest.getImagePath('foo'))
         self.assertTrue(os.path.exists(images_dir))
Пример #14
0
 def test_repopath_location(self):
     with fake_file_env() as env:
         self.assertTrue(env.sd_manifest.getRepoPath().startswith(TEMPDIR))
Пример #15
0
 def test_no_fakelvm(self):
     with fake_file_env() as env:
         self.assertFalse(hasattr(env, 'lvm'))
Пример #16
0
 def test_repopath_location(self):
     with fake_file_env() as env:
         self.assertTrue(env.sd_manifest.getRepoPath().startswith(TEMPDIR))
Пример #17
0
 def test_domain_structure(self):
     with fake_file_env() as env:
         self.assertTrue(os.path.exists(env.sd_manifest.metafile))
         images_dir = os.path.dirname(env.sd_manifest.getImagePath('foo'))
         self.assertTrue(os.path.exists(images_dir))
Пример #18
0
 def test_getmdpath(self):
     with fake_file_env() as env:
         sd_manifest = env.sd_manifest
         mdpath = os.path.join(sd_manifest.domaindir, sd.DOMAIN_META_DATA)
         self.assertEquals(mdpath, env.sd_manifest.getMDPath())
Пример #19
0
 def test_getvallocsize(self):
     with fake_file_env() as env:
         make_file_volume(env.sd_manifest, VOLSIZE,
                          self.img_id, self.vol_id)
         self.assertEqual(0, env.sd_manifest.getVAllocSize(
             self.img_id, self.vol_id))
Пример #20
0
 def test_get_monitoring_path(self):
     with fake_file_env() as env:
         self.assertEqual(env.sd_manifest.metafile,
                          env.sd_manifest.getMonitoringPath())
Пример #21
0
 def test_getmetaparam(self):
     with fake_file_env() as env:
         sd_manifest = env.sd_manifest
         self.assertEquals(sd_manifest.sdUUID,
                           sd_manifest.getMetaParam(sd.DMDK_SDUUID))
Пример #22
0
 def test_getmdpath(self):
     with fake_file_env() as env:
         sd_manifest = env.sd_manifest
         mdpath = os.path.join(sd_manifest.domaindir, sd.DOMAIN_META_DATA)
         self.assertEquals(mdpath, env.sd_manifest.getMDPath())
Пример #23
0
 def test_getisodomainimagesdir(self):
     with fake_file_env() as env:
         isopath = os.path.join(env.sd_manifest.domaindir, sd.DOMAIN_IMAGES,
                                sd.ISO_IMAGE_UUID)
         self.assertEquals(isopath, env.sd_manifest.getIsoDomainImagesDir())
Пример #24
0
 def test_getvsize(self):
     with fake_file_env() as env:
         make_file_volume(env.sd_manifest, VOLSIZE,
                          self.img_id, self.vol_id)
         self.assertEqual(VOLSIZE, env.sd_manifest.getVSize(
             self.img_id, self.vol_id))
Пример #25
0
 def test_getreaddelay(self):
     with fake_file_env() as env:
         self.assertIsInstance(env.sd_manifest.getReadDelay(), float)
Пример #26
0
 def test_getisodomainimagesdir(self):
     with fake_file_env() as env:
         isopath = os.path.join(env.sd_manifest.domaindir, sd.DOMAIN_IMAGES,
                                sd.ISO_IMAGE_UUID)
         self.assertEquals(isopath, env.sd_manifest.getIsoDomainImagesDir())
Пример #27
0
 def test_getvallocsize(self):
     with fake_file_env() as env:
         sd_manifest = env.sd_manifest
         imguuid, voluuid = make_file_volume(sd_manifest.domaindir, VOLSIZE)
         self.assertEqual(0, sd_manifest.getVAllocSize(imguuid, voluuid))
Пример #28
0
 def test_getmetaparam(self):
     with fake_file_env() as env:
         sd_manifest = env.sd_manifest
         self.assertEquals(sd_manifest.sdUUID,
                           sd_manifest.getMetaParam(sd.DMDK_SDUUID))
 def fake_env(self):
     return fake_file_env()
Пример #30
0
 def fake_env(self):
     return fake_file_env()
Пример #31
0
 def test_no_fakelvm(self):
     with fake_file_env() as env:
         self.assertFalse(hasattr(env, 'lvm'))