diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-jupyter/src/main/java/org/apache/dolphinscheduler/plugin/task/jupyter/JupyterTask.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-jupyter/src/main/java/org/apache/dolphinscheduler/plugin/task/jupyter/JupyterTask.java index 3dba1f760b86..a1b9ec430f34 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-jupyter/src/main/java/org/apache/dolphinscheduler/plugin/task/jupyter/JupyterTask.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-jupyter/src/main/java/org/apache/dolphinscheduler/plugin/task/jupyter/JupyterTask.java @@ -30,6 +30,7 @@ import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils; import org.apache.dolphinscheduler.spi.utils.DateUtils; import org.apache.dolphinscheduler.spi.utils.JSONUtils; +import org.apache.dolphinscheduler.spi.utils.PropertyUtils; import org.apache.dolphinscheduler.spi.utils.StringUtils; import java.io.IOException; @@ -48,8 +49,6 @@ public class JupyterTask extends AbstractRemoteTask { private ShellCommandExecutor shellCommandExecutor; - private JupyterPropertyReader jupyterPropertyReader; - public JupyterTask(TaskExecutionContext taskExecutionContext) { super(taskExecutionContext); this.taskExecutionContext = taskExecutionContext; @@ -58,10 +57,6 @@ public JupyterTask(TaskExecutionContext taskExecutionContext) { logger); } - protected JupyterPropertyReader proxyJupyterPropertyReaderCreator() { - return new JupyterPropertyReader(); - } - @Override public List getApplicationIds() throws TaskException { return Collections.emptyList(); @@ -69,8 +64,6 @@ public List getApplicationIds() throws TaskException { @Override public void init() { - this.jupyterPropertyReader = proxyJupyterPropertyReaderCreator(); - logger.info("jupyter task params {}", taskExecutionContext.getTaskParams()); jupyterParameters = JSONUtils.parseObject(taskExecutionContext.getTaskParams(), JupyterParameters.class); @@ -121,7 +114,7 @@ public void trackApplicationStatus() throws TaskException { protected String buildCommand() throws IOException { List args = new ArrayList<>(); - final String condaPath = jupyterPropertyReader.readProperty(TaskConstants.CONDA_PATH); + final String condaPath = readCondaPath(); final String timestamp = DateUtils.getTimestampString(); String condaEnvName = jupyterParameters.getCondaEnvName(); if (condaEnvName.endsWith(JupyterConstants.TXT_SUFFIX)) { @@ -164,6 +157,10 @@ protected String buildCommand() throws IOException { return command; } + protected String readCondaPath() { + return PropertyUtils.getString(TaskConstants.CONDA_PATH); + } + protected List populateJupyterParameterization() throws IOException { List args = new ArrayList<>(); String parameters = jupyterParameters.getParameters(); diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-jupyter/src/test/java/org/apache/dolphinscheduler/plugin/task/jupyter/JupyterTaskTest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-jupyter/src/test/java/org/apache/dolphinscheduler/plugin/task/jupyter/JupyterTaskTest.java index 5b08b72d07d2..1fe03b96407f 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-jupyter/src/test/java/org/apache/dolphinscheduler/plugin/task/jupyter/JupyterTaskTest.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-jupyter/src/test/java/org/apache/dolphinscheduler/plugin/task/jupyter/JupyterTaskTest.java @@ -17,7 +17,6 @@ package org.apache.dolphinscheduler.plugin.task.jupyter; -import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; @@ -118,10 +117,8 @@ public void jupyterTaskUsePipRequirements() throws Exception { private JupyterTask prepareJupyterTaskForTest(final String jupyterTaskParameters) { TaskExecutionContext taskExecutionContext = Mockito.mock(TaskExecutionContext.class); when(taskExecutionContext.getTaskParams()).thenReturn(jupyterTaskParameters); - JupyterPropertyReader mockedJupyterPropertyReader = Mockito.mock(JupyterPropertyReader.class); JupyterTask jupyterTask = spy(new JupyterTask(taskExecutionContext)); - doReturn(mockedJupyterPropertyReader).when(jupyterTask).proxyJupyterPropertyReaderCreator(); - doReturn("/opt/anaconda3/etc/profile.d/conda.sh").when(mockedJupyterPropertyReader).readProperty(any()); + doReturn("/opt/anaconda3/etc/profile.d/conda.sh").when(jupyterTask).readCondaPath(); return jupyterTask; } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-zeppelin/src/test/java/org/apache/dolphinscheduler/plugin/task/zeppelin/ZeppelinTaskTest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-zeppelin/src/test/java/org/apache/dolphinscheduler/plugin/task/zeppelin/ZeppelinTaskTest.java index 42d270051fd6..b33b4d43ff06 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-zeppelin/src/test/java/org/apache/dolphinscheduler/plugin/task/zeppelin/ZeppelinTaskTest.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-zeppelin/src/test/java/org/apache/dolphinscheduler/plugin/task/zeppelin/ZeppelinTaskTest.java @@ -26,8 +26,6 @@ import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; -import com.fasterxml.jackson.databind.ObjectMapper; - import org.apache.dolphinscheduler.plugin.task.api.TaskCallBack; import org.apache.dolphinscheduler.plugin.task.api.TaskException; import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; @@ -123,8 +121,8 @@ public void testHandleWithParagraphExecutionError() throws Exception { @Test(expected = TaskException.class) public void testHandleWithParagraphExecutionException() throws Exception { - when(this.zClient.executeParagraph(any(), any(), any(Map.class))). - thenThrow(new TaskException("Something wrong happens from zeppelin side")); + when(this.zClient.executeParagraph(any(), any(), any(Map.class))) + .thenThrow(new TaskException("Something wrong happens from zeppelin side")); this.zeppelinTask.handle(taskCallBack); Mockito.verify(this.zClient).executeParagraph(MOCK_NOTE_ID, @@ -148,7 +146,6 @@ public void testHandleWithNoteExecutionSuccess() throws Exception { doReturn(this.zClient).when(this.zeppelinTask).getZeppelinClient(); when(this.zClient.executeNote(any(), any(Map.class))).thenReturn(this.noteResult); this.zeppelinTask.init(); - when(this.paragraphResult.getStatus()).thenReturn(Status.FINISHED); this.zeppelinTask.handle(taskCallBack); Mockito.verify(this.zClient).executeNote(MOCK_NOTE_ID, diff --git a/pom.xml b/pom.xml index 8f8dee13fb1c..0efadbdb7fa5 100644 --- a/pom.xml +++ b/pom.xml @@ -65,7 +65,6 @@ 2.6.1 1.8 4.13.1 - 3.9.0 3.1.12 3.3 3.3.0