All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] tests/avocado: Fixes for ppc_hv_tests.py
@ 2024-03-28  4:15 Nicholas Piggin
  2024-03-28  4:15 ` [PATCH 1/4] tests/avocado: Fix ppc_hv_tests.py xorriso dependency guard Nicholas Piggin
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Nicholas Piggin @ 2024-03-28  4:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Nicholas Piggin, Cleber Rosa, Philippe Mathieu-Daudé,
	Wainer dos Santos Moschetta, Beraldo Leal, qemu-ppc,
	Peter Maydell

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(-)

-- 
2.42.0



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/4] tests/avocado: Fix ppc_hv_tests.py xorriso dependency guard
  2024-03-28  4:15 [PATCH 0/4] tests/avocado: Fixes for ppc_hv_tests.py Nicholas Piggin
@ 2024-03-28  4:15 ` Nicholas Piggin
  2024-03-28  4:15 ` [PATCH 2/4] tests/avocado: ppc_hv_tests.py set alpine time before setup-alpine Nicholas Piggin
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Nicholas Piggin @ 2024-03-28  4:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Nicholas Piggin, Cleber Rosa, Philippe Mathieu-Daudé,
	Wainer dos Santos Moschetta, Beraldo Leal, qemu-ppc,
	Peter Maydell

For 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
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 tests/avocado/ppc_hv_tests.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/avocado/ppc_hv_tests.py b/tests/avocado/ppc_hv_tests.py
index 5080358e25..2c8ddd9257 100644
--- a/tests/avocado/ppc_hv_tests.py
+++ b/tests/avocado/ppc_hv_tests.py
@@ -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
-- 
2.42.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/4] tests/avocado: ppc_hv_tests.py set alpine time before setup-alpine
  2024-03-28  4:15 [PATCH 0/4] tests/avocado: Fixes for ppc_hv_tests.py Nicholas Piggin
  2024-03-28  4:15 ` [PATCH 1/4] tests/avocado: Fix ppc_hv_tests.py xorriso dependency guard Nicholas Piggin
@ 2024-03-28  4:15 ` Nicholas Piggin
  2024-03-28  4:15 ` [PATCH 3/4] tests/avocado: exec_command should not consume console output Nicholas Piggin
  2024-03-28  4:15 ` [PATCH 4/4] tests/avocado: Mark ppc_hv_tests.py as non-flaky after fixed console interaction Nicholas Piggin
  3 siblings, 0 replies; 5+ messages in thread
From: Nicholas Piggin @ 2024-03-28  4:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Nicholas Piggin, Cleber Rosa, Philippe Mathieu-Daudé,
	Wainer dos Santos Moschetta, Beraldo Leal, qemu-ppc,
	Peter Maydell

If 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.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 tests/avocado/ppc_hv_tests.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tests/avocado/ppc_hv_tests.py b/tests/avocado/ppc_hv_tests.py
index 2c8ddd9257..bf8822bb97 100644
--- a/tests/avocado/ppc_hv_tests.py
+++ b/tests/avocado/ppc_hv_tests.py
@@ -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.')
 
-- 
2.42.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/4] tests/avocado: exec_command should not consume console output
  2024-03-28  4:15 [PATCH 0/4] tests/avocado: Fixes for ppc_hv_tests.py Nicholas Piggin
  2024-03-28  4:15 ` [PATCH 1/4] tests/avocado: Fix ppc_hv_tests.py xorriso dependency guard Nicholas Piggin
  2024-03-28  4:15 ` [PATCH 2/4] tests/avocado: ppc_hv_tests.py set alpine time before setup-alpine Nicholas Piggin
@ 2024-03-28  4:15 ` Nicholas Piggin
  2024-03-28  4:15 ` [PATCH 4/4] tests/avocado: Mark ppc_hv_tests.py as non-flaky after fixed console interaction Nicholas Piggin
  3 siblings, 0 replies; 5+ messages in thread
From: Nicholas Piggin @ 2024-03-28  4:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Nicholas Piggin, Cleber Rosa, Philippe Mathieu-Daudé,
	Wainer dos Santos Moschetta, Beraldo Leal, qemu-ppc,
	Peter Maydell

_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.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 tests/avocado/avocado_qemu/__init__.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tests/avocado/avocado_qemu/__init__.py b/tests/avocado/avocado_qemu/__init__.py
index 304c428168..5a3ae7f6b5 100644
--- a/tests/avocado/avocado_qemu/__init__.py
+++ b/tests/avocado/avocado_qemu/__init__.py
@@ -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:
-- 
2.42.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 4/4] tests/avocado: Mark ppc_hv_tests.py as non-flaky after fixed console interaction
  2024-03-28  4:15 [PATCH 0/4] tests/avocado: Fixes for ppc_hv_tests.py Nicholas Piggin
                   ` (2 preceding siblings ...)
  2024-03-28  4:15 ` [PATCH 3/4] tests/avocado: exec_command should not consume console output Nicholas Piggin
@ 2024-03-28  4:15 ` Nicholas Piggin
  3 siblings, 0 replies; 5+ messages in thread
From: Nicholas Piggin @ 2024-03-28  4:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Nicholas Piggin, Cleber Rosa, Philippe Mathieu-Daudé,
	Wainer dos Santos Moschetta, Beraldo Leal, qemu-ppc,
	Peter Maydell

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.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 tests/avocado/ppc_hv_tests.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tests/avocado/ppc_hv_tests.py b/tests/avocado/ppc_hv_tests.py
index bf8822bb97..0e83bbac71 100644
--- a/tests/avocado/ppc_hv_tests.py
+++ b/tests/avocado/ppc_hv_tests.py
@@ -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):
-- 
2.42.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-03-28  4:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-28  4:15 [PATCH 0/4] tests/avocado: Fixes for ppc_hv_tests.py Nicholas Piggin
2024-03-28  4:15 ` [PATCH 1/4] tests/avocado: Fix ppc_hv_tests.py xorriso dependency guard Nicholas Piggin
2024-03-28  4:15 ` [PATCH 2/4] tests/avocado: ppc_hv_tests.py set alpine time before setup-alpine Nicholas Piggin
2024-03-28  4:15 ` [PATCH 3/4] tests/avocado: exec_command should not consume console output Nicholas Piggin
2024-03-28  4:15 ` [PATCH 4/4] tests/avocado: Mark ppc_hv_tests.py as non-flaky after fixed console interaction Nicholas Piggin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.