Skip to content

Commit 81fdc50

Browse files
committed
[Test] Make test_essential_features more resilient
by accepting the legit scenario where logs, such as compute_console_output.log, may not have new content from compute nodes after rotation. Signed-off-by: Giacomo Marciani <mgiacomo@amazon.com>
1 parent 27b35ab commit 81fdc50

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tests/integration-tests/tests/basic/log_rotation_utils.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ def _wait_file_not_empty(remote_command_executor, file_path, compute_node_ip=Non
2525
assert_that(size).is_not_equal_to("0")
2626

2727

28+
def _touch_file(remote_command_executor, file_path, compute_node_ip=None):
29+
"""Touch a file on head node or compute node."""
30+
command = f"touch {file_path}"
31+
if compute_node_ip:
32+
_run_command_on_node(remote_command_executor, command, compute_node_ip)
33+
else:
34+
remote_command_executor.run_remote_command(command)
35+
36+
2837
def _run_command_on_node(remote_command_executor, command, compute_node_ip=None):
2938
"""Run remote command on head node or compute node."""
3039
if compute_node_ip:
@@ -159,10 +168,14 @@ def _test_logs_are_rotated(os, logs, remote_command_executor, before_log_rotatio
159168

160169
def _test_logs_written_to_new_file(logs, remote_command_executor, compute_node_ip=None):
161170
"""Test newly generated logs write to log_file.log instead of log_file.log.1."""
162-
# test logs are written to new log files after rotation
171+
# test logs are written to new log files after rotation.
172+
# For those logs that do not necessarily have new entries,
173+
# we touch the file to force the existence for later checks.
163174
for log in logs:
164175
if log.get("trigger_new_entries"):
165176
_wait_file_not_empty(remote_command_executor, log.get("log_path"), compute_node_ip)
177+
else:
178+
_touch_file(remote_command_executor, log.get("log_path"), compute_node_ip)
166179

167180

168181
def _test_logs_uploaded_to_cloudwatch(

0 commit comments

Comments
 (0)