From 17e42505869719b1ca3de0efe5d2b4705dece8ec Mon Sep 17 00:00:00 2001 From: Michael Minella Date: Mon, 22 Aug 2016 12:55:31 -0500 Subject: [PATCH] Checks for invalid ExecutionId in the TaskLifeCycleListener resolves #115 * Fixes bug where if the user set the environment variable and commandline args a unique constraint would fire. * Updated docs * Removed deprecation * Fixed version number for integration test. Added integration tests for externally generated task executions Add externalExecutionId resolves #80 --- .../TaskBatchExecutionListenerTests.java | 2 +- .../SimpleTaskConfiguration.java | 7 +- .../task/configuration/TaskProperties.java | 69 +++++++++++++++++++ .../task/listener/TaskLifecycleListener.java | 32 ++++----- .../cloud/task/repository/TaskExecution.java | 19 ++++- .../cloud/task/repository/TaskRepository.java | 7 +- .../repository/dao/JdbcTaskExecutionDao.java | 30 ++++---- .../repository/dao/MapTaskExecutionDao.java | 8 ++- .../task/repository/dao/TaskExecutionDao.java | 6 +- .../support/SimpleTaskRepository.java | 13 ++-- .../cloud/task/migration/migration-h2.sql | 1 + .../cloud/task/migration/migration-hsqldb.sql | 1 + .../cloud/task/migration/migration-mysql.sql | 2 + .../cloud/task/migration/migration-oracle.sql | 2 + .../task/migration/migration-postgresql.sql | 1 + .../task/migration/migration-sqlserver.sql | 1 + .../springframework/cloud/task/schema-h2.sql | 3 +- .../cloud/task/schema-hsqldb.sql | 3 +- .../cloud/task/schema-mysql.sql | 7 +- .../cloud/task/schema-oracle10g.sql | 3 +- .../cloud/task/schema-postgresql.sql | 3 +- .../cloud/task/schema-sqlserver.sql | 3 +- .../listener/TaskExecutionListenerTests.java | 13 ++-- .../listener/TaskLifecycleListenerTests.java | 35 ++++++++-- .../dao/JdbcTaskExecutionDaoTests.java | 12 ++-- .../dao/MapTaskExecutionDaoTests.java | 14 ++-- .../FindAllPagingQueryProviderTests.java | 16 ++--- .../WhereClausePagingQueryProviderTests.java | 16 ++--- .../support/SimpleTaskExplorerTests.java | 8 ++- .../SimpleTaskRepositoryJdbcTests.java | 12 ++-- .../support/SimpleTaskRepositoryMapTests.java | 4 +- .../cloud/task/util/TaskExecutionCreator.java | 6 +- .../cloud/task/util/TestDBUtils.java | 3 +- .../task/util/TestDefaultConfiguration.java | 9 ++- .../cloud/task/util/TestVerifierUtils.java | 7 +- .../src/main/asciidoc/features.adoc | 35 +++++++++- .../listener/BatchExecutionEventTests.java | 2 +- .../cloud/task/listener/TaskEventTests.java | 2 +- .../listener/JobExecutionEventTests.java | 2 +- .../cloud/task/listener/TaskEventTests.java | 2 +- 40 files changed, 307 insertions(+), 114 deletions(-) create mode 100644 spring-cloud-task-core/src/main/java/org/springframework/cloud/task/configuration/TaskProperties.java diff --git a/spring-cloud-task-batch/src/test/java/org/springframework/cloud/task/batch/listener/TaskBatchExecutionListenerTests.java b/spring-cloud-task-batch/src/test/java/org/springframework/cloud/task/batch/listener/TaskBatchExecutionListenerTests.java index 5066ebf0..dd4520fa 100644 --- a/spring-cloud-task-batch/src/test/java/org/springframework/cloud/task/batch/listener/TaskBatchExecutionListenerTests.java +++ b/spring-cloud-task-batch/src/test/java/org/springframework/cloud/task/batch/listener/TaskBatchExecutionListenerTests.java @@ -61,7 +61,7 @@ import static org.junit.Assert.assertEquals; */ public class TaskBatchExecutionListenerTests { - public static final String[] ARGS = new String[] {"--spring.cloud.task.closecontext.enable=false"}; + public static final String[] ARGS = new String[] {"--spring.cloud.task.closecontext_enable=false"}; private ConfigurableApplicationContext applicationContext; diff --git a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/configuration/SimpleTaskConfiguration.java b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/configuration/SimpleTaskConfiguration.java index 9724889f..5005c6d5 100644 --- a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/configuration/SimpleTaskConfiguration.java +++ b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/configuration/SimpleTaskConfiguration.java @@ -25,6 +25,7 @@ import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.ApplicationArguments; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.cloud.task.listener.TaskLifecycleListener; import org.springframework.cloud.task.listener.annotation.TaskListenerExecutorFactoryBean; import org.springframework.cloud.task.repository.TaskExplorer; @@ -49,6 +50,7 @@ import org.springframework.util.CollectionUtils; */ @Configuration @EnableTransactionManagement +@EnableConfigurationProperties(TaskProperties.class) public class SimpleTaskConfiguration { protected static final Log logger = LogFactory.getLog(SimpleTaskConfiguration.class); @@ -62,6 +64,9 @@ public class SimpleTaskConfiguration { @Autowired(required = false) private ApplicationArguments applicationArguments; + @Autowired + private TaskProperties taskProperties; + private boolean initialized = false; private TaskRepository taskRepository; @@ -137,7 +142,7 @@ public class SimpleTaskConfiguration { this.taskExplorer = taskConfigurer.getTaskExplorer(); this.taskLifecycleListener = new TaskLifecycleListener(this.taskRepository, taskNameResolver(), - this.applicationArguments, taskExplorer); + this.applicationArguments, taskExplorer, taskProperties); initialized = true; } diff --git a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/configuration/TaskProperties.java b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/configuration/TaskProperties.java new file mode 100644 index 00000000..0cb99abe --- /dev/null +++ b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/configuration/TaskProperties.java @@ -0,0 +1,69 @@ +/* + * Copyright 2016 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.cloud.task.configuration; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * Properties available to configure the task. + * + * @author Glenn Renfro + */ + +@ConfigurationProperties(prefix = "spring.cloud.task") +public class TaskProperties { + + /** + * An id that can be associated with a task. + */ + private String externalExecutionId; + + /** + * An id that will be used by the task when updating the task execution. + */ + private Integer executionid; + + /** + * When set to true the context is closed at the end of the task. Else + * the context remains open. + */ + private Boolean closecontextEnable = true; + + public String getExternalExecutionId() { + return externalExecutionId; + } + + public void setExternalExecutionId(String externalExecutionId) { + this.externalExecutionId = externalExecutionId; + } + + public Integer getExecutionid() { + return executionid; + } + + public void setExecutionid(Integer executionid) { + this.executionid = executionid; + } + + public Boolean getClosecontextEnable() { + return closecontextEnable; + } + + public void setClosecontextEnable(Boolean closecontextEnable) { + this.closecontextEnable = closecontextEnable; + } +} diff --git a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/listener/TaskLifecycleListener.java b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/listener/TaskLifecycleListener.java index 850f3bdf..7a213ba3 100644 --- a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/listener/TaskLifecycleListener.java +++ b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/listener/TaskLifecycleListener.java @@ -34,6 +34,7 @@ import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ExitCodeEvent; import org.springframework.boot.context.event.ApplicationFailedEvent; import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.cloud.task.configuration.TaskProperties; import org.springframework.cloud.task.repository.TaskExecution; import org.springframework.cloud.task.repository.TaskExplorer; import org.springframework.cloud.task.repository.TaskNameResolver; @@ -80,6 +81,8 @@ public class TaskLifecycleListener implements ApplicationListener arguments, - String errorMessage) { + String errorMessage, String externalExecutionId) { Assert.notNull(arguments, "arguments must not be null"); this.executionId = executionId; @@ -90,6 +98,7 @@ public class TaskExecution { this.startTime = (startTime != null) ? (Date)startTime.clone() : null; this.endTime = (endTime != null) ? (Date)endTime.clone() : null; this.errorMessage = errorMessage; + this.externalExecutionId = externalExecutionId; } public long getExecutionId() { @@ -152,6 +161,14 @@ public class TaskExecution { this.errorMessage = errorMessage; } + public String getExternalExecutionId() { + return externalExecutionId; + } + + public void setExternalExecutionId(String externalExecutionId) { + this.externalExecutionId = externalExecutionId; + } + @Override public String toString() { return "TaskExecution{" + diff --git a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/TaskRepository.java b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/TaskRepository.java index 69b98f2f..3519ea6d 100644 --- a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/TaskRepository.java +++ b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/TaskRepository.java @@ -62,11 +62,12 @@ public interface TaskRepository { * @param taskName the name that associated with the task execution. * @param startTime the time task began. * @param arguments list of key/value pairs that configure the task. + * @param externalExecutionId id assigned to the task by the platform. * @return the initial {@link TaskExecution} */ @Transactional TaskExecution createTaskExecution(String taskName, - Date startTime,List arguments); + Date startTime,List arguments, String externalExecutionId); /** * Creates an empty TaskExecution with just an id provided. This is intended to be @@ -85,9 +86,11 @@ public interface TaskRepository { * @param taskName the name that associated with the task execution. * @param startTime the time task began. * @param arguments list of key/value pairs that configure the task. + * @param externalExecutionId id assigned to the task by the platform. + * @return */ @Transactional TaskExecution startTaskExecution(long executionid, String taskName, - Date startTime,List arguments); + Date startTime,List arguments, String externalExecutionId); } diff --git a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/dao/JdbcTaskExecutionDao.java b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/dao/JdbcTaskExecutionDao.java index d8da9585..5e0c0a27 100644 --- a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/dao/JdbcTaskExecutionDao.java +++ b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/dao/JdbcTaskExecutionDao.java @@ -58,7 +58,7 @@ public class JdbcTaskExecutionDao implements TaskExecutionDao { public static final String SELECT_CLAUSE = "TASK_EXECUTION_ID, " + "START_TIME, END_TIME, TASK_NAME, EXIT_CODE, " - + "EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED "; + + "EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED, EXTERNAL_EXECUTION_ID "; public static final String FROM_CLAUSE = "%PREFIX%EXECUTION"; @@ -68,14 +68,14 @@ public class JdbcTaskExecutionDao implements TaskExecutionDao { public static final String TASK_NAME_WHERE_CLAUSE = "where TASK_NAME = ? "; private static final String SAVE_TASK_EXECUTION = "INSERT into %PREFIX%EXECUTION" - + "(TASK_EXECUTION_ID, START_TIME, TASK_NAME, LAST_UPDATED)" - + "values (?, ?, ?, ?)"; + + "(TASK_EXECUTION_ID, START_TIME, TASK_NAME, LAST_UPDATED, EXTERNAL_EXECUTION_ID)" + + "values (?, ?, ?, ?, ?)"; private static final String CREATE_TASK_ARGUMENT = "INSERT into " + "%PREFIX%EXECUTION_PARAMS(TASK_EXECUTION_ID, TASK_PARAM ) values (?, ?)"; private static final String START_TASK_EXECUTION = "UPDATE %PREFIX%EXECUTION set " - + "START_TIME = ?, TASK_NAME = ?, LAST_UPDATED = ? where TASK_EXECUTION_ID = ?"; + + "START_TIME = ?, TASK_NAME = ?, LAST_UPDATED = ?, EXTERNAL_EXECUTION_ID = ? where TASK_EXECUTION_ID = ?"; private static final String CHECK_TASK_EXECUTION_EXISTS = "SELECT COUNT(*) FROM " + "%PREFIX%EXECUTION WHERE TASK_EXECUTION_ID = ?"; @@ -86,7 +86,7 @@ public class JdbcTaskExecutionDao implements TaskExecutionDao { private static final String GET_EXECUTION_BY_ID = "SELECT TASK_EXECUTION_ID, " + "START_TIME, END_TIME, TASK_NAME, EXIT_CODE, " - + "EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED " + + "EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED, EXTERNAL_EXECUTION_ID " + "from %PREFIX%EXECUTION where TASK_EXECUTION_ID = ?"; private static final String FIND_ARGUMENT_FROM_ID = "SELECT TASK_EXECUTION_ID, " @@ -129,31 +129,32 @@ public class JdbcTaskExecutionDao implements TaskExecutionDao { @Override public TaskExecution createTaskExecution(String taskName, - Date startTime, List arguments) { + Date startTime, List arguments, String externalExecutionId) { long nextExecutionId = getNextExecutionId(); TaskExecution taskExecution = new TaskExecution(nextExecutionId, null, taskName, - startTime, null, null, arguments, null); + startTime, null, null, arguments, null, externalExecutionId); - Object[] queryParameters = new Object[]{ nextExecutionId, startTime, taskName, new Date()}; + Object[] queryParameters = new Object[]{ nextExecutionId, startTime, taskName, new Date(), externalExecutionId}; jdbcTemplate.update( getQuery(SAVE_TASK_EXECUTION), queryParameters, - new int[]{ Types.BIGINT, Types.TIMESTAMP, Types.VARCHAR, Types.TIMESTAMP }); + new int[]{ Types.BIGINT, Types.TIMESTAMP, Types.VARCHAR, Types.TIMESTAMP, Types.VARCHAR }); insertTaskArguments(nextExecutionId, arguments); return taskExecution; } @Override - public TaskExecution startTaskExecution(long executionId, String taskName, Date startTime, List arguments) { + public TaskExecution startTaskExecution(long executionId, String taskName, Date startTime, List arguments, + String externalExecutionId) { TaskExecution taskExecution = new TaskExecution(executionId, null, taskName, - startTime, null, null, arguments, null); + startTime, null, null, arguments, null, externalExecutionId); - Object[] queryParameters = new Object[]{ startTime, taskName, new Date(), executionId}; + Object[] queryParameters = new Object[]{ startTime, taskName, new Date(), externalExecutionId, executionId}; jdbcTemplate.update( getQuery(START_TASK_EXECUTION), queryParameters, - new int[]{ Types.TIMESTAMP, Types.VARCHAR, Types.TIMESTAMP, Types.BIGINT }); + new int[]{ Types.TIMESTAMP, Types.VARCHAR, Types.TIMESTAMP, Types.VARCHAR, Types.BIGINT }); insertTaskArguments(executionId, arguments); return taskExecution; } @@ -399,7 +400,8 @@ public class JdbcTaskExecutionDao implements TaskExecutionDao { rs.getTimestamp("END_TIME"), rs.getString("EXIT_MESSAGE"), getTaskArguments(id), - rs.getString("ERROR_MESSAGE")); + rs.getString("ERROR_MESSAGE"), + rs.getString("EXTERNAL_EXECUTION_ID")); } private Integer getNullableExitCode(ResultSet rs) throws SQLException { diff --git a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/dao/MapTaskExecutionDao.java b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/dao/MapTaskExecutionDao.java index a1df276f..29b40ba4 100644 --- a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/dao/MapTaskExecutionDao.java +++ b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/dao/MapTaskExecutionDao.java @@ -53,21 +53,23 @@ public class MapTaskExecutionDao implements TaskExecutionDao { @Override public TaskExecution createTaskExecution(String taskName, - Date startTime, List arguments) { + Date startTime, List arguments, String externalExecutionId) { long taskExecutionId = getNextExecutionId(); TaskExecution taskExecution = new TaskExecution(taskExecutionId, null, taskName, - startTime, null, null, arguments, null); + startTime, null, null, arguments, null, externalExecutionId); taskExecutions.put(taskExecutionId, taskExecution); return taskExecution; } @Override - public TaskExecution startTaskExecution(long executionId, String taskName, Date startTime, List arguments) { + public TaskExecution startTaskExecution(long executionId, String taskName, Date startTime, List arguments, + String externalExecutionid) { TaskExecution taskExecution= taskExecutions.get(executionId); taskExecution.setTaskName(taskName); taskExecution.setStartTime(startTime); taskExecution.setArguments(arguments); + taskExecution.setExternalExecutionId(externalExecutionid); return taskExecution; } diff --git a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/dao/TaskExecutionDao.java b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/dao/TaskExecutionDao.java index c312ce2d..f6a57e6d 100644 --- a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/dao/TaskExecutionDao.java +++ b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/dao/TaskExecutionDao.java @@ -37,10 +37,11 @@ public interface TaskExecutionDao { * @param taskName the name that associated with the task execution. * @param startTime the time task began. * @param arguments list of key/value pairs that configure the task. + * @param externalExecutionId id assigned to the task by the platform * @return A fully qualified {@link TaskExecution} instance. */ TaskExecution createTaskExecution( String taskName, - Date startTime, List arguments); + Date startTime, List arguments, String externalExecutionId); /** * Update and existing {@link TaskExecution} to mark it as started. @@ -49,10 +50,11 @@ public interface TaskExecutionDao { * @param taskName the name that associated with the task execution. * @param startTime the time task began. * @param arguments list of key/value pairs that configure the task. + * @param externalExecutionId id assigned to the task by the platform * @since 1.1.0 */ TaskExecution startTaskExecution(long executionId, String taskName, - Date startTime, List arguments); + Date startTime, List arguments, String externalExecutionId); /** * Update and existing {@link TaskExecution} to mark it as completed. diff --git a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/support/SimpleTaskRepository.java b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/support/SimpleTaskRepository.java index dbbf5d8a..f15a9976 100644 --- a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/support/SimpleTaskRepository.java +++ b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/support/SimpleTaskRepository.java @@ -17,6 +17,7 @@ package org.springframework.cloud.task.repository.support; import java.util.ArrayList; +import java.util.Collections; import java.util.Date; import java.util.List; @@ -101,11 +102,11 @@ public class SimpleTaskRepository implements TaskRepository { @Override public TaskExecution createTaskExecution(String taskName, - Date startTime,List arguments) { + Date startTime,List arguments, String externalExecutionId) { initialize(); validateCreateInformation(startTime, taskName); TaskExecution taskExecution = - taskExecutionDao.createTaskExecution(taskName, startTime, arguments); + taskExecutionDao.createTaskExecution(taskName, startTime, arguments, externalExecutionId); logger.debug("Creating: " + taskExecution.toString()); return taskExecution; } @@ -114,16 +115,18 @@ public class SimpleTaskRepository implements TaskRepository { public TaskExecution createTaskExecution() { initialize(); TaskExecution taskExecution = - taskExecutionDao.createTaskExecution(null, null, new ArrayList(0)); + taskExecutionDao.createTaskExecution(null, null, + Collections.emptyList(), null); logger.debug("Creating: " + taskExecution.toString()); return taskExecution; } @Override - public TaskExecution startTaskExecution(long executionid, String taskName, Date startTime, List arguments) { + public TaskExecution startTaskExecution(long executionid, String taskName, Date startTime, List arguments, + String externalExecutionId) { initialize(); TaskExecution taskExecution = - taskExecutionDao.startTaskExecution(executionid, taskName, startTime, arguments); + taskExecutionDao.startTaskExecution(executionid, taskName, startTime, arguments, externalExecutionId); logger.debug("Starting: " + taskExecution.toString()); return taskExecution; } diff --git a/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/migration-h2.sql b/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/migration-h2.sql index 37253c84..3a464c08 100644 --- a/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/migration-h2.sql +++ b/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/migration-h2.sql @@ -1 +1,2 @@ alter table task_execution add ERROR_MESSAGE VARCHAR(2500); +alter table task_execution add EXTERNAL_EXECUTION_ID VARCHAR(255); diff --git a/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/migration-hsqldb.sql b/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/migration-hsqldb.sql index 5da7e4cd..f1f6595e 100644 --- a/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/migration-hsqldb.sql +++ b/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/migration-hsqldb.sql @@ -1 +1,2 @@ alter table task_execution add column ERROR_MESSAGE VARCHAR(2500); +alter table task_execution add EXTERNAL_EXECUTION_ID VARCHAR(255); diff --git a/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/migration-mysql.sql b/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/migration-mysql.sql index 5da7e4cd..f9e62fa3 100644 --- a/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/migration-mysql.sql +++ b/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/migration-mysql.sql @@ -1 +1,3 @@ alter table task_execution add column ERROR_MESSAGE VARCHAR(2500); +alter table task_execution add EXTERNAL_EXECUTION_ID VARCHAR(255); + diff --git a/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/migration-oracle.sql b/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/migration-oracle.sql index 273750c1..f659bea1 100644 --- a/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/migration-oracle.sql +++ b/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/migration-oracle.sql @@ -1 +1,3 @@ alter table task_execution add ERROR_MESSAGE varchar2(2500); +alter table task_execution add EXTERNAL_EXECUTION_ID varchar2(255); + diff --git a/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/migration-postgresql.sql b/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/migration-postgresql.sql index 5da7e4cd..f1f6595e 100644 --- a/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/migration-postgresql.sql +++ b/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/migration-postgresql.sql @@ -1 +1,2 @@ alter table task_execution add column ERROR_MESSAGE VARCHAR(2500); +alter table task_execution add EXTERNAL_EXECUTION_ID VARCHAR(255); diff --git a/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/migration-sqlserver.sql b/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/migration-sqlserver.sql index 37253c84..3a464c08 100644 --- a/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/migration-sqlserver.sql +++ b/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/migration-sqlserver.sql @@ -1 +1,2 @@ alter table task_execution add ERROR_MESSAGE VARCHAR(2500); +alter table task_execution add EXTERNAL_EXECUTION_ID VARCHAR(255); diff --git a/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-h2.sql b/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-h2.sql index de1c01d1..75178998 100644 --- a/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-h2.sql +++ b/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-h2.sql @@ -7,7 +7,8 @@ CREATE TABLE TASK_EXECUTION ( EXIT_CODE INTEGER , EXIT_MESSAGE VARCHAR(2500) , ERROR_MESSAGE VARCHAR(2500) , - LAST_UPDATED TIMESTAMP + LAST_UPDATED TIMESTAMP, + EXTERNAL_EXECUTION_ID VARCHAR(255) ); CREATE TABLE TASK_EXECUTION_PARAMS ( diff --git a/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-hsqldb.sql b/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-hsqldb.sql index 50a91ae8..e345cbb3 100644 --- a/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-hsqldb.sql +++ b/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-hsqldb.sql @@ -7,7 +7,8 @@ CREATE TABLE TASK_EXECUTION ( EXIT_CODE INTEGER , EXIT_MESSAGE VARCHAR(2500) , ERROR_MESSAGE VARCHAR(2500) , - LAST_UPDATED TIMESTAMP + LAST_UPDATED TIMESTAMP, + EXTERNAL_EXECUTION_ID VARCHAR(255) ); CREATE TABLE TASK_EXECUTION_PARAMS ( diff --git a/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-mysql.sql b/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-mysql.sql index 4f056b88..9bd53018 100644 --- a/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-mysql.sql +++ b/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-mysql.sql @@ -7,7 +7,8 @@ CREATE TABLE TASK_EXECUTION ( EXIT_CODE INTEGER , EXIT_MESSAGE VARCHAR(2500) , ERROR_MESSAGE VARCHAR(2500) , - LAST_UPDATED TIMESTAMP + LAST_UPDATED TIMESTAMP, + EXTERNAL_EXECUTION_ID VARCHAR(255) ) ENGINE=InnoDB; CREATE TABLE TASK_EXECUTION_PARAMS ( @@ -18,8 +19,8 @@ CREATE TABLE TASK_EXECUTION_PARAMS ( ) ENGINE=InnoDB; CREATE TABLE TASK_TASK_BATCH ( - TASK_EXECUTION_ID BIGINT NOT NULL , - JOB_EXECUTION_ID BIGINT NOT NULL , + TASK_EXECUTION_ID BIGINT NOT NULL , + JOB_EXECUTION_ID BIGINT NOT NULL , constraint TASK_EXEC_BATCH_FK foreign key (TASK_EXECUTION_ID) references TASK_EXECUTION(TASK_EXECUTION_ID) ) ENGINE=InnoDB; diff --git a/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-oracle10g.sql b/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-oracle10g.sql index 0a188dcc..b871ed1c 100644 --- a/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-oracle10g.sql +++ b/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-oracle10g.sql @@ -7,7 +7,8 @@ CREATE TABLE TASK_EXECUTION ( EXIT_CODE INTEGER , EXIT_MESSAGE VARCHAR2(2500) , ERROR_MESSAGE VARCHAR2(2500) , - LAST_UPDATED TIMESTAMP + LAST_UPDATED TIMESTAMP, + EXTERNAL_EXECUTION_ID VARCHAR2(255) ); CREATE TABLE TASK_EXECUTION_PARAMS ( diff --git a/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-postgresql.sql b/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-postgresql.sql index 89456f6b..0810a7e2 100644 --- a/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-postgresql.sql +++ b/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-postgresql.sql @@ -7,7 +7,8 @@ CREATE TABLE TASK_EXECUTION ( EXIT_CODE INTEGER , EXIT_MESSAGE VARCHAR(2500) , ERROR_MESSAGE VARCHAR(2500) , - LAST_UPDATED TIMESTAMP + LAST_UPDATED TIMESTAMP , + EXTERNAL_EXECUTION_ID VARCHAR(255) ); CREATE TABLE TASK_EXECUTION_PARAMS ( diff --git a/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-sqlserver.sql b/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-sqlserver.sql index 3f84313c..1d475e68 100644 --- a/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-sqlserver.sql +++ b/spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-sqlserver.sql @@ -6,7 +6,8 @@ CREATE TABLE TASK_EXECUTION ( EXIT_CODE INTEGER , EXIT_MESSAGE VARCHAR(2500) , ERROR_MESSAGE VARCHAR(2500) , - LAST_UPDATED DATETIME + LAST_UPDATED DATETIME , + EXTERNAL_EXECUTION_ID VARCHAR(255) ); CREATE TABLE TASK_EXECUTION_PARAMS ( diff --git a/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/listener/TaskExecutionListenerTests.java b/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/listener/TaskExecutionListenerTests.java index 05ad76de..ddfa0ab6 100644 --- a/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/listener/TaskExecutionListenerTests.java +++ b/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/listener/TaskExecutionListenerTests.java @@ -71,7 +71,7 @@ public class TaskExecutionListenerTests { DefaultTaskListenerConfiguration.TestTaskExecutionListener taskExecutionListener = context.getBean(DefaultTaskListenerConfiguration.TestTaskExecutionListener.class); TaskExecution taskExecution = new TaskExecution(0, null, "wombat", - new Date(), new Date(), null, new ArrayList(), null); + new Date(), new Date(), null, new ArrayList(), null, null); verifyListenerResults(true, false, false, taskExecution,taskExecutionListener); } @@ -87,7 +87,7 @@ public class TaskExecutionListenerTests { context.publishEvent(new ApplicationReadyEvent(new SpringApplication(), new String[0], context)); TaskExecution taskExecution = new TaskExecution(0, 0, "wombat", - new Date(), new Date(), null, new ArrayList(), null); + new Date(), new Date(), null, new ArrayList(), null, null); verifyListenerResults(true, true, false, taskExecution,taskExecutionListener); } @@ -106,7 +106,7 @@ public class TaskExecutionListenerTests { context.publishEvent(new ApplicationReadyEvent(application, new String[0], context)); TaskExecution taskExecution = new TaskExecution(0, 1, "wombat", new Date(), - new Date(), null, new ArrayList(), null); + new Date(), null, new ArrayList(), null, null); verifyListenerResults(true, true, true, taskExecution,taskExecutionListener); } @@ -120,7 +120,7 @@ public class TaskExecutionListenerTests { DefaultAnnotationConfiguration.AnnotatedTaskListener annotatedListener = context.getBean(DefaultAnnotationConfiguration.AnnotatedTaskListener.class); TaskExecution taskExecution = new TaskExecution(0, null, "wombat", - new Date(), new Date(), null, new ArrayList(), null); + new Date(), new Date(), null, new ArrayList(), null, null); verifyListenerResults(true, false, false, taskExecution,annotatedListener); } @@ -136,7 +136,7 @@ public class TaskExecutionListenerTests { context.publishEvent(new ApplicationReadyEvent(new SpringApplication(), new String[0], context)); TaskExecution taskExecution = new TaskExecution(0, 0, "wombat", - new Date(), new Date(), null, new ArrayList(), null); + new Date(), new Date(), null, new ArrayList(), null, null); verifyListenerResults(true, true, false, taskExecution,annotatedListener); } @@ -155,7 +155,7 @@ public class TaskExecutionListenerTests { context.publishEvent(new ApplicationReadyEvent(application, new String[0], context)); TaskExecution taskExecution = new TaskExecution(0, 1, "wombat", new Date(), - new Date(), null, new ArrayList(), null); + new Date(), null, new ArrayList(), null, null); verifyListenerResults(true, true, true, taskExecution,annotatedListener); } @@ -184,6 +184,7 @@ public class TaskExecutionListenerTests { assertEquals(taskExecution.getExecutionId(), actualListener.getTaskExecution().getExecutionId()); assertEquals(taskExecution.getExitCode(), actualListener.getTaskExecution().getExitCode()); + assertEquals(taskExecution.getExternalExecutionId(), actualListener.getTaskExecution().getExternalExecutionId()); } private void setupContextForTaskExecutionListener(){ diff --git a/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/listener/TaskLifecycleListenerTests.java b/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/listener/TaskLifecycleListenerTests.java index 9e20fa9c..75a2eb35 100644 --- a/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/listener/TaskLifecycleListenerTests.java +++ b/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/listener/TaskLifecycleListenerTests.java @@ -84,7 +84,7 @@ public class TaskLifecycleListenerTests { public void testTaskCreate() { context.refresh(); this.taskExplorer = context.getBean(TaskExplorer.class); - verifyTaskExecution(0, false, 0, null); + verifyTaskExecution(0, false); } @Test @@ -92,7 +92,7 @@ public class TaskLifecycleListenerTests { context.register(ArgsConfiguration.class); context.refresh(); this.taskExplorer = context.getBean(TaskExplorer.class); - verifyTaskExecution(2, false, 0, null); + verifyTaskExecution(2, false); } @Test @@ -102,7 +102,7 @@ public class TaskLifecycleListenerTests { context.publishEvent(new ApplicationReadyEvent(new SpringApplication(), new String[0], context)); - verifyTaskExecution(0, true, 0, null); + verifyTaskExecution(0, true); } @Test @@ -114,7 +114,7 @@ public class TaskLifecycleListenerTests { context.publishEvent(new ApplicationFailedEvent(application, new String[0], context, exception)); context.publishEvent(new ApplicationReadyEvent(application, new String[0], context)); - verifyTaskExecution(0, true, 1, exception); + verifyTaskExecution(0, true, 1, exception, null); } @Test @@ -128,13 +128,13 @@ public class TaskLifecycleListenerTests { context.publishEvent(new ApplicationFailedEvent(application, new String[0], context, exception)); context.publishEvent(new ApplicationReadyEvent(application, new String[0], context)); - verifyTaskExecution(0, true, exitCode, exception); + verifyTaskExecution(0, true, exitCode, exception, null); } @Test public void testNoClosingOfContext() { ConfigurableApplicationContext applicationContext = SpringApplication.run(new Object[] {TestDefaultConfiguration.class, PropertyPlaceholderAutoConfiguration.class}, - new String[] {"--spring.cloud.task.closecontext.enable=false"}); + new String[] {"--spring.cloud.task.closecontext_enable=false"}); try { assertTrue(applicationContext.isActive()); @@ -155,7 +155,27 @@ public class TaskLifecycleListenerTests { context.refresh(); } - private void verifyTaskExecution(int numberOfParams, boolean update, Integer exitCode, Throwable exception) { + @Test + public void testExternalExecutionId() { + ConfigurableEnvironment environment = new StandardEnvironment(); + MutablePropertySources propertySources = environment.getPropertySources(); + Map myMap = new HashMap(); + myMap.put("spring.cloud.task.external-execution-id", "myid"); + propertySources.addFirst(new MapPropertySource("EnvrionmentTestPropsource", myMap)); + context.setEnvironment(environment); + context.refresh(); + this.taskExplorer = context.getBean(TaskExplorer.class); + + verifyTaskExecution(0, false, 0, null, "myid"); + + } + + private void verifyTaskExecution(int numberOfParams, boolean update) { + verifyTaskExecution(numberOfParams, update, 0, null, null); + } + + private void verifyTaskExecution(int numberOfParams, boolean update, + Integer exitCode, Throwable exception, String externalExecutionId) { Sort sort = new Sort("id"); @@ -168,6 +188,7 @@ public class TaskLifecycleListenerTests { assertEquals(numberOfParams, taskExecution.getArguments().size()); assertEquals(exitCode, taskExecution.getExitCode()); + assertEquals(externalExecutionId, taskExecution.getExternalExecutionId()); if(exception != null) { assertTrue(taskExecution.getErrorMessage().length() > exception.getStackTrace().length); diff --git a/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/dao/JdbcTaskExecutionDaoTests.java b/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/dao/JdbcTaskExecutionDaoTests.java index 4df6707a..6576e80a 100644 --- a/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/dao/JdbcTaskExecutionDaoTests.java +++ b/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/dao/JdbcTaskExecutionDaoTests.java @@ -63,14 +63,15 @@ public class JdbcTaskExecutionDaoTests { @DirtiesContext public void testStartTaskExecution() { TaskExecution expectedTaskExecution = dao.createTaskExecution(null, null, - new ArrayList(0)); + new ArrayList(0), null); expectedTaskExecution.setArguments(Collections.singletonList("foo=" + UUID.randomUUID().toString())); expectedTaskExecution.setStartTime(new Date()); expectedTaskExecution.setTaskName(UUID.randomUUID().toString()); dao.startTaskExecution(expectedTaskExecution.getExecutionId(), expectedTaskExecution.getTaskName(), - expectedTaskExecution.getStartTime(), expectedTaskExecution.getArguments()); + expectedTaskExecution.getStartTime(), expectedTaskExecution.getArguments(), + expectedTaskExecution.getExternalExecutionId()); TestVerifierUtils.verifyTaskExecution(expectedTaskExecution, TestDBUtils.getTaskExecutionFromDB(dataSource, expectedTaskExecution.getExecutionId())); @@ -81,7 +82,7 @@ public class JdbcTaskExecutionDaoTests { public void createTaskExecution() { TaskExecution expectedTaskExecution = TestVerifierUtils.createSampleTaskExecutionNoArg(); expectedTaskExecution = dao.createTaskExecution(expectedTaskExecution.getTaskName(), expectedTaskExecution.getStartTime(), - expectedTaskExecution.getArguments()); + expectedTaskExecution.getArguments(), expectedTaskExecution.getExternalExecutionId()); TestVerifierUtils.verifyTaskExecution(expectedTaskExecution, TestDBUtils.getTaskExecutionFromDB(dataSource, expectedTaskExecution.getExecutionId())); @@ -91,7 +92,7 @@ public class JdbcTaskExecutionDaoTests { @DirtiesContext public void createEmptyTaskExecution() { TaskExecution expectedTaskExecution = dao.createTaskExecution(null, null, - new ArrayList(0)); + new ArrayList(0), null); TestVerifierUtils.verifyTaskExecution(expectedTaskExecution, TestDBUtils.getTaskExecutionFromDB(dataSource, expectedTaskExecution.getExecutionId())); @@ -102,7 +103,8 @@ public class JdbcTaskExecutionDaoTests { public void completeTaskExecution() { TaskExecution expectedTaskExecution = TestVerifierUtils.endSampleTaskExecutionNoArg(); expectedTaskExecution = dao.createTaskExecution(expectedTaskExecution.getTaskName(), - expectedTaskExecution.getStartTime(), expectedTaskExecution.getArguments()); + expectedTaskExecution.getStartTime(), expectedTaskExecution.getArguments(), + expectedTaskExecution.getExternalExecutionId()); dao.completeTaskExecution(expectedTaskExecution.getExecutionId(), expectedTaskExecution.getExitCode(), expectedTaskExecution.getEndTime(), expectedTaskExecution.getExitMessage()); diff --git a/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/dao/MapTaskExecutionDaoTests.java b/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/dao/MapTaskExecutionDaoTests.java index fcf21cf6..c375f092 100644 --- a/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/dao/MapTaskExecutionDaoTests.java +++ b/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/dao/MapTaskExecutionDaoTests.java @@ -45,13 +45,15 @@ public class MapTaskExecutionDaoTests { @Test public void testStartTaskExecution() { - TaskExecution expectedTaskExecution = this.dao.createTaskExecution(null, null, new ArrayList(0)); + TaskExecution expectedTaskExecution = this.dao.createTaskExecution(null, null, new ArrayList(0), null); expectedTaskExecution.setArguments(Collections.singletonList("foo=" + UUID.randomUUID().toString())); expectedTaskExecution.setStartTime(new Date()); expectedTaskExecution.setTaskName(UUID.randomUUID().toString()); - this.dao.startTaskExecution(expectedTaskExecution.getExecutionId(), expectedTaskExecution.getTaskName(), expectedTaskExecution.getStartTime(), expectedTaskExecution.getArguments()); + this.dao.startTaskExecution(expectedTaskExecution.getExecutionId(), expectedTaskExecution.getTaskName(), + expectedTaskExecution.getStartTime(), expectedTaskExecution.getArguments(), + expectedTaskExecution.getExternalExecutionId()); Map taskExecutionMap = this.dao.getTaskExecutions(); assertNotNull("taskExecutionMap must not be null", taskExecutionMap); TestVerifierUtils.verifyTaskExecution(expectedTaskExecution, @@ -61,7 +63,7 @@ public class MapTaskExecutionDaoTests { @Test public void createEmptyTaskExecution() { TaskExecution expectedTaskExecution = dao.createTaskExecution(null, null, - new ArrayList(0)); + new ArrayList(0), null); Map taskExecutionMap = this.dao.getTaskExecutions(); TestVerifierUtils.verifyTaskExecution(expectedTaskExecution, @@ -80,7 +82,8 @@ public class MapTaskExecutionDaoTests { public void saveTaskExecution(){ TaskExecution expectedTaskExecution = TestVerifierUtils.createSampleTaskExecutionNoArg(); expectedTaskExecution = this.dao.createTaskExecution(expectedTaskExecution.getTaskName(), - expectedTaskExecution.getStartTime(), expectedTaskExecution.getArguments()); + expectedTaskExecution.getStartTime(), expectedTaskExecution.getArguments(), + expectedTaskExecution.getExternalExecutionId()); Map taskExecutionMap = this.dao.getTaskExecutions(); assertNotNull("taskExecutionMap must not be null", taskExecutionMap); TestVerifierUtils.verifyTaskExecution(expectedTaskExecution, @@ -91,7 +94,8 @@ public class MapTaskExecutionDaoTests { public void completeTaskExecution(){ TaskExecution expectedTaskExecution = TestVerifierUtils.createSampleTaskExecutionNoArg(); expectedTaskExecution = this.dao.createTaskExecution(expectedTaskExecution.getTaskName(), - expectedTaskExecution.getStartTime(), expectedTaskExecution.getArguments()); + expectedTaskExecution.getStartTime(), expectedTaskExecution.getArguments(), + expectedTaskExecution.getExternalExecutionId()); this.dao.completeTaskExecution(expectedTaskExecution.getExecutionId(), expectedTaskExecution.getExitCode(), expectedTaskExecution.getEndTime(), expectedTaskExecution.getExitMessage()); diff --git a/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/database/support/FindAllPagingQueryProviderTests.java b/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/database/support/FindAllPagingQueryProviderTests.java index 4efe43e0..87a28050 100644 --- a/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/database/support/FindAllPagingQueryProviderTests.java +++ b/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/database/support/FindAllPagingQueryProviderTests.java @@ -43,30 +43,30 @@ public class FindAllPagingQueryProviderTests { public static Collection data() { return Arrays.asList(new Object[][]{ {"Oracle", "SELECT TASK_EXECUTION_ID, START_TIME, END_TIME, TASK_NAME, " - + "EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED FROM " + + "EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED, EXTERNAL_EXECUTION_ID FROM " + "(SELECT TASK_EXECUTION_ID, START_TIME, END_TIME, TASK_NAME, " - + "EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED, ROWNUM as " + + "EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED, EXTERNAL_EXECUTION_ID, ROWNUM as " + "TMP_ROW_NUM FROM (SELECT TASK_EXECUTION_ID, START_TIME, " - + "END_TIME, TASK_NAME, EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED " + + "END_TIME, TASK_NAME, EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED, EXTERNAL_EXECUTION_ID " + "FROM %PREFIX%EXECUTION ORDER BY START_TIME DESC, " + "TASK_EXECUTION_ID DESC)) WHERE TMP_ROW_NUM >= 1 AND " + "TMP_ROW_NUM < 11"}, {"HSQL Database Engine","SELECT LIMIT 0 10 TASK_EXECUTION_ID, " + "START_TIME, END_TIME, TASK_NAME, EXIT_CODE, EXIT_MESSAGE, " - + "ERROR_MESSAGE, LAST_UPDATED FROM %PREFIX%EXECUTION ORDER BY " + + "ERROR_MESSAGE, LAST_UPDATED, EXTERNAL_EXECUTION_ID FROM %PREFIX%EXECUTION ORDER BY " + "START_TIME DESC, TASK_EXECUTION_ID DESC"}, {"PostgreSQL","SELECT TASK_EXECUTION_ID, START_TIME, END_TIME, " - + "TASK_NAME, EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED " + + "TASK_NAME, EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED, EXTERNAL_EXECUTION_ID " + "FROM %PREFIX%EXECUTION ORDER BY START_TIME DESC, " + "TASK_EXECUTION_ID DESC LIMIT 10 OFFSET 0"}, {"MySQL","SELECT TASK_EXECUTION_ID, START_TIME, END_TIME, TASK_NAME, " - + "EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED FROM " + + "EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED, EXTERNAL_EXECUTION_ID FROM " + "%PREFIX%EXECUTION ORDER BY START_TIME DESC, " + "TASK_EXECUTION_ID DESC LIMIT 0, 10"}, {"Microsoft SQL Server","SELECT TASK_EXECUTION_ID, START_TIME, END_TIME, " - + "TASK_NAME, EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED FROM " + + "TASK_NAME, EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED, EXTERNAL_EXECUTION_ID FROM " + "(SELECT TASK_EXECUTION_ID, START_TIME, END_TIME, TASK_NAME, " - + "EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED, ROW_NUMBER() " + + "EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED, EXTERNAL_EXECUTION_ID, ROW_NUMBER() " + "OVER (ORDER BY START_TIME DESC, TASK_EXECUTION_ID DESC) AS " + "TMP_ROW_NUM FROM %PREFIX%EXECUTION) TASK_EXECUTION_PAGE " + "WHERE TMP_ROW_NUM >= 1 AND TMP_ROW_NUM < 11 ORDER BY START_TIME DESC, " diff --git a/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/database/support/WhereClausePagingQueryProviderTests.java b/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/database/support/WhereClausePagingQueryProviderTests.java index 2e67fc68..9f23182f 100644 --- a/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/database/support/WhereClausePagingQueryProviderTests.java +++ b/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/database/support/WhereClausePagingQueryProviderTests.java @@ -44,34 +44,34 @@ public class WhereClausePagingQueryProviderTests { public static Collection data() { return Arrays.asList(new Object[][]{ {"Oracle", "SELECT TASK_EXECUTION_ID, START_TIME, END_TIME, TASK_NAME, " - + "EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED FROM " + + "EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED, EXTERNAL_EXECUTION_ID FROM " + "(SELECT TASK_EXECUTION_ID, START_TIME, END_TIME, TASK_NAME, " - + "EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED, ROWNUM as " + + "EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED, EXTERNAL_EXECUTION_ID, ROWNUM as " + "TMP_ROW_NUM FROM (SELECT TASK_EXECUTION_ID, START_TIME, " + "END_TIME, TASK_NAME, EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, " - + "LAST_UPDATED FROM %PREFIX%EXECUTION " + + "LAST_UPDATED, EXTERNAL_EXECUTION_ID FROM %PREFIX%EXECUTION " + "WHERE TASK_EXECUTION_ID = '0000' ORDER BY START_TIME DESC, " + "TASK_EXECUTION_ID DESC)) WHERE TMP_ROW_NUM >= 1 AND " + "TMP_ROW_NUM < 11"}, {"HSQL Database Engine","SELECT LIMIT 0 10 TASK_EXECUTION_ID, " + "START_TIME, END_TIME, TASK_NAME, EXIT_CODE, EXIT_MESSAGE, " - + "ERROR_MESSAGE, LAST_UPDATED FROM %PREFIX%EXECUTION " + + "ERROR_MESSAGE, LAST_UPDATED, EXTERNAL_EXECUTION_ID FROM %PREFIX%EXECUTION " + "WHERE TASK_EXECUTION_ID = '0000' ORDER BY " + "START_TIME DESC, TASK_EXECUTION_ID DESC"}, {"PostgreSQL","SELECT TASK_EXECUTION_ID, START_TIME, END_TIME, " - + "TASK_NAME, EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED " + + "TASK_NAME, EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED, EXTERNAL_EXECUTION_ID " + "FROM %PREFIX%EXECUTION WHERE TASK_EXECUTION_ID = '0000' " + "ORDER BY START_TIME DESC, " + "TASK_EXECUTION_ID DESC LIMIT 10 OFFSET 0"}, {"MySQL","SELECT TASK_EXECUTION_ID, START_TIME, END_TIME, TASK_NAME, " - + "EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED FROM " + + "EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED, EXTERNAL_EXECUTION_ID FROM " + "%PREFIX%EXECUTION WHERE TASK_EXECUTION_ID = '0000' " + "ORDER BY START_TIME DESC, " + "TASK_EXECUTION_ID DESC LIMIT 0, 10"}, {"Microsoft SQL Server","SELECT TASK_EXECUTION_ID, START_TIME, END_TIME, " - + "TASK_NAME, EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED FROM " + + "TASK_NAME, EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED, EXTERNAL_EXECUTION_ID FROM " + "(SELECT TASK_EXECUTION_ID, START_TIME, END_TIME, TASK_NAME, " - + "EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED, ROW_NUMBER() " + + "EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED, EXTERNAL_EXECUTION_ID, ROW_NUMBER() " + "OVER (ORDER BY START_TIME DESC, TASK_EXECUTION_ID DESC) AS " + "TMP_ROW_NUM FROM %PREFIX%EXECUTION WHERE TASK_EXECUTION_ID = " + "'0000') TASK_EXECUTION_PAGE WHERE TMP_ROW_NUM >= 1 " diff --git a/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/support/SimpleTaskExplorerTests.java b/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/support/SimpleTaskExplorerTests.java index 0bc5c07d..2b4e108b 100644 --- a/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/support/SimpleTaskExplorerTests.java +++ b/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/support/SimpleTaskExplorerTests.java @@ -155,6 +155,7 @@ public class SimpleTaskExplorerTests { final int TEST_COUNT = 2; final int COMPLETE_COUNT = 5; final String TASK_NAME = "FOOBAR"; + final String EXTERNAL_EXECUTION_ID = "123ABC"; Map expectedResults = new HashMap<>(); //Store completed jobs @@ -165,7 +166,7 @@ public class SimpleTaskExplorerTests { for (; i < (COMPLETE_COUNT + TEST_COUNT); i++) { TaskExecution expectedTaskExecution = this.taskRepository.createTaskExecution( - TASK_NAME, new Date(), new ArrayList()); + TASK_NAME, new Date(), new ArrayList(), EXTERNAL_EXECUTION_ID); expectedResults.put(expectedTaskExecution.getExecutionId(), expectedTaskExecution); } Pageable pageable = new PageRequest(0, 10); @@ -190,6 +191,7 @@ public class SimpleTaskExplorerTests { final int TEST_COUNT = 5; final int COMPLETE_COUNT = 7; final String TASK_NAME = "FOOBAR"; + final String EXTERNAL_EXECUTION_ID = "123ABC"; Random randomGenerator = new Random(); Map expectedResults = new HashMap<>(); @@ -200,7 +202,7 @@ public class SimpleTaskExplorerTests { for (int i = 0; i < TEST_COUNT; i++) { TaskExecution expectedTaskExecution = this.taskRepository.createTaskExecution( - TASK_NAME, new Date(), new ArrayList()); + TASK_NAME, new Date(), new ArrayList(), EXTERNAL_EXECUTION_ID); expectedResults.put(expectedTaskExecution.getExecutionId(), expectedTaskExecution); } @@ -318,7 +320,7 @@ public class SimpleTaskExplorerTests { private TaskExecution createAndSaveTaskExecution(int i) { TaskExecution taskExecution = TestVerifierUtils.createSampleTaskExecution(i); taskExecution = this.taskRepository.createTaskExecution(taskExecution.getTaskName(), - taskExecution.getStartTime(), taskExecution.getArguments()); + taskExecution.getStartTime(), taskExecution.getArguments(), taskExecution.getExternalExecutionId()); return taskExecution; } diff --git a/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/support/SimpleTaskRepositoryJdbcTests.java b/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/support/SimpleTaskRepositoryJdbcTests.java index 083fb533..9e7ca05b 100644 --- a/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/support/SimpleTaskRepositoryJdbcTests.java +++ b/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/support/SimpleTaskRepositoryJdbcTests.java @@ -105,7 +105,7 @@ public class SimpleTaskRepositoryJdbcTests { TaskExecution actualTaskExecution = this.taskRepository.startTaskExecution(expectedTaskExecution.getExecutionId(), expectedTaskExecution.getTaskName(), expectedTaskExecution.getStartTime(), - expectedTaskExecution.getArguments()); + expectedTaskExecution.getArguments(), expectedTaskExecution.getExternalExecutionId()); TestVerifierUtils.verifyTaskExecution(expectedTaskExecution, actualTaskExecution); } @@ -121,7 +121,7 @@ public class SimpleTaskRepositoryJdbcTests { TaskExecution actualTaskExecution = this.taskRepository.startTaskExecution(expectedTaskExecution.getExecutionId(), expectedTaskExecution.getTaskName(), expectedTaskExecution.getStartTime(), - expectedTaskExecution.getArguments()); + expectedTaskExecution.getArguments(), expectedTaskExecution.getExternalExecutionId()); TestVerifierUtils.verifyTaskExecution(expectedTaskExecution, actualTaskExecution); } @@ -194,7 +194,8 @@ public class SimpleTaskRepositoryJdbcTests { TaskExecution expectedTaskExecution = TestVerifierUtils.createSampleTaskExecutionNoArg(); expectedTaskExecution.setTaskName(new String(new char[MAX_TASK_NAME_SIZE + 1])); simpleTaskRepository.createTaskExecution(expectedTaskExecution.getTaskName(), - expectedTaskExecution.getStartTime(), expectedTaskExecution.getArguments()); + expectedTaskExecution.getStartTime(), expectedTaskExecution.getArguments(), + expectedTaskExecution.getExternalExecutionId()); } @Test(expected = IllegalArgumentException.class) @@ -204,7 +205,8 @@ public class SimpleTaskRepositoryJdbcTests { TaskExecution expectedTaskExecution = TestVerifierUtils.createSampleTaskExecutionNoArg(); expectedTaskExecution.setTaskName(new String(new char[SimpleTaskRepository.MAX_TASK_NAME_SIZE + 1])); simpleTaskRepository.createTaskExecution(expectedTaskExecution.getTaskName(), - expectedTaskExecution.getStartTime(), expectedTaskExecution.getArguments()); + expectedTaskExecution.getStartTime(), expectedTaskExecution.getArguments(), + expectedTaskExecution.getExternalExecutionId()); } @Test @@ -230,7 +232,7 @@ public class SimpleTaskRepositoryJdbcTests { public void testCreateTaskExecutionNoParamMaxTaskName(){ taskRepository.createTaskExecution( new String(new char[SimpleTaskRepository.MAX_TASK_NAME_SIZE+1]), - new Date(), null); + new Date(), null, null); } @Test(expected=IllegalArgumentException.class) diff --git a/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/support/SimpleTaskRepositoryMapTests.java b/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/support/SimpleTaskRepositoryMapTests.java index 970a5cec..6f14a554 100644 --- a/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/support/SimpleTaskRepositoryMapTests.java +++ b/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/support/SimpleTaskRepositoryMapTests.java @@ -80,7 +80,7 @@ public class SimpleTaskRepositoryMapTests { TaskExecution actualTaskExecution = this.taskRepository.startTaskExecution(expectedTaskExecution.getExecutionId(), expectedTaskExecution.getTaskName(), expectedTaskExecution.getStartTime(), - expectedTaskExecution.getArguments()); + expectedTaskExecution.getArguments(), expectedTaskExecution.getExternalExecutionId()); TestVerifierUtils.verifyTaskExecution(expectedTaskExecution, actualTaskExecution); } @@ -95,7 +95,7 @@ public class SimpleTaskRepositoryMapTests { TaskExecution actualTaskExecution = this.taskRepository.startTaskExecution(expectedTaskExecution.getExecutionId(), expectedTaskExecution.getTaskName(), expectedTaskExecution.getStartTime(), - expectedTaskExecution.getArguments()); + expectedTaskExecution.getArguments(), expectedTaskExecution.getExternalExecutionId()); TestVerifierUtils.verifyTaskExecution(expectedTaskExecution, actualTaskExecution); } diff --git a/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/util/TaskExecutionCreator.java b/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/util/TaskExecutionCreator.java index 9650f220..b8d344d8 100644 --- a/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/util/TaskExecutionCreator.java +++ b/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/util/TaskExecutionCreator.java @@ -49,7 +49,8 @@ public class TaskExecutionCreator { public static TaskExecution createAndStoreTaskExecutionNoParams(TaskRepository taskRepository) { TaskExecution expectedTaskExecution = TestVerifierUtils.createSampleTaskExecutionNoArg(); expectedTaskExecution = taskRepository.createTaskExecution(expectedTaskExecution.getTaskName(), - expectedTaskExecution.getStartTime(), expectedTaskExecution.getArguments()); + expectedTaskExecution.getStartTime(), expectedTaskExecution.getArguments(), + expectedTaskExecution.getExternalExecutionId()); return expectedTaskExecution; } @@ -66,7 +67,8 @@ public class TaskExecutionCreator { params.add(UUID.randomUUID().toString()); expectedTaskExecution.setArguments(params); expectedTaskExecution = taskRepository.createTaskExecution(expectedTaskExecution.getTaskName(), - expectedTaskExecution.getStartTime(), expectedTaskExecution.getArguments()); + expectedTaskExecution.getStartTime(), expectedTaskExecution.getArguments(), + expectedTaskExecution.getExternalExecutionId()); return expectedTaskExecution; } diff --git a/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/util/TestDBUtils.java b/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/util/TestDBUtils.java index a79dc672..706bfe1f 100644 --- a/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/util/TestDBUtils.java +++ b/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/util/TestDBUtils.java @@ -74,7 +74,8 @@ public class TestDBUtils { rs.getTimestamp("END_TIME"), rs.getString("EXIT_MESSAGE"), new ArrayList(0), - rs.getString("ERROR_MESSAGE")); + rs.getString("ERROR_MESSAGE"), + rs.getString("EXTERNAL_EXECUTION_ID")); return taskExecution; } }); diff --git a/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/util/TestDefaultConfiguration.java b/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/util/TestDefaultConfiguration.java index a19e23c6..a171a07b 100644 --- a/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/util/TestDefaultConfiguration.java +++ b/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/util/TestDefaultConfiguration.java @@ -21,6 +21,8 @@ import javax.sql.DataSource; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.ApplicationArguments; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.cloud.task.configuration.TaskProperties; import org.springframework.cloud.task.listener.TaskLifecycleListener; import org.springframework.cloud.task.repository.TaskExplorer; import org.springframework.cloud.task.repository.TaskNameResolver; @@ -40,10 +42,14 @@ import org.springframework.context.annotation.Configuration; * @author Michael Minella */ @Configuration +@EnableConfigurationProperties(TaskProperties.class) public class TestDefaultConfiguration implements InitializingBean { private TaskExecutionDaoFactoryBean factoryBean; + @Autowired + TaskProperties taskProperties; + @Autowired(required = false) private ApplicationArguments applicationArguments; @@ -70,7 +76,8 @@ public class TestDefaultConfiguration implements InitializingBean { @Bean public TaskLifecycleListener taskHandler(TaskExplorer taskExplorer){ - return new TaskLifecycleListener(taskRepository(), taskNameResolver(), applicationArguments, taskExplorer); + return new TaskLifecycleListener(taskRepository(), taskNameResolver(), + applicationArguments, taskExplorer, taskProperties); } @Override diff --git a/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/util/TestVerifierUtils.java b/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/util/TestVerifierUtils.java index df00a6b5..959934dc 100644 --- a/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/util/TestVerifierUtils.java +++ b/spring-cloud-task-core/src/test/java/org/springframework/cloud/task/util/TestVerifierUtils.java @@ -90,7 +90,7 @@ public class TestVerifierUtils { String taskName = UUID.randomUUID().toString(); return new TaskExecution(executionId, 0, taskName, - startTime, null, null, new ArrayList(), null); + startTime, null, null, new ArrayList(), null, null); } /** @@ -108,7 +108,7 @@ public class TestVerifierUtils { String exitMessage = UUID.randomUUID().toString(); return new TaskExecution(executionId, exitCode, taskName, - startTime, endTime, exitMessage, new ArrayList(), null); + startTime, endTime, exitMessage, new ArrayList(), null, null); } /** @@ -119,12 +119,13 @@ public class TestVerifierUtils { public static TaskExecution createSampleTaskExecution(long executionId) { Date startTime = new Date(); String taskName = UUID.randomUUID().toString(); + String externalExecutionId = UUID.randomUUID().toString(); List args = new ArrayList<>(ARG_SIZE); for (int i = 0; i < ARG_SIZE; i++){ args.add(UUID.randomUUID().toString()); } return new TaskExecution(executionId, null, taskName, - startTime, null, null, args, null); + startTime, null, null, args, null, externalExecutionId); } /** diff --git a/spring-cloud-task-docs/src/main/asciidoc/features.adoc b/spring-cloud-task-docs/src/main/asciidoc/features.adoc index 6dc453e1..6508c27a 100644 --- a/spring-cloud-task-docs/src/main/asciidoc/features.adoc +++ b/spring-cloud-task-docs/src/main/asciidoc/features.adoc @@ -49,7 +49,7 @@ updated in the repository with the results. NOTE: At the completion of a task (all `*Runner#run` methods are called and the task repository has been updated) the `ApplicationContext` will be closed by default. This -behavior can be overriden by setting the property `spring.cloud.task.closecontext.enable` +behavior can be overriden by setting the property `spring.cloud.task.closecontext_enable` to false. [[features-task-execution-details]] @@ -135,6 +135,39 @@ If your application utilizes more than one `DataSource`, you'll need to configur task repository with the appropriate `DataSource`. This customization can be done via an implementation of the `TaskConfigurer`. +[[features-generated_task_id]] +=== Externally Generated Task Id + +In some cases a user wants to allow for the time difference between +when a task is requested and when the infrastructure actually launches it. +Spring Cloud Task allows a user to create a TaskExecution at the time the +task is requested. Then pass the execution ID of the generated TaskExecution +to the task so that it can update the TaskExecution through the task's lifecycle. + +The TaskExecution can be created by calling the `createTaskExecution` method on +an implementation of the TaskRepository that references the datastore storing +the TaskExecutions. + +In order to configure your Task to use a generated TaskExecutionId add the +following property: + +``` + spring.cloud.task.executionid= +``` + +[[features-external_task_id]] +=== External Task Id + +Spring Cloud Task allows a user to store an external task Id for each +TaskExecution. An example of this would be a task id that is provided by +Cloud Foundry when a task is launched on the platform. +In order to configure your Task to use a generated TaskExecutionId add the +following property: + +``` +spring.cloud.task.external.executionid= +``` + [[features-task-configurer]] === TaskConfigurer diff --git a/spring-cloud-task-integration-tests/src/test/java/org/springframework/cloud/task/listener/BatchExecutionEventTests.java b/spring-cloud-task-integration-tests/src/test/java/org/springframework/cloud/task/listener/BatchExecutionEventTests.java index 65e75dd7..6f71eb7c 100644 --- a/spring-cloud-task-integration-tests/src/test/java/org/springframework/cloud/task/listener/BatchExecutionEventTests.java +++ b/spring-cloud-task-integration-tests/src/test/java/org/springframework/cloud/task/listener/BatchExecutionEventTests.java @@ -254,7 +254,7 @@ public class BatchExecutionEventTests { } private String[] getCommandLineParams(String sinkChannelParam) { - return new String[]{ "--spring.cloud.task.closecontext.enable=false", + return new String[]{ "--spring.cloud.task.closecontext_enable=false", "--spring.cloud.task.name=" + TASK_NAME, "--spring.main.web-environment=false", "--spring.cloud.stream.defaultBinder=rabbit", diff --git a/spring-cloud-task-integration-tests/src/test/java/org/springframework/cloud/task/listener/TaskEventTests.java b/spring-cloud-task-integration-tests/src/test/java/org/springframework/cloud/task/listener/TaskEventTests.java index 2a4f80f4..e7601fb5 100644 --- a/spring-cloud-task-integration-tests/src/test/java/org/springframework/cloud/task/listener/TaskEventTests.java +++ b/spring-cloud-task-integration-tests/src/test/java/org/springframework/cloud/task/listener/TaskEventTests.java @@ -62,7 +62,7 @@ public class TaskEventTests { ConfigurableApplicationContext applicationContext = new SpringApplicationBuilder().sources(new Object[] {TaskEventsConfiguration.class, TaskEventAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class, - RabbitServiceAutoConfiguration.class}).build().run(new String[] {"--spring.cloud.task.closecontext.enable=false", + RabbitServiceAutoConfiguration.class}).build().run(new String[] {"--spring.cloud.task.closecontext_enable=false", "--spring.cloud.task.name=" + TASK_NAME, "--spring.main.web-environment=false", "--spring.cloud.stream.defaultBinder=rabbit", diff --git a/spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/batch/listener/JobExecutionEventTests.java b/spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/batch/listener/JobExecutionEventTests.java index d7e77745..dabb5844 100644 --- a/spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/batch/listener/JobExecutionEventTests.java +++ b/spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/batch/listener/JobExecutionEventTests.java @@ -278,7 +278,7 @@ public class JobExecutionEventTests { EventJobExecutionConfiguration.class, PropertyPlaceholderAutoConfiguration.class, TestSupportBinderAutoConfiguration.class}, - new String[]{"--spring.cloud.task.closecontext.enable=false", + new String[]{"--spring.cloud.task.closecontext_enable=false", "--spring.main.web-environment=false", disabledPropertyArg}); diff --git a/spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/listener/TaskEventTests.java b/spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/listener/TaskEventTests.java index 7c9fbcd4..cf5e60f9 100644 --- a/spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/listener/TaskEventTests.java +++ b/spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/listener/TaskEventTests.java @@ -42,7 +42,7 @@ public class TaskEventTests { TaskEventAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class, TestSupportBinderAutoConfiguration.class}, - new String[]{ "--spring.cloud.task.closecontext.enable=false", + new String[]{ "--spring.cloud.task.closecontext_enable=false", "--spring.main.web-environment=false"}); assertNotNull(applicationContext.getBean("taskEventListener"));