Skip to content

Commit 39c90c0

Browse files
authored
[Tests] Fix pod tag test (#4700)
* fix pod tag test * format
1 parent 9c7ab0f commit 39c90c0

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

tests/smoke_tests/test_cluster_job.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -845,14 +845,15 @@ def test_add_pod_annotations_for_autodown_with_launch():
845845
# Autodown is set.
846846
f'sky launch -y -c {name} -i 10 --down --num-nodes 2 --cpus=1 --cloud kubernetes',
847847
# Get names of the pods containing cluster name.
848-
f'pod_1=$(kubectl get pods -o name | grep {name} | sed -n 1p)',
849-
f'pod_2=$(kubectl get pods -o name | grep {name} | sed -n 2p)',
848+
f'pod_1=$(kubectl get pods -o name | grep {name} | sed -n 1p) && '
850849
# Describe the first pod and check for annotations.
851-
'kubectl describe pod $pod_1 | grep -q skypilot.co/autodown',
852-
'kubectl describe pod $pod_1 | grep -q skypilot.co/idle_minutes_to_autostop',
850+
'pod_tag=$(kubectl describe $pod_1); echo "$pod_tag"; echo "$pod_tag" | grep -q skypilot.co/autodown && '
851+
'pod_tag=$(kubectl describe $pod_1); echo "$pod_tag"; echo "$pod_tag" | grep -q skypilot.co/idle_minutes_to_autostop',
852+
# Get names of the pods containing cluster name.
853+
f'pod_2=$(kubectl get pods -o name | grep {name} | sed -n 2p) && '
853854
# Describe the second pod and check for annotations.
854-
'kubectl describe pod $pod_2 | grep -q skypilot.co/autodown',
855-
'kubectl describe pod $pod_2 | grep -q skypilot.co/idle_minutes_to_autostop'
855+
'pod_tag=$(kubectl describe $pod_2); echo "$pod_tag"; echo "$pod_tag" | grep -q skypilot.co/autodown && '
856+
'pod_tag=$(kubectl describe $pod_2); echo "$pod_tag"; echo "$pod_tag" | grep -q skypilot.co/idle_minutes_to_autostop'
856857
],
857858
f'sky down -y {name}',
858859
)
@@ -870,22 +871,24 @@ def test_add_and_remove_pod_annotations_with_autostop():
870871
# Set autodown on the cluster with 'autostop' command.
871872
f'sky autostop -y {name} -i 20 --down',
872873
# Get names of the pods containing cluster name.
873-
f'pod_1=$(kubectl get pods -o name | grep {name} | sed -n 1p)',
874-
f'pod_2=$(kubectl get pods -o name | grep {name} | sed -n 2p)',
874+
f'pod_1=$(kubectl get pods -o name | grep {name} | sed -n 1p) && '
875875
# Describe the first pod and check for annotations.
876-
'kubectl describe pod $pod_1 | grep -q skypilot.co/autodown',
877-
'kubectl describe pod $pod_1 | grep -q skypilot.co/idle_minutes_to_autostop',
876+
'pod_tag=$(kubectl describe $pod_1); echo "$pod_tag"; echo "$pod_tag" | grep -q skypilot.co/autodown && '
877+
'pod_tag=$(kubectl describe $pod_1); echo "$pod_tag"; echo "$pod_tag" | grep -q skypilot.co/idle_minutes_to_autostop',
878878
# Describe the second pod and check for annotations.
879-
'kubectl describe pod $pod_2 | grep -q skypilot.co/autodown',
880-
'kubectl describe pod $pod_2 | grep -q skypilot.co/idle_minutes_to_autostop',
879+
f'pod_2=$(kubectl get pods -o name | grep {name} | sed -n 2p) && '
880+
'pod_tag=$(kubectl describe $pod_2); echo "$pod_tag"; echo "$pod_tag" | grep -q skypilot.co/autodown && '
881+
'pod_tag=$(kubectl describe $pod_2); echo "$pod_tag"; echo "$pod_tag" | grep -q skypilot.co/idle_minutes_to_autostop',
881882
# Cancel the set autodown to remove the annotations from the pods.
882883
f'sky autostop -y {name} --cancel',
883884
# Describe the first pod and check if annotations are removed.
884-
'! kubectl describe pod $pod_1 | grep -q skypilot.co/autodown',
885-
'! kubectl describe pod $pod_1 | grep -q skypilot.co/idle_minutes_to_autostop',
885+
f'pod_1=$(kubectl get pods -o name | grep {name} | sed -n 1p) && '
886+
'pod_tag=$(kubectl describe $pod_1); echo "$pod_tag"; ! echo "$pod_tag" | grep -q skypilot.co/autodown && '
887+
'pod_tag=$(kubectl describe $pod_1); echo "$pod_tag"; ! echo "$pod_tag" | grep -q skypilot.co/idle_minutes_to_autostop',
886888
# Describe the second pod and check if annotations are removed.
887-
'! kubectl describe pod $pod_2 | grep -q skypilot.co/autodown',
888-
'! kubectl describe pod $pod_2 | grep -q skypilot.co/idle_minutes_to_autostop',
889+
f'pod_2=$(kubectl get pods -o name | grep {name} | sed -n 2p) && '
890+
'pod_tag=$(kubectl describe $pod_2); echo "$pod_tag"; ! echo "$pod_tag" | grep -q skypilot.co/autodown && '
891+
'pod_tag=$(kubectl describe $pod_2); echo "$pod_tag"; ! echo "$pod_tag" | grep -q skypilot.co/idle_minutes_to_autostop',
889892
],
890893
f'sky down -y {name}',
891894
)

0 commit comments

Comments
 (0)