Skip to content

Commit

Permalink
Merge pull request autotest#5635 from cliping/VIRT-60228
Browse files Browse the repository at this point in the history
graphics: Add case to test no specified listen type for vnc graphic
  • Loading branch information
Yingshun authored Jun 26, 2024
2 parents 8a7eb41 + 3aac99c commit 4be9bbc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
5 changes: 5 additions & 0 deletions libvirt/tests/cfg/graphics/graphics_functional.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,11 @@
need_vnc_dict = "no"
check_dom_xml = "yes"
check_qemu_pattern = '-vnc none'
- listen_type_non_exist:
vnc_listen_type = "not_exist"
vnc_autoport = "not_set"
need_vnc_dict = "no"
check_dom_xml = "yes"
- listen_type_address:
vnc_listen_type = 'address'
variants:
Expand Down
43 changes: 24 additions & 19 deletions libvirt/tests/src/graphics/graphics_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,9 @@ def handle_auto_filled_items(given_graphic_attrs, vm, params):
given_graphic_attrs['listen_attrs'].update({'address': utils_net.get_host_ip_address()})
elif vnc_network_type == 'vnet':
given_graphic_attrs['listen_attrs'].update({'address': params.get('vnet_address')})
elif vnc_listen_type == 'not_exist':
given_graphic_attrs.update({'listen_attrs': {'type': 'address'}})

if vnc_port and vnc_port == '0':
del given_graphic_attrs['port']
given_graphic_attrs.update({'listen_attrs': {'type': 'address'}})
Expand Down Expand Up @@ -1707,26 +1710,28 @@ def run(test, params, env):
if spice_listen_type == "network" or vnc_listen_type == "network":
for ip in all_ips:
ip.addr = ipaddress.ip_address(ip.addr).compressed
try:
logging.debug("Before starting, vm xml:\n%s", VMXML.new_from_dumpxml(vm_name))
vm.start()
logging.debug("After starting, vm xml:\n%s", VMXML.new_from_dumpxml(vm_name))
except virt_vm.VMStartError as detail:
compare_guest_xml(vnc_graphic, vm, params, test)
if not fail_patts:
test.fail(
"Expect VM can be started, but failed with: %s" % detail)
for patt in fail_patts:
if re.search(patt, str(detail)):
return
test.fail(
"Expect fail with error in %s, but failed with: %s"
% (fail_patts, detail))
else:
if fail_patts:

logging.debug("Before starting, vm xml:\n%s", VMXML.new_from_dumpxml(vm_name))
if vnc_listen_type != "not_exist":
try:
vm.start()
logging.debug("After starting, vm xml:\n%s", VMXML.new_from_dumpxml(vm_name))
except virt_vm.VMStartError as detail:
compare_guest_xml(vnc_graphic, vm, params, test)
if not fail_patts:
test.fail(
"Expect VM can be started, but failed with: %s" % detail)
for patt in fail_patts:
if re.search(patt, str(detail)):
return
test.fail(
"Expect VM can't be started with %s, but started."
% fail_patts)
"Expect fail with error in %s, but failed with: %s"
% (fail_patts, detail))
else:
if fail_patts:
test.fail(
"Expect VM can't be started with %s, but started."
% fail_patts)

if spice_xml:
spice_opts, plaintext_channels, tls_channels = qemu_spice_options(vm)
Expand Down

0 comments on commit 4be9bbc

Please sign in to comment.