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

Snapshot: add new auto case for snapshot-list #5835

Merged
merged 1 commit into from
Aug 28, 2024

Conversation

meinaLi
Copy link
Contributor

@meinaLi meinaLi commented Aug 8, 2024

Automate case VIRT-16603 - [Disk snapshot][External] Get guest snapshot list with option

@meinaLi
Copy link
Contributor Author

meinaLi commented Aug 8, 2024

# avocado run --vt-type libvirt --test-runner=runner --vt-machine-type q35 snapshot_list.with_options
JOB ID     : c1cb5ada2b7bc3bd1b02a88efc4236ff5d269003
JOB LOG    : /root/avocado/job-results/job-2024-08-08T04.38-c1cb5ad/job.log
 (1/9) type_specific.io-github-autotest-libvirt.snapshot_list.with_options.roots: PASS (34.97 s)
 (2/9) type_specific.io-github-autotest-libvirt.snapshot_list.with_options.leaves: PASS (28.24 s)
 (3/9) type_specific.io-github-autotest-libvirt.snapshot_list.with_options.no_leaves.with_external: PASS (34.83 s)
 (4/9) type_specific.io-github-autotest-libvirt.snapshot_list.with_options.no_leaves.with_inactive: PASS (29.13 s)
 (5/9) type_specific.io-github-autotest-libvirt.snapshot_list.with_options.no_leaves.with_active: PASS (27.08 s)
 (6/9) type_specific.io-github-autotest-libvirt.snapshot_list.with_options.no_leaves.with_disk_only: PASS (33.51 s)
 (7/9) type_specific.io-github-autotest-libvirt.snapshot_list.with_options.from_and_descendants: PASS (29.30 s)
 (8/9) type_specific.io-github-autotest-libvirt.snapshot_list.with_options.topological: PASS (27.31 s)
 (9/9) type_specific.io-github-autotest-libvirt.snapshot_list.with_options.parent: PASS (36.40 s)
RESULTS    : PASS 9 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB HTML   : /root/avocado/job-results/job-2024-08-08T04.38-c1cb5ad/results.html
JOB TIME   : 282.82 s

@meinaLi
Copy link
Contributor Author

meinaLi commented Aug 15, 2024

@nanli1 Can you help to review this PR? Thanks.

bkxml = vmxml.copy()
virsh_dargs = {"debug": True, "ignore_status": False}
test_obj = snapshot_base.SnapshotTest(vm, test, params)
libvirt_version.is_libvirt_feature_supported(params)
Copy link
Contributor

Choose a reason for hiding this comment

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

Version checking could me more forward ,maybe L68

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think moving to L76 is more better after variant definition. So I've updated it to there.

virsh.snapshot_create_as(vm_name, "%s --disk-only" % snap_names[0], **virsh_dargs)
test.log.info("TEST_SETUP: Prepare running guest and create a disk only snapshot.")
if not vm.is_alive():
vm.start()
Copy link
Contributor

Choose a reason for hiding this comment

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

We could login vm to avoid some unpredictable issues

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I think it's a useful checkpoint. Finish to update now.

Comment on lines 50 to 51
cmd = "virsh snapshot-list %s %s" % (vm_name, list_options)
list_result = process.run(cmd, shell=True, ignore_status=False).stdout_text.split()
Copy link
Contributor

Choose a reason for hiding this comment

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

For virsh commands, I think it's better to reuse the functions in virsh module. Can you plz try virsh.command or virsh.snapshot_list?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I've tried to use virsh.snapshot_list before. But it's hard to deal with the result to match the expected list. Maybe you can have more better solution to deal with the cmd result?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, can you plz tell me what the problem is? and can't 'virsh.command' be used?

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 to your detailed introduction. I changed it from process.run to virsh.command and the cases can pass.

if list_dict.get(key) != value:
test.fail("Get incorrect result %s, the expected result is %s" %
(list_result, expected_dict))
test.log.debug("Get expected result for snapshot-list options %s" %
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
test.log.debug("Get expected result for snapshot-list options %s" %
test.log.debug("Get expected result for snapshot-list options %s",

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.

if snap_name not in snap_list:
test.fail("Snapshot %s doesn't exist" % snap_name)
else:
test.log.info("Snapshot %s is in expected snapshot list." % snap_name)
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 ','.

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.

Automate case VIRT-16603 - [Disk snapshot][External] Get guest snapshot list with option

Signed-off-by: Meina Li <[email protected]>
@Yingshun Yingshun merged commit 117e215 into autotest:master Aug 28, 2024
5 checks passed
@meinaLi meinaLi deleted the snapshot_list branch August 29, 2024 02:32
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