Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit f4ce350

Browse files
committed
Scheduled Task does not recognize multiple profiles
Resolves #3192
1 parent aa39aea commit f4ce350

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/controller/TaskSchedulerController.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,10 @@ public PagedResources<ScheduleInfoResource> filteredList(@PathVariable String ta
136136
public void save(@RequestParam("scheduleName") String scheduleName,
137137
@RequestParam("taskDefinitionName") String taskDefinitionName,
138138
@RequestParam String properties,
139-
@RequestParam(required = false) List<String> arguments) {
139+
@RequestParam(required = false) String arguments) {
140140
Map<String, String> propertiesToUse = DeploymentPropertiesUtils.parse(properties);
141-
schedulerService.schedule(scheduleName, taskDefinitionName, propertiesToUse, arguments);
141+
List<String> argumentsToUse = DeploymentPropertiesUtils.parseParamList(arguments, " ");
142+
schedulerService.schedule(scheduleName, taskDefinitionName, propertiesToUse, argumentsToUse);
142143
}
143144

144145
/**

spring-cloud-dataflow-server-core/src/test/java/org/springframework/cloud/dataflow/server/controller/TaskSchedulerControllerTests.java

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,35 @@ public void testCreateSchedule() throws Exception {
191191

192192
@Test
193193
public void testCreateScheduleWithSensitiveFields() throws Exception {
194-
AppRegistration registration = this.registry.save("testApp", ApplicationType.task,
195-
"1.0.0", new URI("file:src/test/resources/apps/foo-task"), null);
194+
String auditData = createScheduleWithArguments("argument1=foo password=secret");
195+
196+
assertEquals(
197+
"{\"commandlineArguments\":[\"argument1=foo\",\"password=******\"],\"taskDefinitionName\":\"testDefinition\","
198+
+ "\"taskDefinitionProperties\":{\"prop1\":\"foo\",\"spring.datasource.username\":null,\"prop2.secret\":\"******\",\"spring.datasource.url\":null,\"spring.datasource.driverClassName\":null,\"spring.cloud.task.name\":\"testDefinition\"},"
199+
+ "\"deploymentProperties\":{\"spring.cloud.deployer.prop1.secret\":\"******\",\"spring.cloud.deployer.prop2.password\":\"******\"}}",
200+
auditData);
201+
}
202+
203+
@Test
204+
public void testCreateScheduleCommaDelimitedArgs() throws Exception {
205+
String auditData = createScheduleWithArguments("argument1=foo spring.profiles.active=k8s,master argument3=bar");
206+
207+
assertEquals(
208+
"{\"commandlineArguments\":[\"argument1=foo\",\"spring.profiles.active=k8s,master\",\"argument3=bar\"],\"taskDefinitionName\":\"testDefinition\","
209+
+ "\"taskDefinitionProperties\":{\"prop1\":\"foo\",\"spring.datasource.username\":null,\"prop2.secret\":\"******\",\"spring.datasource.url\":null,\"spring.datasource.driverClassName\":null,\"spring.cloud.task.name\":\"testDefinition\"},"
210+
+ "\"deploymentProperties\":{\"spring.cloud.deployer.prop1.secret\":\"******\",\"spring.cloud.deployer.prop2.password\":\"******\"}}",
211+
auditData);
212+
}
213+
214+
private String createScheduleWithArguments(String arguments) throws Exception {
215+
this.registry.save("testApp", ApplicationType.task, "1.0.0", new URI("file:src/test/resources/apps/foo-task"), null);
196216

197217
repository.save(new TaskDefinition("testDefinition", "testApp"));
198218
mockMvc.perform(post("/tasks/schedules/").param("taskDefinitionName", "testDefinition")
199219
.param("scheduleName", "mySchedule")
200220
.param("properties",
201221
"scheduler.cron.expression=* * * * *,app.testApp.prop1=foo,app.testApp.prop2.secret=kenny,deployer.*.prop1.secret=cartman,deployer.*.prop2.password=kyle")
202-
.param("arguments", "argument1=foo,password=secret")
222+
.param("arguments", arguments)
203223
.accept(MediaType.APPLICATION_JSON)).andDo(print()).andExpect(status().isCreated());
204224
assertEquals(1, simpleTestScheduler.list().size());
205225
ScheduleInfo scheduleInfo = simpleTestScheduler.list().get(0);
@@ -216,12 +236,7 @@ public void testCreateScheduleWithSensitiveFields() throws Exception {
216236
assertEquals(AuditActionType.CREATE, auditRecord.getAuditAction());
217237
assertEquals("mySchedule", auditRecord.getCorrelationId());
218238

219-
assertEquals(
220-
"{\"commandlineArguments\":[\"argument1=foo\",\"password=******\"],\"taskDefinitionName\":\"testDefinition\","
221-
+ "\"taskDefinitionProperties\":{\"prop1\":\"foo\",\"spring.datasource.username\":null,\"prop2.secret\":\"******\",\"spring.datasource.url\":null,\"spring.datasource.driverClassName\":null,\"spring.cloud.task.name\":\"testDefinition\"},"
222-
+ "\"deploymentProperties\":{\"spring.cloud.deployer.prop1.secret\":\"******\",\"spring.cloud.deployer.prop2.password\":\"******\"}}",
223-
auditRecord.getAuditData());
224-
239+
return auditRecord.getAuditData();
225240
}
226241

227242
@Test

0 commit comments

Comments
 (0)