Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inc_backup: add datastore element test scenarios to incremental backup #6130

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
local_ip = "ENTER.YOUR.IPV4ADDR"
local_user_name = "ENTER.YOUR.USER.NAME"
local_user_password = "ENTER.YOUR.USER.PASSWORD"
only original_disk_local
variants:
- without_datastore:
- with_datastore:
only default_exportbitmap.default_exportname
with_data_file = "yes"
func_supported_since_libvirt_ver = (10, 10, 0)
data_file_option = " -o data_file=%s"
variants:
- scratch_luks_encrypted:
only custom_exportname..custom_exportbitmap..hotplug_disk..original_disk_local
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
start_vm = "no"
original_disk_size = "100M"
backup_data_size = "1M"
variants:
- without_datastore:
- with_datastore:
only original_disk_local
with_data_file = "yes"
func_supported_since_libvirt_ver = (10, 10, 0)
data_file_option = " -o data_file=%s"
variants:
- backup_to_file:
target_type = "file"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def run(test, params, env):
local_user_name = params.get("local_user_name", "root")
local_user_password = params.get("local_user_password", "redhat")
tmp_dir = data_dir.get_tmp_dir()
with_data_file = "yes" == params.get("with_data_file", "no")
libvirt_version.is_libvirt_feature_supported(params)
# Backup config
scratch_type = params.get("scratch_type", "file")
reuse_scratch_file = "yes" == params.get("reuse_scratch_file")
Expand Down Expand Up @@ -150,8 +152,15 @@ def run(test, params, env):
if original_disk_type == "local":
image_name = "{}_image.qcow2".format(original_disk_target)
disk_path = os.path.join(tmp_dir, image_name)
data_file = os.path.join(tmp_dir, "datastore")
for file in [disk_path, data_file]:
if os.path.exists(file):
os.remove(file)
if with_data_file:
data_file_option = params.get("data_file_option", "") % data_file
extra_cmd = "" if not with_data_file else data_file_option
libvirt.create_local_disk("file", disk_path, original_disk_size,
"qcow2")
"qcow2", extra=extra_cmd)
disk_params = {"device_type": "disk",
"type_name": "file",
"driver_type": "qcow2",
Expand Down Expand Up @@ -213,6 +222,11 @@ def run(test, params, env):
virsh.attach_device(vm.name, disk_xml,
flagstr="--config", debug=True)
vm.start()
guest_xml = virsh.dumpxml(vm_name).stdout_text
logging.debug("The current guest xml is:%s" % guest_xml)
if with_data_file:
if data_file not in guest_xml:
test.fail("The datastore file xml can't be generated automatically in guest!")
session = vm.wait_for_login()
new_disks_in_vm = list(utils_disk.get_linux_disks(session).keys())
session.close()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ def backup_job_done(vm_name, vm_disk):
backup_error = "yes" == params.get("backup_error")
expect_backup_canceled = "yes" == params.get("expect_backup_canceled")
tmp_dir = data_dir.get_data_dir()
with_data_file = "yes" == params.get("with_data_file", "no")
libvirt_version.is_libvirt_feature_supported(params)
virsh_dargs = {'debug': True, 'ignore_status': True}

try:
Expand All @@ -87,10 +89,15 @@ def backup_job_done(vm_name, vm_disk):
if original_disk_type == "local":
image_name = "{}_image.qcow2".format(original_disk_target)
disk_path = os.path.join(tmp_dir, image_name)
if os.path.exists(disk_path):
os.remove(disk_path)
data_file = os.path.join(tmp_dir, "datastore")
for file in [disk_path, data_file]:
if os.path.exists(file):
os.remove(file)
if with_data_file:
data_file_option = params.get("data_file_option", "") % data_file
extra_cmd = "" if not with_data_file else data_file_option
libvirt.create_local_disk("file", disk_path, original_disk_size,
"qcow2")
"qcow2", extra=extra_cmd)
disk_params = {"device_type": "disk",
"type_name": "file",
"driver_type": "qcow2",
Expand Down Expand Up @@ -167,6 +174,11 @@ def backup_job_done(vm_name, vm_disk):
virsh.attach_device(vm.name, disk_xml,
flagstr="--config", debug=True)
vm.start()
guest_xml = virsh.dumpxml(vm_name).stdout_text
logging.debug("The current guest xml is:%s" % guest_xml)
if with_data_file:
if data_file not in guest_xml:
test.fail("The datastore file xml can't be generated automatically in guest!")
session = vm.wait_for_login()
new_disks_in_vm = list(utils_disk.get_linux_disks(session).keys())
session.close()
Expand Down