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

Add blockcopy xml test cases #2912

Merged
merged 1 commit into from
Sep 17, 2020

Conversation

chunfuwen
Copy link
Contributor

Cover different backend storage such as file,block,iscsi,rbd,nbd,ceph and gluster

Signed-off-by: chunfuwen [email protected]

@chunfuwen chunfuwen force-pushed the add_virsh_blockcopy_xml_cases branch from 89b564b to 9501324 Compare July 7, 2020 03:29
@chunfuwen
Copy link
Contributor Author

PASS 1-type_specific.io-github-autotest-libvirt.virsh.blockcopy_xml.positive_test.block_test.pivot
PASS 2-type_specific.io-github-autotest-libvirt.virsh.blockcopy_xml.positive_test.block_test.finish
PASS 3-type_specific.io-github-autotest-libvirt.virsh.blockcopy_xml.positive_test.block_test.reuse-external

PASS 1-type_specific.io-github-autotest-libvirt.virsh.blockcopy_xml.positive_test.nbd_test.pivot
PASS 2-type_specific.io-github-autotest-libvirt.virsh.blockcopy_xml.positive_test.nbd_test.finish
PASS 3-type_specific.io-github-autotest-libvirt.virsh.blockcopy_xml.positive_test.nbd_test.reuse-external

PASS 1-type_specific.io-github-autotest-libvirt.virsh.blockcopy_xml.positive_test.file_test.pivot
PASS 2-type_specific.io-github-autotest-libvirt.virsh.blockcopy_xml.positive_test.file_test.finish
PASS 3-type_specific.io-github-autotest-libvirt.virsh.blockcopy_xml.positive_test.file_test.reuse-external

PASS 1-type_specific.io-github-autotest-libvirt.virsh.blockcopy_xml.positive_test.iscsi_test.pivot
PASS 2-type_specific.io-github-autotest-libvirt.virsh.blockcopy_xml.positive_test.iscsi_test.finish
PASS 3-type_specific.io-github-autotest-libvirt.virsh.blockcopy_xml.positive_test.iscsi_test.reuse-external

PASS 1-type_specific.io-github-autotest-libvirt.virsh.blockcopy_xml.positive_test.ceph_test.pivot
PASS 2-type_specific.io-github-autotest-libvirt.virsh.blockcopy_xml.positive_test.ceph_test.finish

@chunfuwen chunfuwen force-pushed the add_virsh_blockcopy_xml_cases branch from 9501324 to e343026 Compare July 7, 2020 04:21
@chunfuwen chunfuwen force-pushed the add_virsh_blockcopy_xml_cases branch 2 times, most recently from 3db8d07 to e35da6e Compare July 23, 2020 02:28
virt_disk_device_target = "vdb"
virt_disk_device_format = "raw"
virt_disk_device_bus = "virtio"
variants blockcopy_option:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo? Please correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the reference.

virsh_dargs = {'debug': True, 'ignore_status': True}
ignore_check = False

def check_blockcopy_xml(vm_name, source_image, ignore_check=False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'ignore_check' seems unnecessary. If we do not check, we need not to call this function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is tip to make code follow consistent workflow, rather than see too many if ... else

if backend_storage_type == "file":
image_filename = params.get("image_filename", "raw.img")
disk_path = os.path.join(data_dir.get_tmp_dir(), image_filename)
if blockcopy_option in ['reuse_external']:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If only one item, is it better to use blockcopy_option == 'reuse_external' simply?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reserved for further extension

"hosts": [{"name": gluster_host_ip,
"port": "24007"}]}
checkout_device_source = gluster_img_name
test.cancel("gluster permission denied issue,see https://bugzilla.redhat.com/show_bug.cgi?id=1447694")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure the reason to raise an exception here directly. Don't we need to run some commands and filter the output to decide if cancel?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be some problem here, even have bug, we still need to give test.fail and let CI judge it is skip or not. And the bug info can shown in test.fail

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we now know Bugzilla 1447694 is currently-existed known issue, using test.cancel directly can save prepare effort, which is nothing useful when case is cancelled eventually.
tp-libvirt is standalone upstream project, does it make sense that additional CI is necessarily used to judge skip or not. How can we assume that any team ,which want to use tp-libvirt, need setup CI as pre-request.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dealing with the skip case in CI will keep the code consistent even the bug fixed, so we prefer not deal with the bug in code. Else, you may forget to update it even the bug fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upstream first!
As tp-libvirt is standalone upstream project, if issue can be handled in upstream, we CAN NOT leave it to be handled by downstream , such as CI, which you mentioned here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure that this bug is RHEL bug but not upstream bug, it is not suitable to show non upstream bug number here. The case fail with bug is acceptable for upstream testing as it have fail/bug indeed. Also we set in CI not change the failure result of tp-libvirt test, it just SHOW SKIP in jenkins, but still failure in test.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And also, a test.cancel here without any situation is not a reasonable logic. Please think and check again, thanks

Copy link
Contributor Author

@chunfuwen chunfuwen Sep 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete this part test logic (gluster)to avoid PR stuck due to some controversy.
Once condition is met, this logic can be brought back.

logging.debug("disk auth dict is: %s" % disk_auth_dict)
disk_source.auth = disk_xml.new_auth(**disk_auth_dict)
disk_xml.source = disk_source
logging.debug("new disk xml is: %s", disk_xml)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move L252-L265 to L285 where it is referenced for better readability.

Copy link
Contributor Author

@chunfuwen chunfuwen Jul 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all code lines before 251 prepare disk source with different backing end, just after that, one disk_xml is provisioned to consume disk source. Therefore, the workflow sounds very natural.

try:
nbd.cleanup()
except Exception as ndbEx:
logging.info("Clean Up nbd failed: %s" % str(ndbEx))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logging.error is better?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe forget to update?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, updated now

virt_disk_device_type = "network"
nbd_server_port = "10001"
variants:
- positive_test:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nothing more for it? If you want to reserve a interface here, maybe you also need a parameter to show how to judge it is positive or negative

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is reserved for extension. Once it happen, one variant will be added for that.

for line in blklist:
if line.strip().startswith(('hd', 'vd', 'sd', 'xvd')):
source_imge_list.append(line.split()[-1])
logging.debug('vm list is :')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what you want to debug here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe forget to update?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated now

"hosts": [{"name": gluster_host_ip,
"port": "24007"}]}
checkout_device_source = gluster_img_name
test.cancel("gluster permission denied issue,see https://bugzilla.redhat.com/show_bug.cgi?id=1447694")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be some problem here, even have bug, we still need to give test.fail and let CI judge it is skip or not. And the bug info can shown in test.fail

size=size, disk_format="raw")
s_attach = virsh.attach_disk(vm_name, tmp_device_source, device_target,
"--config", debug=True)
libvirt.check_exit_status(s_attach)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use ignore_status in virsh, thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is common usage.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, acceptable as discussed

result = virsh.blockcopy(vm_name, device_target, "--xml %s" % disk_xml.xml,
options=options,
debug=True)
libvirt.check_exit_status(result)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is common usage

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, acceptable as discussed

Copy link
Contributor

@kylazhang kylazhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please check the comments and give update, thanks

"hosts": [{"name": gluster_host_ip,
"port": "24007"}]}
checkout_device_source = gluster_img_name
test.cancel("gluster permission denied issue,see https://bugzilla.redhat.com/show_bug.cgi?id=1447694")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two points I'd like to say:

  1. As the team discussed before, we use CI blacklist to filter the expected error message to decide if the failure should be ignored or not. This method has been used for long time within the team. For this bug, if we use blacklist way, we need raise test.fail(xxx) if checking fails and blacklist will check 'xxx' to decide 'skip' or 'fail'. And when the bug is fixed, the case will PASS without any other updates by us.
    But if you would not like this way, shall we discuss if this way's good for us? Would you like to launch the discussion?

  2. Using your current way, would you like to track the status of this bug and update the case when the bug is fixed in future?

Copy link
Contributor Author

@chunfuwen chunfuwen Aug 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mention previously, upstream first is our senior principle and Red Hat's value proposition.
Please keep mind that what upstream does and what downstream does.
If CI blacklist can have better handling for bugzilla status, we can consider move those logic into tp-libvirt.
For example, we can check whether the bugzilla is valid before we can test.cancel.

Moreover, even checking current CI blacklist ,you will find that there are nearly 3000 lines there,and all mess up and become more and more hard to maintain.

Copy link
Contributor

@kylazhang kylazhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please check comments, thanks

checkout_device_source = ceph_disk_name
elif backend_storage_type == "nbd":
# Get server hostname.
hostname = process.run('hostname', ignore_status=False, shell=True, verbose=True).stdout_text.strip()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to use python built-in function to get host name according to we discussed before.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

# Create an local image and make FS on it.
disk_cmd = ("qemu-img create -f %s %s %s" %
(device_format, img_file, storage_size))
process.run(disk_cmd, ignore_status=False, shell=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

libvirt.create_local_disk() can easily work for L187-189.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

"name": "%s/%s" % (iscsi_target, lun_num)},
"hosts": [{"name": iscsi_host, "port": iscsi_port}]}
checkout_device_source = 'emulated-iscsi'
elif backend_storage_type == "ceph":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly recommend we create some ceph utility functions because it seems many work can be reuse, for example, convert the image to remote storage, clear disks in advance, prepare config file/package and so on.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create one issue to track the progress:#3055


logging.debug("device source is: %s", device_source)
# Add disk xml.
vmxml = vm_xml.VMXML.new_from_dumpxml(vm_name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

libvirt.create_disk_xml() should work for Line 230 - 242.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if check the implementation libvirt.create_disk_xml(), it use nearly hardcoded source_params to create disk_source,which will not satisfy current situation covering different backend storage.
source_params = {"attrs": source_attrs, "seclabels": source_seclabel,
"hosts": source_host}
src_config_file = params.get("source_config_file")
if src_config_file:
source_params.update({"config_file": src_config_file})
# If we use config file, "hosts" isn't needed
if "hosts" in source_params:
source_params.pop("hosts")
snapshot_name = params.get('source_snap_name')
if snapshot_name:
source_params.update({"snapshot_name": snapshot_name})
disk_source = diskxml.new_disk_source(**source_params)

libvirt.setup_or_cleanup_iscsi(is_setup=False)
elif backend_storage_type == "ceph":
# Remove ceph configure file if created.
if ceph_cfg:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For ceph client clean up, it is better to create a reusable function

Copy link
Contributor Author

@chunfuwen chunfuwen Sep 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use one issue to track the progress:#3055

Cover different backend storage such as file,block,iscsi,rbd,nbd,ceph and gluster

Signed-off-by: chunfuwen <[email protected]>
@chunfuwen
Copy link
Contributor Author

@dzhengfy
comments are updated accordingly, please take a look.

Copy link
Contributor

@dzhengfy dzhengfy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have issues tracking for some discussion points.

@dzhengfy dzhengfy merged commit 82822a1 into autotest:master Sep 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants