Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$END will not be validated as a app #4392

Merged
merged 2 commits into from
Feb 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,17 @@ public void saveTaskDefinition(TaskDefinition taskDefinition) {
if (taskNode.isComposed()) {
// Create the child task definitions needed for the composed task
taskNode.getTaskApps().forEach(task -> {
String labelPrefix = StringUtils.hasText(task.getLabel()) ? task.getLabel() + ":" : "";
// Add arguments to child task definitions
String generatedTaskDSL = labelPrefix + task.getName() + task.getArguments().entrySet().stream()
.map(argument -> String.format(" --%s=%s", argument.getKey(),
DefinitionUtils.autoQuotes(argument.getValue())))
.collect(Collectors.joining());
TaskDefinition composedTaskElementDefinition = new TaskDefinition(task.getExecutableDSLName(),
generatedTaskDSL);
saveStandardTaskDefinition(composedTaskElementDefinition);
if (StringUtils.hasText(task.getName()) && !task.getName().equals("$END")) {
String labelPrefix = StringUtils.hasText(task.getLabel()) ? task.getLabel() + ":" : "";
// Add arguments to child task definitions
String generatedTaskDSL = labelPrefix + task.getName() + task.getArguments().entrySet().stream()
.map(argument -> String.format(" --%s=%s", argument.getKey(),
DefinitionUtils.autoQuotes(argument.getValue())))
.collect(Collectors.joining());
TaskDefinition composedTaskElementDefinition = new TaskDefinition(task.getExecutableDSLName(),
generatedTaskDSL);
saveStandardTaskDefinition(composedTaskElementDefinition);
}
});
taskDefinitionRepository.save(taskDefinition);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,28 @@ public void executeComposedTaskwithUserCTRName() {
assertNull(request.getDefinition().getProperties().get("globalstreamkey"));
}

@Test
@DirtiesContext
public void executeComposedTaskWithEnd() {
String dsl = "timestamp '*'->t1: timestamp 'FOO'->$END";
initializeSuccessfulRegistry(appRegistry);

taskSaveService.saveTaskDefinition(new TaskDefinition("transitionTask", dsl));
when(taskLauncher.launch(any())).thenReturn("0");

Map<String, String> properties = new HashMap<>();
properties.put("app.t1.timestamp.format", "YYYY");
assertEquals(1L, this.taskExecutionService.executeTask("transitionTask", properties, new LinkedList<>()));
ArgumentCaptor<AppDeploymentRequest> argumentCaptor = ArgumentCaptor.forClass(AppDeploymentRequest.class);
verify(this.taskLauncher, atLeast(1)).launch(argumentCaptor.capture());

AppDeploymentRequest request = argumentCaptor.getValue();
assertEquals("transitionTask", request.getDefinition().getProperties().get("spring.cloud.task.name"));
assertEquals("YYYY",
request.getDefinition().getProperties().get("composed-task-app-properties.app.t1.timestamp.format"));

}

@Test
@DirtiesContext
public void executeComposedTaskWithLabels() {
Expand Down