33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
# coding=utf-8
|
|
import pytest
|
|
|
|
from spark_executor.core.log_parser import parse_spark_submit_output
|
|
|
|
|
|
def test_parses_submitted_application_line():
|
|
stderr = "Warning: ignoring...\nSubmitted application application_17400000001\n"
|
|
app_id, url = parse_spark_submit_output(stderr)
|
|
assert app_id == "application_17400000001"
|
|
assert url is None
|
|
|
|
|
|
def test_parses_tracking_url_line():
|
|
stderr = "tracking URL: http://rm:8088/proxy/application_17400000002/\n"
|
|
app_id, url = parse_spark_submit_output(stderr)
|
|
assert app_id == "application_17400000002"
|
|
assert url == "http://rm:8088/proxy/application_17400000002/"
|
|
|
|
|
|
def test_prefers_submitted_application_line_over_tracking_url():
|
|
stderr = (
|
|
"tracking URL: http://rm:8088/proxy/application_9999/\n"
|
|
"Submitted application application_1234\n"
|
|
)
|
|
app_id, _ = parse_spark_submit_output(stderr)
|
|
assert app_id == "application_1234"
|
|
|
|
|
|
def test_raises_when_no_application_id_found():
|
|
with pytest.raises(ValueError, match="application_id"):
|
|
parse_spark_submit_output("some unrelated output\n")
|