Skip to contentSkip to conversation

tests/avocado: Fix exec_command and enable ppc_hv_tests.py

PATCH In review Nicholas Piggin 2 participants 4 messages Aug 5, 2024 – Aug 15, 2024

lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index a3da2a96bb..ef935614cf 100644
@@ -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
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] tests/avocado: exec_command should not consume console output

Quoted 24 lines · 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 +0 -0
index a3da2a96bb..ef935614cf 100644
@@ -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:
#3 lore raw

PATCH 2/2 tests/avocado: Mark ppc_hv_tests.py as non-flaky after fixed console interaction

In reply to Nicholas Piggin

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
index bf8822bb97..0e83bbac71 100644
@@ -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