def backup_with_backing_file_test(backing_dev, backup_target): # NOQA dev = backing_dev # NOQA offset = 0 length = 256 snap0 = cmd.snapshot_create() before = read_dev(dev, offset, length) assert before != "" snap0_checksum = common.checksum_dev(dev) exists = read_from_backing_file(offset, length) assert before == exists backup0 = cmd.backup_create(snap0, backup_target) backup0_info = cmd.backup_inspect(backup0) assert backup0_info["URL"] == backup0 assert backup0_info["VolumeName"] == VOLUME_NAME assert backup0_info["VolumeSize"] == VOLUME_SIZE assert snap0 in backup0_info["SnapshotName"] backup_test(dev, backup_target) cmd.backup_restore(backup0) after = read_dev(dev, offset, length) assert before == after c = common.checksum_dev(dev) assert c == snap0_checksum cmd.backup_rm(backup0) with pytest.raises(subprocess.CalledProcessError): cmd.backup_restore(backup0) with pytest.raises(subprocess.CalledProcessError): cmd.backup_inspect(backup0)
def test_backup_with_backing_file(backing_dev): # NOQA dev = backing_dev # NOQA offset = 0 length = 256 snap0 = cmd.snapshot_create() before = read_dev(dev, offset, length) assert before != "" snap0_checksum = common.checksum_dev(dev) exists = read_from_backing_file(offset, length) assert before == exists backup0 = cmd.backup_create(snap0, BACKUP_DEST) backup0_info = cmd.backup_inspect(backup0) assert backup0_info["URL"] == backup0 assert backup0_info["VolumeName"] == VOLUME_NAME assert backup0_info["VolumeSize"] == VOLUME_SIZE assert snap0 in backup0_info["SnapshotName"] test_backup(dev) cmd.backup_restore(backup0) after = read_dev(dev, offset, length) assert before == after c = common.checksum_dev(dev) assert c == snap0_checksum cmd.backup_rm(backup0) with pytest.raises(subprocess.CalledProcessError): cmd.backup_restore(backup0) with pytest.raises(subprocess.CalledProcessError) as e: cmd.backup_inspect(backup0) assert 'cannot find' in str(e.value)
def test_backup_with_backing_file(backing_dev): # NOQA dev = backing_dev # NOQA offset = 0 length = 256 snap0 = cmd.snapshot_create() before = read_dev(dev, offset, length) assert before != "" exists = read_from_backing_file(offset, length) assert before == exists backup0 = cmd.backup_create(snap0, BACKUP_DEST) backup0_info = cmd.backup_inspect(backup0) assert backup0_info["BackupURL"] == backup0 assert backup0_info["VolumeName"] == VOLUME_NAME assert backup0_info["VolumeSize"] == VOLUME_SIZE assert snap0 in backup0_info["SnapshotName"] test_backup(dev) cmd.backup_restore(backup0) after = read_dev(dev, offset, length) assert before == after cmd.backup_rm(backup0) with pytest.raises(subprocess.CalledProcessError): cmd.backup_restore(backup0) with pytest.raises(subprocess.CalledProcessError) as e: cmd.backup_inspect(backup0) assert 'cannot find' in str(e.value)
def rm_backups(*backups): for b in backups: cmd.backup_rm(b) with pytest.raises(subprocess.CalledProcessError): cmd.backup_restore(b) with pytest.raises(subprocess.CalledProcessError): cmd.backup_inspect(b)
def rm_backups(backups, url=cmd.CONTROLLER): for b in backups: cmd.backup_rm(b, url) with pytest.raises(subprocess.CalledProcessError): cmd.backup_restore(b) with pytest.raises(subprocess.CalledProcessError): cmd.backup_inspect(b)
def rm_backups(url, engine_name, backups): for b in backups: cmd.backup_rm(url, b) with pytest.raises(subprocess.CalledProcessError): restore_with_frontend(url, engine_name, b) with pytest.raises(subprocess.CalledProcessError): cmd.backup_inspect(url, b) # Engine frontend is down, Start it up start_engine_frontend(engine_name)
def test_backup(dev): # NOQA offset = 0 length = 128 snap1_data = common.random_string(length) common.verify_data(dev, offset, snap1_data) snap1_checksum = common.checksum_dev(dev) snap1 = cmd.snapshot_create() backup1 = cmd.backup_create(snap1, BACKUP_DEST) backup1_info = cmd.backup_inspect(backup1) assert backup1_info["URL"] == backup1 assert backup1_info["VolumeName"] == VOLUME_NAME assert backup1_info["VolumeSize"] == VOLUME_SIZE assert backup1_info["Size"] == BLOCK_SIZE assert snap1 in backup1_info["SnapshotName"] snap2_data = common.random_string(length) common.verify_data(dev, offset, snap2_data) snap2_checksum = common.checksum_dev(dev) snap2 = cmd.snapshot_create() backup2 = cmd.backup_create(snap2, BACKUP_DEST) backup2_info = cmd.backup_inspect(backup2) assert backup2_info["URL"] == backup2 assert backup2_info["VolumeName"] == VOLUME_NAME assert backup2_info["VolumeSize"] == VOLUME_SIZE assert backup2_info["Size"] == BLOCK_SIZE assert snap2 in backup2_info["SnapshotName"] snap3_data = common.random_string(length) common.verify_data(dev, offset, snap3_data) snap3_checksum = common.checksum_dev(dev) snap3 = cmd.snapshot_create() backup3 = cmd.backup_create(snap3, BACKUP_DEST) backup3_info = cmd.backup_inspect(backup3) assert backup3_info["URL"] == backup3 assert backup3_info["VolumeName"] == VOLUME_NAME assert backup3_info["VolumeSize"] == VOLUME_SIZE assert backup3_info["Size"] == BLOCK_SIZE assert snap3 in backup3_info["SnapshotName"] cmd.backup_restore(backup3) readed = read_dev(dev, offset, length) assert readed == snap3_data c = common.checksum_dev(dev) assert c == snap3_checksum cmd.backup_rm(backup3) with pytest.raises(subprocess.CalledProcessError): cmd.backup_restore(backup3) with pytest.raises(subprocess.CalledProcessError) as e: cmd.backup_inspect(backup3) assert 'cannot find' in str(e.value) cmd.backup_restore(backup1) readed = read_dev(dev, offset, length) assert readed == snap1_data c = common.checksum_dev(dev) assert c == snap1_checksum cmd.backup_rm(backup1) with pytest.raises(subprocess.CalledProcessError): cmd.backup_restore(backup1) with pytest.raises(subprocess.CalledProcessError) as e: cmd.backup_inspect(backup1) assert 'cannot find' in str(e.value) cmd.backup_restore(backup2) readed = read_dev(dev, offset, length) assert readed == snap2_data c = common.checksum_dev(dev) assert c == snap2_checksum cmd.backup_rm(backup2) with pytest.raises(subprocess.CalledProcessError): cmd.backup_restore(backup2) with pytest.raises(subprocess.CalledProcessError) as e: cmd.backup_inspect(backup2) assert 'cannot find' in str(e.value)
def test_backup(dev): # NOQA offset = 0 length = 128 snap1_data = common.random_string(length) common.verify_data(dev, offset, snap1_data) snap1 = cmd.snapshot_create() backup1 = cmd.backup_create(snap1, BACKUP_DEST) backup1_info = cmd.backup_inspect(backup1) assert backup1_info["BackupURL"] == backup1 assert backup1_info["VolumeName"] == VOLUME_NAME assert backup1_info["VolumeSize"] == VOLUME_SIZE assert snap1 in backup1_info["SnapshotName"] snap2_data = common.random_string(length) common.verify_data(dev, offset, snap2_data) snap2 = cmd.snapshot_create() backup2 = cmd.backup_create(snap2, BACKUP_DEST) backup2_info = cmd.backup_inspect(backup2) assert backup2_info["BackupURL"] == backup2 assert backup2_info["VolumeName"] == VOLUME_NAME assert backup2_info["VolumeSize"] == VOLUME_SIZE assert snap2 in backup2_info["SnapshotName"] snap3_data = common.random_string(length) common.verify_data(dev, offset, snap3_data) snap3 = cmd.snapshot_create() backup3 = cmd.backup_create(snap3, BACKUP_DEST) backup3_info = cmd.backup_inspect(backup3) assert backup3_info["BackupURL"] == backup3 assert backup3_info["VolumeName"] == VOLUME_NAME assert backup3_info["VolumeSize"] == VOLUME_SIZE assert snap3 in backup3_info["SnapshotName"] cmd.backup_restore(backup3) readed = read_dev(dev, offset, length) assert readed == snap3_data cmd.backup_rm(backup3) with pytest.raises(subprocess.CalledProcessError): cmd.backup_restore(backup3) with pytest.raises(subprocess.CalledProcessError) as e: cmd.backup_inspect(backup3) assert 'cannot find' in str(e.value) cmd.backup_restore(backup1) readed = read_dev(dev, offset, length) assert readed == snap1_data cmd.backup_rm(backup1) with pytest.raises(subprocess.CalledProcessError): cmd.backup_restore(backup1) with pytest.raises(subprocess.CalledProcessError) as e: cmd.backup_inspect(backup1) assert 'cannot find' in str(e.value) cmd.backup_restore(backup2) readed = read_dev(dev, offset, length) assert readed == snap2_data cmd.backup_rm(backup2) with pytest.raises(subprocess.CalledProcessError): cmd.backup_restore(backup2) with pytest.raises(subprocess.CalledProcessError) as e: cmd.backup_inspect(backup2) assert 'cannot find' in str(e.value)
def backup_test(dev, backup_target): # NOQA offset = 0 length = 128 snap1_data = common.random_string(length) common.verify_data(dev, offset, snap1_data) snap1_checksum = common.checksum_dev(dev) snap1 = cmd.snapshot_create() backup1 = cmd.backup_create(snap1, backup_target) backup1_info = cmd.backup_inspect(backup1) assert backup1_info["URL"] == backup1 assert backup1_info["VolumeName"] == VOLUME_NAME assert backup1_info["VolumeSize"] == VOLUME_SIZE assert backup1_info["Size"] == BLOCK_SIZE assert snap1 in backup1_info["SnapshotName"] snap2_data = common.random_string(length) common.verify_data(dev, offset, snap2_data) snap2_checksum = common.checksum_dev(dev) snap2 = cmd.snapshot_create() backup2 = cmd.backup_create(snap2, backup_target) backup2_info = cmd.backup_inspect(backup2) assert backup2_info["URL"] == backup2 assert backup2_info["VolumeName"] == VOLUME_NAME assert backup2_info["VolumeSize"] == VOLUME_SIZE assert backup2_info["Size"] == BLOCK_SIZE assert snap2 in backup2_info["SnapshotName"] snap3_data = common.random_string(length) common.verify_data(dev, offset, snap3_data) snap3_checksum = common.checksum_dev(dev) snap3 = cmd.snapshot_create() backup3 = cmd.backup_create(snap3, backup_target) backup3_info = cmd.backup_inspect(backup3) assert backup3_info["URL"] == backup3 assert backup3_info["VolumeName"] == VOLUME_NAME assert backup3_info["VolumeSize"] == VOLUME_SIZE assert backup3_info["Size"] == BLOCK_SIZE assert snap3 in backup3_info["SnapshotName"] cmd.backup_restore(backup3) readed = read_dev(dev, offset, length) assert readed == snap3_data c = common.checksum_dev(dev) assert c == snap3_checksum cmd.backup_rm(backup3) with pytest.raises(subprocess.CalledProcessError): cmd.backup_restore(backup3) with pytest.raises(subprocess.CalledProcessError): cmd.backup_inspect(backup3) cmd.backup_restore(backup1) readed = read_dev(dev, offset, length) assert readed == snap1_data c = common.checksum_dev(dev) assert c == snap1_checksum cmd.backup_rm(backup1) with pytest.raises(subprocess.CalledProcessError): cmd.backup_restore(backup1) with pytest.raises(subprocess.CalledProcessError): cmd.backup_inspect(backup1) cmd.backup_restore(backup2) readed = read_dev(dev, offset, length) assert readed == snap2_data c = common.checksum_dev(dev) assert c == snap2_checksum cmd.backup_rm(backup2) with pytest.raises(subprocess.CalledProcessError): cmd.backup_restore(backup2) with pytest.raises(subprocess.CalledProcessError): cmd.backup_inspect(backup2)