Skip to content

Commit 4f693a5

Browse files
det101luxlcaishunfengSbloodySruanwenjun
authored
[Fix-17704][HttpTask] The output parameters of an HTTP task cannot be referenced in downstream tasks. (#17716)
* fix #17637 * Because workflow lineage only retains the current version, deleting historical versions in the workflow does not invoke lineage deletion. Therefore, logic for deleting lineages should be added when deleting workflows. * Optimize workflow deletion logic to ensure compatibility with historical library data. * spotless * fix #17637 * Because workflow lineage only retains the current version, deleting historical versions in the workflow does not invoke lineage deletion. Therefore, logic for deleting lineages should be added when deleting workflows. * Optimize workflow deletion logic to ensure compatibility with historical library data. * spotless * add ut test * fix #17638 * Simplify the logic of WorkflowDefinitionService.saveWorkflowLineage(). * fix #17704 * Update dolphinscheduler-task-plugin/dolphinscheduler-task-http/src/main/java/org/apache/dolphinscheduler/plugin/task/http/HttpTask.java Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: luxl <[email protected]> Co-authored-by: caishunfeng <[email protected]> Co-authored-by: xiangzihao <[email protected]> Co-authored-by: Wenjun Ruan <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Gallardot <[email protected]>
1 parent 0f7a844 commit 4f693a5

File tree

2 files changed

+35
-0
lines changed
  • dolphinscheduler-task-plugin/dolphinscheduler-task-http/src

2 files changed

+35
-0
lines changed

dolphinscheduler-task-plugin/dolphinscheduler-task-http/src/main/java/org/apache/dolphinscheduler/plugin/task/http/HttpTask.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ public void handle(TaskCallBack taskCallBack) throws TaskException {
7373

7474
OkHttpResponse httpResponse = sendRequest();
7575

76+
taskExecutionContext.setVarPool(httpParameters.getVarPool());
77+
7678
validateResponse(httpResponse.getBody(), httpResponse.getStatusCode());
7779
}
7880

dolphinscheduler-task-plugin/dolphinscheduler-task-http/src/test/java/org/apache/dolphinscheduler/plugin/task/http/HttpTaskTest.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,39 @@ public void testAddDefaultOutput() throws Exception {
181181
Assertions.assertEquals(response, property.getValue());
182182
}
183183

184+
@Test
185+
public void testHandleSetsVarPoolToTaskExecutionContext() throws Exception {
186+
String responseBody = "{\"status\": \"success\", \"data\": \"test\"}";
187+
String taskName = "testHttpTask";
188+
189+
TaskExecutionContext taskExecutionContext = Mockito.mock(TaskExecutionContext.class);
190+
Mockito.when(taskExecutionContext.getTaskName()).thenReturn(taskName);
191+
192+
String url = withMockWebServer(DEFAULT_MOCK_PATH, HttpStatus.SC_OK, responseBody);
193+
String paramData = generateHttpParameters(url, HttpRequestMethod.GET, "",
194+
new ArrayList<>(), HttpCheckCondition.STATUS_CODE_DEFAULT, "");
195+
Mockito.when(taskExecutionContext.getTaskParams()).thenReturn(paramData);
196+
197+
HttpTask httpTask = new HttpTask(taskExecutionContext);
198+
httpTask.init();
199+
httpTask.handle(null);
200+
201+
Mockito.verify(taskExecutionContext, Mockito.times(1)).setVarPool(Mockito.anyList());
202+
203+
Mockito.verify(taskExecutionContext).setVarPool(Mockito.argThat(varPool -> {
204+
if (varPool == null || varPool.isEmpty()) {
205+
return false;
206+
}
207+
Property property = varPool.get(0);
208+
return property.getProp().equals(taskName + ".response")
209+
&& property.getDirect() == Direct.OUT
210+
&& property.getType() == DataType.VARCHAR
211+
&& property.getValue().contains("status");
212+
}));
213+
214+
Assertions.assertEquals(EXIT_CODE_SUCCESS, httpTask.getExitStatusCode());
215+
}
216+
184217
private String withMockWebServer(String path, int actualResponseCode,
185218
String actualResponseBody) throws IOException {
186219
MockWebServer server = new MockWebServer();

0 commit comments

Comments
 (0)