def test_set_generation(self, env_type): with self.make_env(env_type) as env: vol = env.chain[0] job = update_volume.Job(make_uuid(), 0, make_endpoint_from_volume(vol), dict(generation=44)) job.run() wait_for_job(job) self.assertEqual(jobs.STATUS.DONE, job.status) self.assertEqual(44, vol.getMetaParam(sc.GENERATION))
def test_set_legality(self, env_type, legality, expected): with self.make_env(env_type) as env: vol = env.chain[0] vol.setLegality(legality) generation = vol.getMetaParam(sc.GENERATION) job = update_volume.Job(make_uuid(), 0, make_endpoint_from_volume(vol), dict(legality=expected)) job.run() wait_for_job(job) self.assertEqual(jobs.STATUS.DONE, job.status) self.assertEqual(expected, vol.getMetaParam(sc.LEGALITY)) self.assertEqual(generation + 1, vol.getMetaParam(sc.GENERATION))
def test_set_description(self, env_type): with self.make_env(env_type) as env: vol = env.chain[0] generation = vol.getMetaParam(sc.GENERATION) description = 'my wonderful description' job = update_volume.Job(make_uuid(), 0, make_endpoint_from_volume(vol), dict(description=description)) job.run() wait_for_job(job) self.assertEqual(jobs.STATUS.DONE, job.status) self.assertEqual(description, vol.getMetaParam(sc.DESCRIPTION)) self.assertEqual(generation + 1, vol.getMetaParam(sc.GENERATION))
def test_set_legality_invalid(self, env_type, legality): with self.make_env(env_type) as env: vol = env.chain[0] vol.setLegality(legality) generation = vol.getMetaParam(sc.GENERATION) job = update_volume.Job(make_uuid(), 0, make_endpoint_from_volume(vol), dict(legality=legality)) job.run() wait_for_job(job) self.assertEqual(job.status, jobs.STATUS.FAILED) self.assertEqual(type(job.error), se.InvalidVolumeUpdate) self.assertEqual(generation, vol.getMetaParam(sc.GENERATION))
def test_set_type_internal(self, env_type): with self.make_env(env_type, chain_length=1) as env: internal_vol = env.chain[0] generation = internal_vol.getMetaParam(sc.GENERATION) internal_vol.setInternal() job = update_volume.Job(make_uuid(), 0, make_endpoint_from_volume(internal_vol), dict(type=sc.type2name(sc.SHARED_VOL))) job.run() wait_for_job(job) self.assertEqual(job.status, jobs.STATUS.FAILED) self.assertEqual(type(job.error), se.InvalidVolumeUpdate) self.assertEqual(generation, internal_vol.getMetaParam(sc.GENERATION))
def test_set_type_leaf_with_parent(self, env_type): with self.make_env(env_type, chain_length=2) as env: top_vol = env.chain[1] generation = top_vol.getMetaParam(sc.GENERATION) job = update_volume.Job(make_uuid(), 0, make_endpoint_from_volume(top_vol), dict(type=sc.type2name(sc.SHARED_VOL))) job.run() wait_for_job(job) self.assertEqual(job.status, jobs.STATUS.FAILED) self.assertEqual(type(job.error), se.InvalidVolumeUpdate) self.assertEqual(sc.type2name(sc.LEAF_VOL), top_vol.getMetaParam(sc.VOLTYPE)) self.assertEqual(generation, top_vol.getMetaParam(sc.GENERATION))
def test_set_type(self, env_type): with self.make_env(env_type) as env: leaf_vol = env.chain[0] generation = leaf_vol.getMetaParam(sc.GENERATION) job = update_volume.Job(make_uuid(), 0, make_endpoint_from_volume(leaf_vol), dict(type=sc.type2name(sc.SHARED_VOL))) job.run() wait_for_job(job) self.assertEqual(jobs.STATUS.DONE, job.status) self.assertEqual(sc.type2name(sc.SHARED_VOL), leaf_vol.getMetaParam(sc.VOLTYPE)) self.assertEqual(generation + 1, leaf_vol.getMetaParam(sc.GENERATION))
def test_invalid_generation(self, generation): with self.assertRaises(ValueError): update_volume.Job(make_uuid(), 0, make_endpoint(), dict(generation=generation))
def test_invalid_type_internal(self, type): with self.assertRaises(ValueError): update_volume.Job(make_uuid(), 0, make_endpoint(), dict(type=type))
def test_invalid_legality(self): with self.assertRaises(ValueError): update_volume.Job(make_uuid(), 0, make_endpoint(), dict(legality='INVALID'))
def test_empty_vol_attr(self): with self.assertRaises(ValueError): update_volume.Job(make_uuid(), 0, make_endpoint(), {})