From b967306be1ff55a52893b6fef30ec4a07690d668 Mon Sep 17 00:00:00 2001 From: Shreyas Kallingal Date: Sun, 21 Jul 2024 20:21:21 -0700 Subject: [PATCH] Add symlink log smoke test and fix formatting in warning string --- sky/utils/log_utils.py | 2 +- tests/test_smoke.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/sky/utils/log_utils.py b/sky/utils/log_utils.py index 46f9e19e03d..a6871eca901 100644 --- a/sky/utils/log_utils.py +++ b/sky/utils/log_utils.py @@ -210,7 +210,7 @@ def create_and_symlink_log_dir(log_dir: str): os.remove(symlink_path) else: logger.warning(( - 'Failed to create symlink to latest logs at \'{symlink_path}\'.' + f'Failed to create symlink to latest logs at \'{symlink_path}\'.' 'Please remove the existing file/directory.')) return os.symlink(log_dir, symlink_path) diff --git a/tests/test_smoke.py b/tests/test_smoke.py index 325a836cf4c..bca18777235 100644 --- a/tests/test_smoke.py +++ b/tests/test_smoke.py @@ -1317,6 +1317,24 @@ def test_scp_logs(): run_one_test(test) +@pytest.mark.kubernetes +def test_symlink_latest_logs(): + test = Test( + 'symlink_latest_logs', + [ + 'sky local up || true', + 'eval symlink_path="~/sky_logs/sky_latest"; [ -L "$symlink_path" ] || exit 1 ;' + 'target_file=$(readlink -f "$symlink_path") || exit 1 ;' + 'sky local down || true ;' + '[ -L "$symlink_path" ] || exit 1 ;' + 'target_file2=$(readlink -f "$symlink_path") ;' + '[ "$target_file" != "$target_file2" ] || exit 1' + ], + 'sky local down', + ) + run_one_test(test) + + # ---------- Job Queue. ---------- @pytest.mark.no_fluidstack # FluidStack DC has low availability of T4 GPUs @pytest.mark.no_lambda_cloud # Lambda Cloud does not have T4 gpus