Skip to content

Commit 1e1f5a5

Browse files
committed
Added unit tests for auto_add_timeout_for_spark_job function
1 parent 779c9eb commit 1e1f5a5

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

tests/test_spark_tools.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import pytest
55

66
from paasta_tools import spark_tools
7+
from paasta_tools.spark_tools import auto_add_timeout_for_spark_job
78

89

910
def test_get_webui_url():
@@ -133,3 +134,42 @@ def test_get_volumes_from_spark_k8s_configs(mock_sys, spark_conf, expected):
133134
def test_get_spark_driver_monitoring_annotations(spark_config, expected):
134135
result = spark_tools.get_spark_driver_monitoring_annotations(spark_config)
135136
assert result == expected
137+
138+
139+
@pytest.mark.parametrize(
140+
argnames=[
141+
"cmd",
142+
"timeout_duration",
143+
"expected",
144+
],
145+
argvalues=[
146+
pytest.param(
147+
"spark-submit abc.py",
148+
"4h",
149+
"timeout 4h spark-submit abc.py",
150+
id="No timeout",
151+
),
152+
pytest.param(
153+
"timeout 2h spark-submit abc.py",
154+
"12h",
155+
"timeout 2h spark-submit abc.py",
156+
id="Timeout without options",
157+
),
158+
pytest.param(
159+
"timeout -v 2h spark-submit abc.py",
160+
"12h",
161+
"timeout -v 2h spark-submit abc.py",
162+
id="Timeout with options",
163+
),
164+
pytest.param(
165+
"timeout -v -s 1 2h spark-submit abc.py",
166+
"12h",
167+
"timeout -v -s 1 2h spark-submit abc.py",
168+
id="Timeout with multiple options",
169+
),
170+
],
171+
)
172+
def test_auto_add_timeout_for_spark_job(cmd, timeout_duration, expected):
173+
result = auto_add_timeout_for_spark_job(cmd, timeout_duration)
174+
175+
assert result == expected

0 commit comments

Comments
 (0)