Introduced Error Message to Task Execution

To provide the ability to control task orchestration via the exit
message, we moved the stack trace storage to a new field.  This means
that exit message is now a field we can use similar to how exit code is
in batch, and still have the stack trace of an unsuccessful task
execution stored.

Resolves spring-cloud/spring-cloud-task#186

Disabled integration tests by default

Just some cleanup on merge
This commit is contained in:
Michael Minella
2016-08-11 14:25:10 -05:00
committed by Glenn Renfro
parent 551a4bc53a
commit db0565b7cf
28 changed files with 225 additions and 64 deletions

View File

@@ -156,7 +156,7 @@ public class TaskLifecycleListener implements ApplicationListener<ApplicationEve
}
if(this.applicationFailedEvent != null) {
this.taskExecution.setExitMessage(stackTraceToString(this.applicationFailedEvent.getException()));
this.taskExecution.setErrorMessage(stackTraceToString(this.applicationFailedEvent.getException()));
}
if(this.taskExecution.getExitCode() != 0){
@@ -165,7 +165,7 @@ public class TaskLifecycleListener implements ApplicationListener<ApplicationEve
}
taskExecution.setExitMessage(invokeOnTaskEnd(taskExecution).getExitMessage());
taskRepository.completeTaskExecution(taskExecution.getExecutionId(), taskExecution.getExitCode(),
taskExecution.getEndTime(), taskExecution.getExitMessage());
taskExecution.getEndTime(), taskExecution.getExitMessage(), taskExecution.getErrorMessage());
this.finished = true;
@@ -237,7 +237,8 @@ public class TaskLifecycleListener implements ApplicationListener<ApplicationEve
return new TaskExecution(taskExecution.getExecutionId(),
taskExecution.getExitCode(), taskExecution.getTaskName(), startTime,
endTime,taskExecution.getExitMessage(),
Collections.unmodifiableList(taskExecution.getArguments()));
Collections.unmodifiableList(taskExecution.getArguments()),
taskExecution.getErrorMessage());
}
@Override

View File

@@ -26,6 +26,7 @@ import org.springframework.util.Assert;
* Represents the state of the Task for each execution.
*
* @author Glenn Renfro
* @author Michael Minella
*/
public class TaskExecution {
@@ -59,6 +60,13 @@ public class TaskExecution {
*/
private String exitMessage;
/**
* Error information available upon the failure of a task
*
* @since 1.1.0
*/
private String errorMessage;
/**
* The arguments that were used for this task execution.
*/
@@ -70,7 +78,8 @@ public class TaskExecution {
public TaskExecution(long executionId, Integer exitCode, String taskName,
Date startTime, Date endTime,
String exitMessage, List<String> arguments) {
String exitMessage, List<String> arguments,
String errorMessage) {
Assert.notNull(arguments, "arguments must not be null");
Assert.notNull(startTime, "startTime must not be null");
@@ -81,6 +90,7 @@ public class TaskExecution {
this.arguments = new ArrayList<>(arguments);
this.startTime = (Date)startTime.clone();
this.endTime = (endTime != null) ? (Date)endTime.clone() : null;
this.errorMessage = errorMessage;
}
public long getExecutionId() {
@@ -135,6 +145,14 @@ public class TaskExecution {
this.arguments = new ArrayList<> (arguments);
}
public String getErrorMessage() {
return errorMessage;
}
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
@Override
public String toString() {
return "TaskExecution{" +
@@ -144,6 +162,7 @@ public class TaskExecution {
", startTime=" + startTime +
", endTime=" + endTime +
", exitMessage='" + exitMessage + '\'' +
", errorMessage='" + errorMessage + "\'" +
", arguments=" + arguments +
'}';
}

View File

@@ -42,6 +42,20 @@ public interface TaskRepository {
TaskExecution completeTaskExecution(long executionId, Integer exitCode, Date endTime,
String exitMessage);
/**
* Notifies the repository that a taskExecution has completed.
*
* @param executionId to the task execution to be updated.
* @param exitCode to be stored for this task.
* @param endTime designated when the task completed.
* @param exitMessage to be stored for the task.
* @return the updated {@link TaskExecution}
* @since 1.1.0
*/
@Transactional
TaskExecution completeTaskExecution(long executionId, Integer exitCode, Date endTime,
String exitMessage, String errorMessage);
/**
* Notifies the repository that a taskExecution needs to be created.
*

View File

@@ -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, LAST_UPDATED ";
+ "EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED ";
public static final String FROM_CLAUSE = "%PREFIX%EXECUTION";
@@ -78,12 +78,12 @@ public class JdbcTaskExecutionDao implements TaskExecutionDao {
+ "%PREFIX%EXECUTION WHERE TASK_EXECUTION_ID = ?";
private static final String UPDATE_TASK_EXECUTION = "UPDATE %PREFIX%EXECUTION set "
+ "END_TIME = ?, EXIT_CODE = ?, EXIT_MESSAGE = ?, LAST_UPDATED = ? "
+ "where TASK_EXECUTION_ID = ?";
+ "END_TIME = ?, EXIT_CODE = ?, EXIT_MESSAGE = ?, ERROR_MESSAGE = ?, "
+ "LAST_UPDATED = ? where TASK_EXECUTION_ID = ?";
private static final String GET_EXECUTION_BY_ID = "SELECT TASK_EXECUTION_ID, " +
"START_TIME, END_TIME, TASK_NAME, EXIT_CODE, "
+ "EXIT_MESSAGE, LAST_UPDATED "
+ "EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED "
+ "from %PREFIX%EXECUTION where TASK_EXECUTION_ID = ?";
private static final String FIND_ARGUMENT_FROM_ID = "SELECT TASK_EXECUTION_ID, "
@@ -129,7 +129,7 @@ public class JdbcTaskExecutionDao implements TaskExecutionDao {
Date startTime, List<String> arguments) {
long taskExecutionId = getNextExecutionId();
TaskExecution taskExecution = new TaskExecution(taskExecutionId, null, taskName,
startTime, null, null, arguments);
startTime, null, null, arguments, null);
Object[] queryParameters = new Object[]{ taskExecutionId, startTime, taskName, new Date()};
jdbcTemplate.update(
@@ -142,7 +142,7 @@ public class JdbcTaskExecutionDao implements TaskExecutionDao {
@Override
public void completeTaskExecution(long taskExecutionId, Integer exitCode, Date endTime,
String exitMessage) {
String exitMessage, String errorMessage) {
// Check if given TaskExecution's Id already exists, if none is found
// it is invalid and an exception should be thrown.
if (jdbcTemplate.queryForObject(getQuery(CHECK_TASK_EXECUTION_EXISTS), Integer.class,
@@ -150,15 +150,21 @@ public class JdbcTaskExecutionDao implements TaskExecutionDao {
throw new IllegalStateException("Invalid TaskExecution, ID " + taskExecutionId + " not found.");
}
Object[] parameters = new Object[]{ endTime, exitCode, exitMessage, new Date(),
Object[] parameters = new Object[]{ endTime, exitCode, exitMessage, errorMessage, new Date(),
taskExecutionId};
jdbcTemplate.update(
getQuery(UPDATE_TASK_EXECUTION),
parameters,
new int[]{ Types.TIMESTAMP, Types.INTEGER, Types.VARCHAR, Types.TIMESTAMP,
new int[]{ Types.TIMESTAMP, Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.TIMESTAMP,
Types.BIGINT});
}
@Override
public void completeTaskExecution(long taskExecutionId, Integer exitCode, Date endTime,
String exitMessage) {
completeTaskExecution(taskExecutionId, exitCode, endTime, exitMessage, null);
}
/**
* Public setter for the table prefix property. This will be prefixed to all
* the table names before queries are executed. Defaults to
@@ -374,7 +380,8 @@ public class JdbcTaskExecutionDao implements TaskExecutionDao {
rs.getTimestamp("START_TIME"),
rs.getTimestamp("END_TIME"),
rs.getString("EXIT_MESSAGE"),
getTaskArguments(id));
getTaskArguments(id),
rs.getString("ERROR_MESSAGE"));
}
private Integer getNullableExitCode(ResultSet rs) throws SQLException {

View File

@@ -56,17 +56,23 @@ public class MapTaskExecutionDao implements TaskExecutionDao {
Date startTime, List<String> arguments) {
long taskExecutionId = getNextExecutionId();
TaskExecution taskExecution = new TaskExecution(taskExecutionId, null, taskName,
startTime, null, null, arguments);
startTime, null, null, arguments, null);
taskExecutions.put(taskExecutionId, taskExecution);
return taskExecution;
}
@Override
public void completeTaskExecution(long executionId, Integer exitCode, Date endTime, String exitMessage) {
public void completeTaskExecution(long executionId, Integer exitCode, Date endTime, String exitMessage, String errorMessage) {
TaskExecution taskExecution= taskExecutions.get(executionId);
taskExecution.setEndTime(endTime);
taskExecution.setExitCode(exitCode);
taskExecution.setExitMessage(exitMessage);
taskExecution.setErrorMessage(errorMessage);
}
@Override
public void completeTaskExecution(long executionId, Integer exitCode, Date endTime, String exitMessage) {
completeTaskExecution(executionId, exitCode, endTime, exitMessage, null);
}
@Override

View File

@@ -42,6 +42,18 @@ public interface TaskExecutionDao {
TaskExecution createTaskExecution( String taskName,
Date startTime, List<String> arguments);
/**
* Update and existing {@link TaskExecution}.
*
* @param executionId the id of the taskExecution to be updated.
* @param exitCode the status of the task upon completion.
* @param endTime the time the task completed.
* @param exitMessage the message assigned to the task upon completion.
* @param errorMessage error information available upon failure of a task.
* @since 1.1.0
*/
void completeTaskExecution(long executionId, Integer exitCode, Date endTime, String exitMessage, String errorMessage);
/**
* Update and existing {@link TaskExecution}.
*

View File

@@ -51,19 +51,25 @@ public class SimpleTaskRepository implements TaskRepository {
this.taskExecutionDaoFactoryBean = taskExecutionDaoFactoryBean;
}
@Override
public TaskExecution completeTaskExecution(long executionId, Integer exitCode, Date endTime, String exitMessage) {
return completeTaskExecution(executionId, exitCode, endTime, exitMessage, null);
}
@Override
public TaskExecution completeTaskExecution(long executionId, Integer exitCode, Date endTime,
String exitMessage) {
String exitMessage, String errorMessage) {
initialize();
validateExitInformation(executionId, exitCode, endTime);
exitMessage = trimExitMessage(exitMessage);
taskExecutionDao.completeTaskExecution(executionId, exitCode, endTime, exitMessage);
taskExecutionDao.completeTaskExecution(executionId, exitCode, endTime, exitMessage, errorMessage);
logger.debug("Updating: TaskExecution with executionId="+executionId
+ " with the following {"
+ "exitCode=" + exitCode
+ ", endTime=" + endTime
+ ", exitMessage='" + exitMessage + '\''
+ ", errorMessage='" + errorMessage + '\''
+ '}');
return taskExecutionDao.getTaskExecution(executionId);

View File

@@ -6,6 +6,7 @@ CREATE TABLE TASK_EXECUTION (
TASK_NAME VARCHAR(100) ,
EXIT_CODE INTEGER ,
EXIT_MESSAGE VARCHAR(2500) ,
ERROR_MESSAGE VARCHAR(2500) ,
LAST_UPDATED TIMESTAMP
);

View File

@@ -6,6 +6,7 @@ CREATE TABLE TASK_EXECUTION (
TASK_NAME VARCHAR(100) ,
EXIT_CODE INTEGER ,
EXIT_MESSAGE VARCHAR(2500) ,
ERROR_MESSAGE VARCHAR(2500) ,
LAST_UPDATED TIMESTAMP
);

View File

@@ -6,6 +6,7 @@ CREATE TABLE TASK_EXECUTION (
TASK_NAME VARCHAR(100) ,
EXIT_CODE INTEGER ,
EXIT_MESSAGE VARCHAR(2500) ,
ERROR_MESSAGE VARCHAR(2500) ,
LAST_UPDATED TIMESTAMP
) ENGINE=InnoDB;

View File

@@ -6,6 +6,7 @@ CREATE TABLE TASK_EXECUTION (
TASK_NAME VARCHAR2(100) ,
EXIT_CODE INTEGER ,
EXIT_MESSAGE VARCHAR2(2500) ,
ERROR_MESSAGE VARCHAR2(2500) ,
LAST_UPDATED TIMESTAMP
);

View File

@@ -6,6 +6,7 @@ CREATE TABLE TASK_EXECUTION (
TASK_NAME VARCHAR(100) ,
EXIT_CODE INTEGER ,
EXIT_MESSAGE VARCHAR(2500) ,
ERROR_MESSAGE VARCHAR(2500) ,
LAST_UPDATED TIMESTAMP
);

View File

@@ -5,6 +5,7 @@ CREATE TABLE TASK_EXECUTION (
TASK_NAME VARCHAR(100) ,
EXIT_CODE INTEGER ,
EXIT_MESSAGE VARCHAR(2500) ,
ERROR_MESSAGE VARCHAR(2500) ,
LAST_UPDATED DATETIME
);

View File

@@ -28,8 +28,8 @@ public class TaskCoreTests {
private static final String UPDATE_TASK_MESSAGE = "Updating: TaskExecution with executionId=";
private static final String SUCCESS_EXIT_CODE_MESSAGE = "with the following {exitCode=0";
private static final String EXCEPTION_EXIT_CODE_MESSAGE = "with the following {exitCode=1";
private static final String EXIT_MESSAGE =
"exitMessage='java.lang.IllegalStateException: Failed to execute CommandLineRunner";
private static final String ERROR_MESSAGE =
"errorMessage='java.lang.IllegalStateException: Failed to execute CommandLineRunner";
private ConfigurableApplicationContext applicationContext;
@@ -83,7 +83,7 @@ public class TaskCoreTests {
assertTrue("Test results have incorrect exit code: " + output,
output.contains(EXCEPTION_EXIT_CODE_MESSAGE));
assertTrue("Test results have incorrect exit message: " + output,
output.contains(EXIT_MESSAGE));
output.contains(ERROR_MESSAGE));
assertTrue("Test results have exception message: " + output,
output.contains(EXCEPTION_MESSAGE));
}

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>());
new Date(), new Date(), null, new ArrayList<String>(), 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>());
new Date(), new Date(), null, new ArrayList<String>(), 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>());
new Date(), null, new ArrayList<String>(), 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>());
new Date(), new Date(), null, new ArrayList<String>(), 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>());
new Date(), new Date(), null, new ArrayList<String>(), 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>());
new Date(), null, new ArrayList<String>(), null);
verifyListenerResults(true, true, true, taskExecution,annotatedListener);
}
@@ -169,13 +169,16 @@ public class TaskExecutionListenerTests {
assertEquals(TestListener.END_MESSAGE, actualListener.getTaskExecution().getExitMessage());
assertNotNull(actualListener.getThrowable());
assertTrue(actualListener.getThrowable() instanceof RuntimeException);
assertTrue(actualListener.getTaskExecution().getErrorMessage().startsWith("java.lang.RuntimeException: This was expected"));
}
else if(isTaskEnd){
assertEquals(TestListener.END_MESSAGE, actualListener.getTaskExecution().getExitMessage());
assertNull(actualListener.getTaskExecution().getErrorMessage());
assertNull(actualListener.getThrowable());
}
else {
assertEquals(TestListener.START_MESSAGE, actualListener.getTaskExecution().getExitMessage());
assertNull(actualListener.getTaskExecution().getErrorMessage());
assertNull(actualListener.getThrowable());
}

View File

@@ -139,7 +139,7 @@ public class TaskLifecycleListenerTests {
assertEquals(exitCode, taskExecution.getExitCode());
if(exception != null) {
assertTrue(taskExecution.getExitMessage().length() > exception.getStackTrace().length);
assertTrue(taskExecution.getErrorMessage().length() > exception.getStackTrace().length);
}
else {
assertNull(taskExecution.getExitMessage());

View File

@@ -16,18 +16,19 @@
package org.springframework.cloud.task.repository.database.support;
import static org.junit.Assert.assertEquals;
import java.util.Arrays;
import java.util.Collection;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.springframework.cloud.task.util.TestDBUtils;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import static org.junit.Assert.assertEquals;
/**
* @author Glenn Renfro
*/
@@ -42,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, LAST_UPDATED FROM "
+ "EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED FROM "
+ "(SELECT TASK_EXECUTION_ID, START_TIME, END_TIME, TASK_NAME, "
+ "EXIT_CODE, EXIT_MESSAGE, LAST_UPDATED, ROWNUM as "
+ "EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED, ROWNUM as "
+ "TMP_ROW_NUM FROM (SELECT TASK_EXECUTION_ID, START_TIME, "
+ "END_TIME, TASK_NAME, EXIT_CODE, EXIT_MESSAGE, LAST_UPDATED "
+ "END_TIME, TASK_NAME, EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED "
+ "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, "
+ "LAST_UPDATED FROM %PREFIX%EXECUTION ORDER BY "
+ "ERROR_MESSAGE, LAST_UPDATED 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, LAST_UPDATED "
+ "TASK_NAME, EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED "
+ "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, LAST_UPDATED FROM "
+ "EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED 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, LAST_UPDATED FROM "
+ "TASK_NAME, EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED FROM "
+ "(SELECT TASK_EXECUTION_ID, START_TIME, END_TIME, TASK_NAME, "
+ "EXIT_CODE, EXIT_MESSAGE, LAST_UPDATED, ROW_NUMBER() "
+ "EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED, 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

@@ -16,19 +16,20 @@
package org.springframework.cloud.task.repository.database.support;
import static org.junit.Assert.assertEquals;
import java.util.Arrays;
import java.util.Collection;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.springframework.cloud.task.repository.database.PagingQueryProvider;
import org.springframework.cloud.task.util.TestDBUtils;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import static org.junit.Assert.assertEquals;
/**
* @author Glenn Renfro
*/
@@ -43,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, LAST_UPDATED FROM "
+ "EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED FROM "
+ "(SELECT TASK_EXECUTION_ID, START_TIME, END_TIME, TASK_NAME, "
+ "EXIT_CODE, EXIT_MESSAGE, LAST_UPDATED, ROWNUM as "
+ "EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED, ROWNUM as "
+ "TMP_ROW_NUM FROM (SELECT TASK_EXECUTION_ID, START_TIME, "
+ "END_TIME, TASK_NAME, EXIT_CODE, EXIT_MESSAGE, LAST_UPDATED "
+ "FROM %PREFIX%EXECUTION "
+ "END_TIME, TASK_NAME, EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, "
+ "LAST_UPDATED 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, "
+ "LAST_UPDATED FROM %PREFIX%EXECUTION "
+ "ERROR_MESSAGE, LAST_UPDATED 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, LAST_UPDATED "
+ "TASK_NAME, EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED "
+ "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, LAST_UPDATED FROM "
+ "EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED 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, LAST_UPDATED FROM "
+ "TASK_NAME, EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED FROM "
+ "(SELECT TASK_EXECUTION_ID, START_TIME, END_TIME, TASK_NAME, "
+ "EXIT_CODE, EXIT_MESSAGE, LAST_UPDATED, ROW_NUMBER() "
+ "EXIT_CODE, EXIT_MESSAGE, ERROR_MESSAGE, LAST_UPDATED, 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

@@ -70,6 +70,6 @@ public class TaskExecutionCreator {
TaskExecution expectedTaskExecution) {
return taskRepository.completeTaskExecution(expectedTaskExecution.getExecutionId(),
expectedTaskExecution.getExitCode(), expectedTaskExecution.getEndTime(),
expectedTaskExecution.getExitMessage());
expectedTaskExecution.getExitMessage(), expectedTaskExecution.getErrorMessage());
}
}

View File

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

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>());
startTime, null, null, new ArrayList<String>(), 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>());
startTime, endTime, exitMessage, new ArrayList<String>(), null);
}
/**
@@ -117,7 +117,6 @@ public class TestVerifierUtils {
* @return
*/
public static TaskExecution createSampleTaskExecution(long executionId) {
Random randomGenerator = new Random();
Date startTime = new Date();
String taskName = UUID.randomUUID().toString();
List<String> args = new ArrayList<>(ARG_SIZE);
@@ -125,7 +124,7 @@ public class TestVerifierUtils {
args.add(UUID.randomUUID().toString());
}
return new TaskExecution(executionId, null, taskName,
startTime, null, null, args);
startTime, null, null, args, null);
}
/**
@@ -153,6 +152,9 @@ public class TestVerifierUtils {
assertEquals("exitMessage must be equal",
expectedTaskExecution.getExitMessage(),
actualTaskExecution.getExitMessage());
assertEquals("errorMessage must be equal",
expectedTaskExecution.getErrorMessage(),
actualTaskExecution.getErrorMessage());
if (expectedTaskExecution.getArguments() != null) {
assertNotNull("arguments should not be null",
actualTaskExecution.getArguments());