Skip to content

Commit

Permalink
add logging and generify smoke test
Browse files Browse the repository at this point in the history
  • Loading branch information
ShreyasKallingal committed Jul 26, 2024
1 parent c2d6fd7 commit ba3f164
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions sky/utils/log_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,13 @@ def create_and_symlink_log_dir(log_dir: str):
try:
os.remove(symlink_path)
except OSError:
logger.warning('Failed to remove old symlink to latest logs'
f'at {symlink_path!r}.')
return
else:
logger.warning(
(f'Failed to symlink to latest logs at {symlink_path!r}.'
'Please remove the existing file/directory.'))
f'Failed to symlink to latest logs at {symlink_path!r}.'
'Please remove the existing file/directory.')
return
try:
os.symlink(log_dir, symlink_path)
Expand Down
10 changes: 5 additions & 5 deletions tests/test_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -1317,22 +1317,22 @@ def test_scp_logs():
run_one_test(test)


@pytest.mark.kubernetes
def test_symlink_latest_logs():
def test_symlink_latest_logs(generic_cloud: str):
name = _get_cluster_name()
test = Test(
'symlink_latest_logs',
[
'sky launch -c test1 --cloud kubernetes -- echo hi > log1.txt || true',
f'sky launch -y -c {name} --cloud {generic_cloud} -- echo hi > log1.txt || true',
'eval symlink_path="~/sky_logs/sky_latest"; [ -L "$symlink_path" ] || exit 1 ;'
'target_file=$(readlink -f "$symlink_path") || exit 1 ;'
'grep -E "To view detailed progress: .+ $target_file" log1.txt || exit 1;'
'sky launch -c test1 --cloud kubernetes -- echo hi > log2.txt || true ;'
f'sky launch -y -c {name} --cloud {generic_cloud} -- echo hi > log2.txt || true ;'
'[ -L "$symlink_path" ] || exit 1 ;'
'target_file2=$(readlink -f "$symlink_path") || exit 1 ;'
'grep -E "To view detailed progress: .+ $target_file2" log2.txt || exit 1;'
'[ "$target_file" != "$target_file2" ] || exit 1'
],
'rm log1.txt log2.txt',
'rm log1.txt log2.txt 2> /dev/null || true',
)
run_one_test(test)

Expand Down

0 comments on commit ba3f164

Please sign in to comment.