tests/avocado: Fix exec_command and enable ppc_hv_tests.py
cover tests/avocado: Fix exec_command and enable ppc_hv_tests.py
This fixes an issue with exec_command eating console output and causing the ppc_hv_tests.py to fail. A few other tests also use exec_command but I didn't see any that subsequently checked console output.
Thanks,
Nick
Nicholas Piggin (2):
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 | 1 - 2 files changed, 7 insertions(+), 1 deletion(-)
Signature · 1 line
2.45.2
PATCH 1/2 tests/avocado: exec_command should not consume console output
_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
@@ -135,6 +135,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.45.2
Re: [PATCH 1/2] tests/avocado: exec_command should not consume console output
Quoted 24 lines · Nicholas Piggin
_console_interactionreads 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 bywait_for_console_patterncalls that follows anexec_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 byexec_command, so they get missed by subsequent wait for pattern calls.Signed-off-by Nicholas Piggin <[email protected]>--- tests/avocado/avocado_qemu/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+)tests/avocado/avocado_qemu/__init__.py +0
-0@@ -135,6 +135,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
tests/avocado/avocado_qemu/__init__.py def _console_interaction(test, success_message, failure_message, · line 147
Quoted 10 lines
tests/avocado/avocado_qemu/__init__.py +7
-0+ + # 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:
PATCH 2/2 tests/avocado: Mark ppc_hv_tests.py as non-flaky after fixed console interaction
In reply to Nicholas PigginNow 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.45.2