Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
asaiacai committed Jul 18, 2024
1 parent ee55e82 commit 4905134
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 3 deletions.
5 changes: 2 additions & 3 deletions sky/templates/kubernetes-ray.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ available_node_types:
- |
FILE_PATTERN="~/sky_logs/*/tasks/*.log"
while ! ls $(eval echo $FILE_PATTERN) 1> /dev/null 2>&1; do
sleep 5
sleep 0.1
done
# Tails file and checks every 5 sec for
# open file handlers with write access
Expand Down Expand Up @@ -355,8 +355,7 @@ available_node_types:
monitor_file $file &
already_monitored="${already_monitored} ${file}"
done

sleep 5
sleep 0.1
done

ports:
Expand Down
81 changes: 81 additions & 0 deletions tests/test_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -1979,6 +1979,87 @@ def test_task_labels_kubernetes():
run_one_test(test)


# ---------- Container logs from task on Kubernetes ----------
@pytest.mark.kubernetes
def test_container_logs_multinode_kubernetes():
name = _get_cluster_name()
task_yaml = 'tests/test_yamls/test_k8s_logs.yaml'
with tempfile.NamedTemporaryFile(suffix='.yaml', mode='w') as f:
test = Test(
'container_logs_multinode_kubernetes',
[
f'sky launch -y -c {name} {task_yaml} --num-nodes 2',
'kubectl get pods -o jsonpath="{.items[*].metadata.name}" | tr " " "\n" | grep worker'
'| xargs -I {} kubectl logs {} | wc -l | grep 9',
'kubectl get pods -o jsonpath="{.items[*].metadata.name}" | tr " " "\n" | grep head'
'| xargs -I {} kubectl logs {} | wc -l | grep 9',
],
f'sky down -y {name}',
)
run_one_test(test)


@pytest.mark.kubernetes
def test_container_logs_two_jobs_kubernetes():
name = _get_cluster_name()
task_yaml = 'tests/test_yamls/test_k8s_logs.yaml'
pod_logs = (
'kubectl get pods -o jsonpath="{.items[*].metadata.name}"| grep head | xargs -I {} kubectl logs {}'
)
with tempfile.NamedTemporaryFile(suffix='.yaml', mode='w') as f:
test = Test(
'test_container_logs_two_jobs_kubernetes',
[
f'sky launch -y -c {name} {task_yaml}',
f'{pod_logs} | wc -l | grep 9',
f'sky launch -y -c {name} {task_yaml}',
f'{pod_logs} | wc -l | grep 18',
f'{pod_logs} | grep 1 | wc -l | grep 2',
f'{pod_logs} | grep 2 | wc -l | grep 2',
f'{pod_logs} | grep 3 | wc -l | grep 2',
f'{pod_logs} | grep 4 | wc -l | grep 2',
f'{pod_logs} | grep 5 | wc -l | grep 2',
f'{pod_logs} | grep 6 | wc -l | grep 2',
f'{pod_logs} | grep 7 | wc -l | grep 2',
f'{pod_logs} | grep 8 | wc -l | grep 2',
f'{pod_logs} | grep 9 | wc -l | grep 2',
],
f'sky down -y {name}',
)
run_one_test(test)


@pytest.mark.kubernetes
def test_container_logs_two_simultaneous_jobs_kubernetes():
name = _get_cluster_name()
task_yaml = 'tests/test_yamls/test_k8s_logs.yaml'
pod_logs = (
'kubectl get pods -o jsonpath="{.items[*].metadata.name}"| grep head | xargs -I {} kubectl logs {}'
)
with tempfile.NamedTemporaryFile(suffix='.yaml', mode='w') as f:
test = Test(
'test_container_logs_two_simultaneous_jobs_kubernetes',
[
f'sky launch -y -c {name}',
f'sky exec -c {name} -d {task_yaml}',
f'sky exec -c {name} -d {task_yaml}',
'sleep 5',
f'{pod_logs} | wc -l | grep 18',
f'{pod_logs} | grep 1 | wc -l | grep 2',
f'{pod_logs} | grep 2 | wc -l | grep 2',
f'{pod_logs} | grep 3 | wc -l | grep 2',
f'{pod_logs} | grep 4 | wc -l | grep 2',
f'{pod_logs} | grep 5 | wc -l | grep 2',
f'{pod_logs} | grep 6 | wc -l | grep 2',
f'{pod_logs} | grep 7 | wc -l | grep 2',
f'{pod_logs} | grep 8 | wc -l | grep 2',
f'{pod_logs} | grep 9 | wc -l | grep 2',
],
f'sky down -y {name}',
)
run_one_test(test)


# ---------- Task: n=2 nodes with setups. ----------
@pytest.mark.no_lambda_cloud # Lambda Cloud does not have V100 gpus
@pytest.mark.no_ibm # IBM cloud currently doesn't provide public image with CUDA
Expand Down

0 comments on commit 4905134

Please sign in to comment.