Skip to content

Commit

Permalink
Merge pull request autotest#5173 from smitterl/improve_guests
Browse files Browse the repository at this point in the history
libvirt-guests: Improve test logging
  • Loading branch information
dzhengfy authored Nov 16, 2023
2 parents 90a6935 + 4bf6076 commit dff5fd1
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from avocado.utils import process

from virttest import utils_libguestfs
from virttest import data_dir
from virttest import utils_misc
from virttest import virsh
from virttest import utils_config
Expand Down Expand Up @@ -39,10 +38,9 @@ def get_log():
:returns: the appended data tailed from /var/log/messages
"""
tailed_log_file = os.path.join(data_dir.get_tmp_dir(), 'tail_log')
tailed_messages = aexpect.Tail(command='tail -f /var/log/messages',
output_func=utils_misc.log_line,
output_params=(tailed_log_file))
tailed_messages = aexpect.Tail(command='tail -f /var/log/messages')
logging.debug("Tail of log messages are logged in %s",
tailed_messages.output_filename)
return tailed_messages

def chk_on_shutdown(status_error, on_shutdown, parallel_shutdown, output):
Expand Down Expand Up @@ -265,8 +263,10 @@ def cleanup_nfs_backend_guest(vmxml_backup):

config = utils_config.LibvirtGuestsConfig()
libvirt_guests_service = service.Factory.create_service("libvirt-guests")
if not libvirt_guests_service.status():
libvirt_guests_service.start()
if (not libvirt_guests_service.status()
and not libvirt_guests_service.start()):
process.run("journalctl -u libvirt-guests", ignore_status=True)
test.error("libvirt-guests service failed to start. Please check logs")

vms = [main_vm]
if main_vm.is_alive:
Expand Down Expand Up @@ -319,7 +319,9 @@ def cleanup_nfs_backend_guest(vmxml_backup):
# Even though libvirt-guests was designed to operate guests when
# host shutdown. The purpose can also be fulfilled by restart the
# libvirt-guests service.
libvirt_guests_service.restart()
if not libvirt_guests_service.restart():
process.run("journalctl -u libvirt-guests", ignore_status=True)
test.error("libvirt-guests failed to restart. Please check logs.")
time.sleep(30)
output = tail_messages.get_output()
logging.debug("Get messages in /var/log/messages: %s" % output)
Expand Down

0 comments on commit dff5fd1

Please sign in to comment.