Skip to content

Commit

Permalink
[DPE-3552] Fix handling of extraJavaOptions (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
welpaolo authored Jul 11, 2024
1 parent 29ac72b commit 1525ce5
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ignore_missing_imports = true

[tool.poetry]
name = "spark8t"
version = "0.0.9"
version = "0.0.10"
description = "This project provides some utilities function and CLI commands to run Spark on K8s."
authors = [
"Canonical Data Platform <[email protected]>"
Expand Down
2 changes: 1 addition & 1 deletion spark8t/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def options(self) -> Dict[str, Dict]:
@staticmethod
def _construct_options_string(options: Dict) -> str:
output = " ".join(f"-D{k}={v}" for k, v in options.items())
return f'"{output}"'
return f"{output}"

@classmethod
def empty(cls) -> "PropertyFile":
Expand Down
2 changes: 1 addition & 1 deletion spark8t/literals.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MANAGED_BY_LABELNAME = "app.kubernetes.io/managed-by"
PRIMARY_LABELNAME = "app.kubernetes.io/spark8t-primary"
SPARK8S_LABEL = "spark8t"
HUB_LABEL = "integration-hub-conf"
HUB_LABEL = "integrator-hub-conf" # TODO revert this label to `integration-hub-conf``
2 changes: 1 addition & 1 deletion spark8t/resources/templates/role_yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ rules:
resources:
- secrets
resourceNames:
- integration-hub-conf-{{username}}
- integrator-hub-conf-{{username}}
verbs:
- get
2 changes: 1 addition & 1 deletion tests/integration/test_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def test_merge_configurations():
expected_merged_props = PropertyFile(
{
k1: v13,
k2: f'"-Dscala.shell.histfile={v23}"',
k2: f"-Dscala.shell.histfile={v23}",
"key1": "value1",
"key2": "value2",
"key3": "value3",
Expand Down
14 changes: 7 additions & 7 deletions tests/unittest/test_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def test_property_file_parse_options():

scala_hist_file = str(uuid.uuid4())

props_with_option = f'"-Dscala.shell.histfile={scala_hist_file} -Da=A -Db=B -Dc=C"'
props_with_option = f"-Dscala.shell.histfile={scala_hist_file} -Da=A -Db=B -Dc=C"

conf = PropertyFile(
props={
Expand All @@ -213,7 +213,7 @@ def test_property_file_construct_options_string():
scala_hist_file = str(uuid.uuid4())

expected_props_with_option = (
f'"-Dscala.shell.histfile={scala_hist_file} -Da=A -Db=B -Dc=C"'
f"-Dscala.shell.histfile={scala_hist_file} -Da=A -Db=B -Dc=C"
)

assert (
Expand All @@ -240,7 +240,7 @@ def test_property_file_io():
app_name = str(uuid.uuid4())
test_config_w = dict()
contents_java_options = (
f'-Dscala.shell.histfile = "{scala_hist_file} -Da=A -Db=B -Dc=C"'
f"-Dscala.shell.histfile={scala_hist_file} -Da=A -Db=B -Dc=C"
)

test_config_w["spark.kubernetes.authenticate.driver.serviceAccountName"] = name
Expand Down Expand Up @@ -285,11 +285,11 @@ def test_merge_property_file_options(tmp_path, key):
"""
filename_1 = os.path.join(tmp_path, "test-1.properties")
with open(filename_1, "w") as fid:
fid.write(f'{key}="-Da=A -Db=B"')
fid.write(f"{key}=-Da=A -Db=B")

filename_2 = os.path.join(tmp_path, "test-2.properties")
with open(filename_2, "w") as fid:
fid.write(f'{key}="-Da=D -Dc=C"')
fid.write(f"{key}=-Da=D -Dc=C")

conf_1 = PropertyFile.read(filename_1)
conf_2 = PropertyFile.read(filename_2)
Expand All @@ -298,15 +298,15 @@ def test_merge_property_file_options(tmp_path, key):

assert conf_1.options[key]["a"] == "A"

assert conf_1.props[key] == '"-Da=A -Db=B"'
assert conf_1.props[key] == "-Da=A -Db=B"

merged = conf_1 + conf_2

assert len(merged.options[key]) == 3

assert merged.options[key]["a"] == "D"

assert merged.props[key] == '"-Da=D -Db=B -Dc=C"'
assert merged.props[key] == "-Da=D -Db=B -Dc=C"


def test_property_file_log(caplog):
Expand Down

0 comments on commit 1525ce5

Please sign in to comment.