Esempio n. 1
0
    def test_intra_domain_copy(self, env_type, src_fmt, dst_fmt):
        src_fmt = sc.name2type(src_fmt)
        dst_fmt = sc.name2type(dst_fmt)
        job_id = str(uuid.uuid4())

        with self.get_vols(env_type, src_fmt,
                           dst_fmt) as (src_chain, dst_chain):
            src_vol = src_chain[0]
            dst_vol = dst_chain[0]
            write_qemu_chain(src_chain)
            self.assertRaises(ChainVerificationError, verify_qemu_chain,
                              dst_chain)

            source = dict(endpoint_type='div',
                          sd_id=src_vol.sdUUID,
                          img_id=src_vol.imgUUID,
                          vol_id=src_vol.volUUID)
            dest = dict(endpoint_type='div',
                        sd_id=dst_vol.sdUUID,
                        img_id=dst_vol.imgUUID,
                        vol_id=dst_vol.volUUID)
            job = storage.sdm.api.copy_data.Job(job_id, None, source, dest)
            job.run()
            wait_for_job(job)

            self.assertEqual(jobs.STATUS.DONE, job.status)
            self.assertEqual(100.0, job.progress)
            self.assertNotIn('error', job.info())
            verify_qemu_chain(dst_chain)
            self.assertEqual(sc.fmt2str(dst_fmt),
                             qemuimg.info(dst_vol.volumePath)['format'])
    def test_intra_domain_copy(self, env_type, src_fmt, dst_fmt):
        src_fmt = sc.name2type(src_fmt)
        dst_fmt = sc.name2type(dst_fmt)
        job_id = str(uuid.uuid4())

        with self.get_vols(env_type, src_fmt, dst_fmt) as (src_chain,
                                                           dst_chain):
            src_vol = src_chain[0]
            dst_vol = dst_chain[0]
            write_qemu_chain(src_chain)
            self.assertRaises(ChainVerificationError,
                              verify_qemu_chain, dst_chain)

            source = dict(endpoint_type='div', sd_id=src_vol.sdUUID,
                          img_id=src_vol.imgUUID, vol_id=src_vol.volUUID)
            dest = dict(endpoint_type='div', sd_id=dst_vol.sdUUID,
                        img_id=dst_vol.imgUUID, vol_id=dst_vol.volUUID)
            job = storage.sdm.api.copy_data.Job(job_id, None, source, dest)
            job.run()
            wait_for_job(job)

            self.assertEqual(jobs.STATUS.DONE, job.status)
            self.assertEqual(100.0, job.progress)
            self.assertNotIn('error', job.info())
            verify_qemu_chain(dst_chain)
            self.assertEqual(sc.fmt2str(dst_fmt),
                             qemuimg.info(dst_vol.volumePath)['format'])
    def test_create_volume_domainlock_contended(self):
        def error(*args):
            raise se.AcquireLockFailure('id', 'rc', 'out', 'err')

        args = self._get_args()
        args['sd_manifest'].acquireDomainLock = error
        job = storage.sdm.api.create_volume.Job(**args)
        job.run()
        wait_for_job(job)
        self.assertEqual(jobs.STATUS.FAILED, job.status)
        self.assertEqual(se.AcquireLockFailure.code,
                         job.info()['error']['code'])
    def test_create_volume_domainlock_contended(self):
        def error(*args):
            raise se.AcquireLockFailure('id', 'rc', 'out', 'err')

        args = self._get_args()
        args['sd_manifest'].acquireDomainLock = error
        job = storage.sdm.api.create_volume.Job(**args)
        job.run()
        wait_for_job(job)
        self.assertEqual(jobs.STATUS.FAILED, job.status)
        self.assertEqual(se.AcquireLockFailure.code,
                         job.info()['error']['code'])
 def test_volume_chain_copy(self, env_type, src_fmt, dst_fmt, copy_seq):
     src_fmt = sc.name2type(src_fmt)
     dst_fmt = sc.name2type(dst_fmt)
     nr_vols = len(copy_seq)
     with self.get_vols(env_type, src_fmt, dst_fmt,
                        chain_length=nr_vols) as (src_chain,
                                                  dst_chain):
         write_qemu_chain(src_chain)
         for index in copy_seq:
             job_id = str(uuid.uuid4())
             src_vol = src_chain[index]
             dst_vol = dst_chain[index]
             source = dict(endpoint_type='div', sd_id=src_vol.sdUUID,
                           img_id=src_vol.imgUUID, vol_id=src_vol.volUUID)
             dest = dict(endpoint_type='div', sd_id=dst_vol.sdUUID,
                         img_id=dst_vol.imgUUID, vol_id=dst_vol.volUUID)
             job = storage.sdm.api.copy_data.Job(job_id, None, source, dest)
             job.run()
             wait_for_job(job)
         verify_qemu_chain(dst_chain)
    def test_create_volume(self):
        args = self._get_args()
        job = storage.sdm.api.create_volume.Job(**args)

        with self._fake_env():
            job.run()
        wait_for_job(job)
        self.assertEqual(jobs.STATUS.DONE, job.status)
        self.assertIsNone(job.progress)
        self.assertNotIn('error', job.info())

        # Verify that the domain lock was acquired and released
        self.assertEqual([('acquireDomainLock', (1, ), {}),
                          ('releaseDomainLock', (), {})],
                         args['sd_manifest'].__calls__)

        # Verify that the image resource was locked and released
        image_ns = sd.getNamespace(job.sd_manifest.sdUUID, sc.IMAGE_NAMESPACE)
        rm_args = (image_ns, job.vol_info.img_id, rm.LockType.exclusive)
        self.assertEqual([('acquireResource', rm_args, {}),
                          ('releaseResource', rm_args, {})], self.rm.__calls__)
    def test_create_volume(self):
        args = self._get_args()
        job = storage.sdm.api.create_volume.Job(**args)

        with self._fake_env():
            job.run()
        wait_for_job(job)
        self.assertEqual(jobs.STATUS.DONE, job.status)
        self.assertIsNone(job.progress)
        self.assertNotIn('error', job.info())

        # Verify that the domain lock was acquired and released
        self.assertEqual([('acquireDomainLock', (1,), {}),
                          ('releaseDomainLock', (), {})],
                         args['sd_manifest'].__calls__)

        # Verify that the image resource was locked and released
        image_ns = sd.getNamespace(job.sd_manifest.sdUUID, IMAGE_NAMESPACE)
        rm_args = (image_ns, job.vol_info.img_id, rm.LockType.exclusive)
        self.assertEqual([('acquireResource', rm_args, {}),
                          ('releaseResource', rm_args, {})],
                         self.rm.__calls__)
Esempio n. 8
0
 def test_volume_chain_copy(self, env_type, src_fmt, dst_fmt, copy_seq):
     src_fmt = sc.name2type(src_fmt)
     dst_fmt = sc.name2type(dst_fmt)
     nr_vols = len(copy_seq)
     with self.get_vols(env_type, src_fmt, dst_fmt,
                        chain_length=nr_vols) as (src_chain, dst_chain):
         write_qemu_chain(src_chain)
         for index in copy_seq:
             job_id = str(uuid.uuid4())
             src_vol = src_chain[index]
             dst_vol = dst_chain[index]
             source = dict(endpoint_type='div',
                           sd_id=src_vol.sdUUID,
                           img_id=src_vol.imgUUID,
                           vol_id=src_vol.volUUID)
             dest = dict(endpoint_type='div',
                         sd_id=dst_vol.sdUUID,
                         img_id=dst_vol.imgUUID,
                         vol_id=dst_vol.volUUID)
             job = storage.sdm.api.copy_data.Job(job_id, None, source, dest)
             job.run()
             wait_for_job(job)
         verify_qemu_chain(dst_chain)
Esempio n. 9
0
 def run_job(self, job):
     self.assertEqual(jobs.STATUS.PENDING, job.status)
     self.assertIsNone(getattr(vars, 'job_id', None))
     job.run()
     wait_for_job(job)
     self.assertIsNone(getattr(vars, 'job_id', None))