jason810496 commented on code in PR #76314:
URL: https://github.com/apache/airflow/pull/76314#discussion_r4450061414
##########
task-sdk/tests/task_sdk/coordinators/java/test_coordinator.py:
##########
@@ -406,7 +426,11 @@ def test_classpath_flag_and_value_present(self, jars_dir,
java_task_handlers, mo
assert "-classpath" in cmd
cp_idx = cmd.index("-classpath")
classpath = cmd[cp_idx + 1]
- assert jars_dir.joinpath("app.jar").as_posix() in classpath
+ assert classpath == "./app.jar"
+
+ def test_runs_in_the_bundle_directory(self, jars_dir, java_task_handlers,
mock_client):
+ self._captured_popen_cmd(java_task_handlers, mock_client)
+ assert self.popen_kwargs["cwd"] == jars_dir
Review Comment:
The only colon-path test calls `_calculate_classpath` directly. This covers
the task path end to end, checking that the classpath and `cwd` agree when the
bundle version directory holds `os.pathsep`.
```suggestion
def test_runs_in_the_bundle_directory(self, jars_dir,
java_task_handlers, mock_client):
self._captured_popen_cmd(java_task_handlers, mock_client)
assert self.popen_kwargs["cwd"] == jars_dir
@pytest.fixture
def timestamped_task_handlers(self, tmp_path):
root = tmp_path / f"2026-11-02T15{os.pathsep}52{os.pathsep}20Z"
root.mkdir()
_make_jar(root / "app.jar", main_class="com.example.TaskRunner",
schema_version="2026-06-16")
_make_jar(root / "libs" / "dep.jar", main_class=None)
bundle = {
"name": "java-task-handlers",
"classpath":
"airflow.dag_processing.bundles.local.LocalDagBundle",
"kwargs": {"path": str(root)},
}
with conf_vars({("dag_processor", "dag_bundle_config_list"):
json.dumps([bundle])}):
yield bundle["name"], root
def test_bundle_path_with_path_separator(self,
timestamped_task_handlers, mock_client):
bundle_name, root = timestamped_task_handlers
cmd = self._captured_popen_cmd(bundle_name, mock_client)
assert self.popen_kwargs["cwd"] == root
classpath = cmd[cmd.index("-classpath") + 1]
assert classpath.split(os.pathsep) == ["./app.jar", "./libs/dep.jar"]
```
##########
task-sdk/tests/task_sdk/coordinators/java/test_coordinator.py:
##########
@@ -683,8 +707,11 @@ def test_rejects_a_jar_deleted_after_discovery(self,
tmp_path):
@patch("airflow.sdk.coordinators._subprocess._set_close_on_exec_above_stderr",
autospec=True)
Review Comment:
Same check for Dag parsing: `chdir` target and classpath together, with a
bundle path holding `os.pathsep`.
```suggestion
@patch("airflow.sdk.coordinators._subprocess._set_close_on_exec_above_stderr",
autospec=True)
@patch("airflow.sdk.coordinators._subprocess.signal.signal",
autospec=True)
@patch("airflow.sdk.coordinators._subprocess.os.chdir", autospec=True)
@patch("airflow.sdk.coordinators._subprocess.os.execvpe", autospec=True,
side_effect=OSError("exec"))
def test_parse_dag_with_path_separator_in_bundle_path(
self, mock_execvpe, mock_chdir, mock_signal, mock_close_on_exec,
tmp_path
):
root = tmp_path / f"2026-11-02T15{os.pathsep}52{os.pathsep}20Z"
root.mkdir()
jar = _make_jar(root / "app.jar", main_class="com.example.Dags",
schema_version="2026-10-30")
_make_jar(root / "libs" / "dep.jar", main_class=None)
with pytest.raises(OSError, match="exec"):
JavaCoordinator().parse_dag(
path=jar,
bundle_path=root,
comm_address=("127.0.0.1", 1001),
logs_address=("127.0.0.1", 1002),
report_schema_version=lambda _: None,
)
mock_chdir.assert_called_once_with(root)
argv = mock_execvpe.call_args.args[1]
assert argv[argv.index("-classpath") + 1].split(os.pathsep) ==
["./app.jar", "./libs/dep.jar"]
@patch("airflow.sdk.coordinators._subprocess._set_close_on_exec_above_stderr",
autospec=True)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]