def test_qemu_bitmap_add_failure(fake_scheduler, monkeypatch, env_type): monkeypatch.setattr(qemuimg, "bitmap_add", failure) job_id = make_uuid() with make_env(env_type, sc.name2type('cow')) as env: env_vol = env.chain[0] generation = env_vol.getMetaParam(sc.GENERATION) vol = dict(endpoint_type='div', sd_id=env_vol.sdUUID, img_id=env_vol.imgUUID, vol_id=env_vol.volUUID, generation=generation) job = add_bitmap.Job(job_id, 0, vol, "bitmap") job.run() assert job.status == jobs.STATUS.FAILED assert type(job.error) == exception.AddBitmapError assert env_vol.getLegality() == sc.LEGAL_VOL assert env_vol.getMetaParam(sc.GENERATION) == generation
def test_vol_type_not_qcow(fake_scheduler, env_type): job_id = make_uuid() bitmap = "bitmap" with make_env(env_type, sc.name2type('raw')) as env: env_vol = env.chain[0] generation = env_vol.getMetaParam(sc.GENERATION) vol = dict(endpoint_type='div', sd_id=env_vol.sdUUID, img_id=env_vol.imgUUID, vol_id=env_vol.volUUID, generation=generation) job = add_bitmap.Job(job_id, 0, vol, bitmap) job.run() assert job.status == jobs.STATUS.FAILED assert type(job.error) == se.GeneralException assert env_vol.getLegality() == sc.LEGAL_VOL assert env_vol.getMetaParam(sc.GENERATION) == generation
def test_add_bitmap(fake_scheduler, env_type): job_id = make_uuid() bitmap = "bitmap" with make_env(env_type, sc.name2type('cow')) as env: env_vol = env.chain[0] generation = env_vol.getMetaParam(sc.GENERATION) vol = dict(endpoint_type='div', sd_id=env_vol.sdUUID, img_id=env_vol.imgUUID, vol_id=env_vol.volUUID, generation=generation) job = add_bitmap.Job(job_id, 0, vol, bitmap) job.run() assert jobs.STATUS.DONE == job.status vol_info = qemuimg.info(env_vol.getVolumePath()) qcow2_data = vol_info["format-specific"]["data"] assert len(qcow2_data["bitmaps"]) == 1 assert qcow2_data["bitmaps"][0]["name"] == bitmap assert env_vol.getMetaParam(sc.GENERATION) == generation + 1