Restore defaults for queue/executor_memory/executor_cores/num_executors in prepare_submit_job, but require the caller to explicitly confirm them. If any defaulted field is omitted, the route returns HTTP 400 listing the defaults and asks the caller to resubmit with explicit values. app_name remains required (no meaningful default). extra_args remains optional. Tests cover rejection of unconfirmed defaults and acceptance of explicitly confirmed defaults.
36 lines
1.0 KiB
Python
36 lines
1.0 KiB
Python
# coding=utf-8
|
|
import pytest
|
|
|
|
from spark_executor.tools.requests import PrepareSubmitJobRequest
|
|
|
|
|
|
def test_prepare_submit_job_request_requires_connection_script_path_and_app_name():
|
|
with pytest.raises(ValueError):
|
|
PrepareSubmitJobRequest(connection="prod", script_path="/tmp/x.py")
|
|
|
|
|
|
def test_prepare_submit_job_request_restores_defaults_for_queue_and_resources():
|
|
req = PrepareSubmitJobRequest(
|
|
connection="prod",
|
|
script_path="/tmp/x.py",
|
|
app_name="test-app",
|
|
)
|
|
assert req.queue == "default"
|
|
assert req.executor_memory == "4G"
|
|
assert req.executor_cores == 2
|
|
assert req.num_executors == 2
|
|
|
|
|
|
def test_prepare_submit_job_request_accepts_extra_args():
|
|
req = PrepareSubmitJobRequest(
|
|
connection="prod",
|
|
script_path="/tmp/x.py",
|
|
queue="default",
|
|
executor_memory="4G",
|
|
executor_cores=2,
|
|
num_executors=2,
|
|
app_name="test-app",
|
|
extra_args={"jars": "hdfs:///lib/foo.jar"},
|
|
)
|
|
assert req.extra_args == {"jars": "hdfs:///lib/foo.jar"}
|