|
4 | 4 | import pytest |
5 | 5 |
|
6 | 6 | from paasta_tools import spark_tools |
| 7 | +from paasta_tools.spark_tools import auto_add_timeout_for_spark_job |
7 | 8 |
|
8 | 9 |
|
9 | 10 | def test_get_webui_url(): |
@@ -133,3 +134,42 @@ def test_get_volumes_from_spark_k8s_configs(mock_sys, spark_conf, expected): |
133 | 134 | def test_get_spark_driver_monitoring_annotations(spark_config, expected): |
134 | 135 | result = spark_tools.get_spark_driver_monitoring_annotations(spark_config) |
135 | 136 | 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