def test_add_only_valid_bitmaps(vol_chain): bitmap = 'bitmap' # Add new bitmap to base volume op = qemuimg.bitmap_add(vol_chain.base_vol, bitmap) op.run() # Add invalid bitmap to base volume op = qemuimg.bitmap_add( vol_chain.base_vol, 'disabled', enable=False ) op.run() # Add bitmaps from base volume to top volume bitmaps.add_bitmaps(vol_chain.base_vol, vol_chain.top_vol) info = qemuimg.info(vol_chain.top_vol) assert info['bitmaps'] == [ { "flags": ["auto"], "name": bitmap, "granularity": 65536 }, ]
def test_add_bitmap_failed(monkeypatch, vol_chain): # Add new bitmap to base volume op = qemuimg.bitmap_add(vol_chain.base_vol, 'bitmap') op.run() monkeypatch.setattr(qemuimg, "bitmap_add", qemuimg_failure) with pytest.raises(exception.AddBitmapError): bitmaps.add_bitmaps(vol_chain.base_vol, vol_chain.top_vol)
def test_no_bitmaps_to_add(vol_chain): # Add bitmaps from base volume to top volume bitmaps.add_bitmaps(vol_chain.base_vol, vol_chain.top_vol) info = qemuimg.info(vol_chain.top_vol) assert 'bitmaps' not in info