Skip to content

Commit 4b945db

Browse files
pb8oalxiord
authored andcommitted
chore(tests): add more logging in case of error
Signed-off-by: Pablo Barbáchano <pablob@amazon.com>
1 parent 2fe205b commit 4b945db

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

tests/integration_tests/functional/test_balloon.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,29 @@ def get_rss_from_pmap():
4545

4646
def make_guest_dirty_memory(ssh_connection, should_oom=False, amount=8192):
4747
"""Tell the guest, over ssh, to dirty `amount` pages of memory."""
48+
logger = logging.getLogger("make_guest_dirty_memory")
49+
4850
amount_in_mbytes = amount / MB_TO_PAGES
4951

50-
exit_code, _, _ = ssh_connection.execute_command(
51-
"/sbin/fillmem {}".format(amount_in_mbytes)
52-
)
52+
cmd = f"/sbin/fillmem {amount_in_mbytes}"
53+
exit_code, stdout, stderr = ssh_connection.execute_command(cmd)
54+
# add something to the logs for troubleshooting
55+
if exit_code != 0:
56+
logger.error("while running: %s", cmd)
57+
logger.error("stdout: %s", stdout.read())
58+
logger.error("stderr: %s", stderr.read())
5359

5460
cmd = "cat /tmp/fillmem_output.txt"
5561
_, stdout, _ = ssh_connection.execute_command(cmd)
5662
if should_oom:
5763
assert (
58-
exit_code == 0
59-
and ("OOM Killer stopped the program with " "signal 9, exit code 0")
60-
in stdout.read()
64+
"OOM Killer stopped the program with "
65+
"signal 9, exit code 0" in stdout.read()
6166
)
6267
else:
63-
assert exit_code == 0 and ("Memory filling was " "successful") in stdout.read()
68+
assert exit_code == 0, stderr.read()
69+
stdout_txt = stdout.read()
70+
assert "Memory filling was successful" in stdout_txt, stdout_txt
6471

6572

6673
def build_test_matrix(network_config, bin_cloner_path, logger):

tests/integration_tests/functional/test_snapshot_basic.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ def _test_seq_snapshots(context):
103103
microvm, _ = vm_builder.build_from_snapshot(
104104
snapshot, resume=True, diff_snapshots=diff_snapshots
105105
)
106-
107106
# Test vsock guest-initiated connections.
108107
path = os.path.join(
109108
microvm.path, make_host_port_path(VSOCK_UDS_PATH, ECHO_SERVER_PORT)

0 commit comments

Comments
 (0)