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
This commit is contained in:
Michael Minella
2016-08-22 12:55:31 -05:00
parent 2bfc4780c7
commit 17e4250586
40 changed files with 307 additions and 114 deletions

View File

@@ -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<String>(), null);
new Date(), new Date(), null, new ArrayList<String>(), 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<String>(), null);
new Date(), new Date(), null, new ArrayList<String>(), 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<String>(), null);
new Date(), null, new ArrayList<String>(), 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<String>(), null);
new Date(), new Date(), null, new ArrayList<String>(), 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<String>(), null);
new Date(), new Date(), null, new ArrayList<String>(), 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<String>(), null);
new Date(), null, new ArrayList<String>(), 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(){

View File

@@ -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);

View File

@@ -63,14 +63,15 @@ public class JdbcTaskExecutionDaoTests {
@DirtiesContext
public void testStartTaskExecution() {
TaskExecution expectedTaskExecution = dao.createTaskExecution(null, null,
new ArrayList<String>(0));
new ArrayList<String>(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<String>(0));
new ArrayList<String>(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());

View File

@@ -45,13 +45,15 @@ public class MapTaskExecutionDaoTests {
@Test
public void testStartTaskExecution() {
TaskExecution expectedTaskExecution = this.dao.createTaskExecution(null, null, new ArrayList<String>(0));
TaskExecution expectedTaskExecution = this.dao.createTaskExecution(null, null, new ArrayList<String>(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<Long, TaskExecution> 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<String>(0));
new ArrayList<String>(0), null);
Map<Long, TaskExecution> 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<Long, TaskExecution> 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());

View File

@@ -43,30 +43,30 @@ public class FindAllPagingQueryProviderTests {
public static Collection<Object[]> 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, "

View File

@@ -44,34 +44,34 @@ public class WhereClausePagingQueryProviderTests {
public static Collection<Object[]> 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 "

View File

@@ -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<Long, TaskExecution> 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<String>());
TASK_NAME, new Date(), new ArrayList<String>(), 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<Long, TaskExecution> 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<String>());
TASK_NAME, new Date(), new ArrayList<String>(), 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;
}

View File

@@ -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)

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -74,7 +74,8 @@ public class TestDBUtils {
rs.getTimestamp("END_TIME"),
rs.getString("EXIT_MESSAGE"),
new ArrayList<String>(0),
rs.getString("ERROR_MESSAGE"));
rs.getString("ERROR_MESSAGE"),
rs.getString("EXTERNAL_EXECUTION_ID"));
return taskExecution;
}
});

View File

@@ -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

View File

@@ -90,7 +90,7 @@ public class TestVerifierUtils {
String taskName = UUID.randomUUID().toString();
return new TaskExecution(executionId, 0, taskName,
startTime, null, null, new ArrayList<String>(), null);
startTime, null, null, new ArrayList<String>(), 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<String>(), null);
startTime, endTime, exitMessage, new ArrayList<String>(), 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<String> 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);
}
/**