tests/avocado: Fixes for ppc_hv_tests.py
cover tests/avocado: Fixes for ppc_hv_tests.py
This series is a bunch of fixes for ppc_hv_tests.py. It includes a generic avocado patch that I've posted before, but that seems to only really affect ppc_hv_tests.py (I haven't seen other tests wait for console after executing a command like this).
If people feel patch 3 is too late for 9.0, then patch 4 should be left of too, but 1 and 2 at least should resolve some CI failures and are self-contained.
Thanks,
Nick
Nicholas Piggin (4):
tests/avocado: Fix ppc_hv_tests.py xorriso dependency guard tests/avocado: ppc_hv_tests.py set alpine time before setup-alpine tests/avocado: exec_command should not consume console output tests/avocado: Mark ppc_hv_tests.py as non-flaky after fixed console
interaction
tests/avocado/avocado_qemu/__init__.py | 7 +++++++ tests/avocado/ppc_hv_tests.py | 7 +++++-- 2 files changed, 12 insertions(+), 2 deletions(-)
Signature · 1 line
2.42.0
PATCH 4/4 tests/avocado: Mark ppc_hv_tests.py as non-flaky after fixed console interaction
Now that exec_command doesn't incorrectly consume console output, and guest time is set correctly, ppc_hv_tests.py is working more reliably. Try marking it non-flaky.
--- tests/avocado/ppc_hv_tests.py | 1 - 1 file changed, 1 deletion(-)
tests/avocado/ppc_hv_tests.py +0 -1
@@ -45,7 +45,6 @@ def missing_deps(): # QEMU already installed and use that. # XXX: The order of these tests seems to matter, see git blame. @skipIf(missing_deps(), 'dependencies (%s) not installed' % ','.join(deps)) -@skipUnless(os.getenv('QEMU_TEST_FLAKY_TESTS'), 'Test sometimes gets stuck due to console handling problem') @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited') @skipUnless(os.getenv('SPEED') == 'slow', 'runtime limited') class HypervisorTest(QemuSystemTest):
Signature · 1 line
2.42.0
PATCH 1/4 tests/avocado: Fix ppc_hv_tests.py xorriso dependency guard
In reply to Nicholas PigginFor some reason the skipIf missing_deps() check fails to skip the test if it comes after the skipUnless lines, causing an error running on systems without xorriso.
Avocado implements skipUnless is just an inverted skipIf, so it's not clear what the bug is or why this fixes it. For now it's enough to get things working.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2246
--- tests/avocado/ppc_hv_tests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tests/avocado/ppc_hv_tests.py +2 -1
@@ -42,10 +42,11 @@ def missing_deps(): # QEMU packages are downloaded and installed on each test. That's not a # large download, but it may be more polite to create qcow2 image with # QEMU already installed and use that. +# XXX: The order of these tests seems to matter, see git blame. +@skipIf(missing_deps(), 'dependencies (%s) not installed' % ','.join(deps)) @skipUnless(os.getenv('QEMU_TEST_FLAKY_TESTS'), 'Test sometimes gets stuck due to console handling problem') @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited') @skipUnless(os.getenv('SPEED') == 'slow', 'runtime limited') -@skipIf(missing_deps(), 'dependencies (%s) not installed' % ','.join(deps)) class HypervisorTest(QemuSystemTest): timeout = 1000
Signature · 1 line
2.42.0
PATCH 3/4 tests/avocado: exec_command should not consume console output
In reply to Nicholas Piggin_console_interaction reads data from the console even when there is only an input string to send, and no output data to wait on. This can cause lines to be missed by wait_for_console_pattern calls that follows an exec_command. Fix this by not reading the console if there is no pattern to wait for.
This solves occasional hangs in ppc_hv_tests.py, usually when run on KVM hosts that are fast enough to output important lines quickly enough to be consumed by exec_command, so they get missed by subsequent wait for pattern calls.
--- tests/avocado/avocado_qemu/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+)
tests/avocado/avocado_qemu/__init__.py +7 -0
@@ -144,6 +144,13 @@ def _console_interaction(test, success_message, failure_message, vm.console_socket.sendall(send_string.encode()) if not keep_sending: send_string = None # send only once + + # Only consume console output if waiting for something + if success_message is None and failure_message is None: + if send_string is None: + break + continue + try: msg = console.readline().decode().strip() except UnicodeDecodeError:
Signature · 1 line
2.42.0
PATCH 2/4 tests/avocado: ppc_hv_tests.py set alpine time before setup-alpine
In reply to Nicholas PigginIf the time is wrong, setup-alpine SSL certificate checks can fail. setup-alpine is used to bring up the network, but it doesn't seem to to set NTP time before the failing SSL checks. This test has recently started failing presumably because the default time has now fallen too far behind.
Fix this by setting time from the host time before running setup-alpine.
--- tests/avocado/ppc_hv_tests.py | 3 +++ 1 file changed, 3 insertions(+)
tests/avocado/ppc_hv_tests.py +3 -0
@@ -14,6 +14,7 @@ import os import time import subprocess +from datetime import datetime deps = ["xorriso"] # dependent tools needed in the test setup/box.
@@ -107,6 +108,8 @@ def do_start_alpine(self): exec_command(self, 'root') wait_for_console_pattern(self, 'localhost login:') wait_for_console_pattern(self, 'You may change this message by editing /etc/motd.') + # If the time is wrong, SSL certificates can fail. + exec_command(self, 'date -s "' + datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S' + '"')) exec_command(self, 'setup-alpine -qe') wait_for_console_pattern(self, 'Updating repository indexes... done.')
Signature · 1 line
2.42.0