Skip to content

[virsh metadata] change the checking logic for missing metadata #6376

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

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
2 changes: 2 additions & 0 deletions libvirt/tests/cfg/virsh_cmd/domain/virsh_metadata.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
variants:
- config_current_option:
metadata_set = "yes"
metadata_empty = "yes"
metadata_option = "--config --current"
- live_current_option:
metadata_set = "yes"
metadata_empty = "yes"
metadata_option = "--live --current"
- invalid_option:
metadata_option = "--xyz"
Expand Down
7 changes: 6 additions & 1 deletion libvirt/tests/src/virsh_cmd/domain/virsh_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def run(test, params, env):
virsh_dargs = {'debug': True, 'ignore_status': True}
metadata_set = "yes" == params.get("metadata_set", "no")
metadata_get = "yes" == params.get("metadata_get", "yes")
metadata_empty = "yes" == params.get("metadata_empty", "no")
metadata_remove = "yes" == params.get("metadata_remove", "no")
restart_libvirtd = "yes" == params.get("restart_libvirtd", "no")
status_error = "yes" == params.get("status_error", "no")
Expand Down Expand Up @@ -110,6 +111,10 @@ def get_metadata(metadata_option=""):
**virsh_dargs)
check_result(result, status_error)
# Get metadata
# from libvirt 11.3.0, instead of return status error, libvirt will return an empty string if there is no metadata to be returned
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this comment in favor of cleaner code, the information is available in your commit message.

if metadata_empty:
status_error = False
metadata_value = ""
for option in metadata_option.split():
if option == "--config":
vm.destroy()
Expand Down Expand Up @@ -137,6 +142,6 @@ def get_metadata(metadata_option=""):
check_result(result, status_error)
# Get metadata again
for option in metadata_option.split():
check_result(get_metadata(metadata_option=option), True)
check_result(get_metadata(metadata_option=option), False, '')
Copy link
Contributor

Choose a reason for hiding this comment

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

Will negative scenarios now fail for previous libvirt versions? If so, maybe the negative scenarios should only be run with 11.3.0 or later. This can be achieved by using version switch as described here: https://github.com/autotest/tp-libvirt/blob/master/tp-libvirt_review_comment_summary.rst?plain=1#L121

finally:
vmxml.sync()