Exit code is nullable

- Make exit code nullable and only update of execution status can make it a valid integer
 - Update JDBC create/start task execution queries to have exitCode as `null` values
 - Update tests to validate/verify the appropirate exit code values for create/start/complete task executions

On merge had to add a pause to the TaskLauncherSinkTests to wait for the task to complete successfully   Before we assumed that 0 was a satisfactory result meaning it was either running or completed.    Now with the null being returned it could be zero or null.  So we have to wait for the task to complete.
This commit is contained in:
Ilayaperumal Gopinathan
2018-10-22 15:38:30 +05:30
committed by Glenn Renfro
parent 219aa2741f
commit cf3a0dce8c
9 changed files with 49 additions and 17 deletions

View File

@@ -65,8 +65,8 @@ public class TaskLauncherSinkTests {
private final static int WAIT_INTERVAL = 500;
private final static int MAX_WAIT_TIME = 10000;
private final static String URL = "maven://io.spring.cloud:"
+ "timestamp-task:jar:1.0.0.RC1";
private final static String URL = "maven://org.springframework.cloud.task.app:"
+ "timestamp-task:jar:1.3.0.RELEASE";
private final static String DATASOURCE_URL;
private final static String DATASOURCE_USER_NAME = "SA";
private final static String DATASOURCE_USER_PASSWORD = "''";
@@ -128,8 +128,8 @@ public class TaskLauncherSinkTests {
assertTrue(waitForDBToBePopulated());
Page<TaskExecution> taskExecutions = taskExplorer.findAll(PageRequest.of(0, 10));
TaskExecution te = taskExecutions.iterator().next();
assertEquals("Only one row is expected", 1, taskExecutions.getTotalElements());
assertTrue(waitForTaskToComplete());
assertEquals("return code should be 0", 0, taskExecutions.iterator().next().getExitCode().intValue());
}
@@ -156,6 +156,19 @@ public class TaskLauncherSinkTests {
return isDbPopulated;
}
private boolean waitForTaskToComplete() throws Exception {
boolean istTaskComplete = false;
for (int waitTime = 0; waitTime <= MAX_WAIT_TIME; waitTime += WAIT_INTERVAL) {
Thread.sleep(WAIT_INTERVAL);
TaskExecution taskExecution = taskExplorer.getTaskExecution(1);
if (taskExecution.getExitCode() != null) {
istTaskComplete = true;
break;
}
}
return istTaskComplete;
}
private void launchTask(String artifactURL) {
TaskLaunchRequest request = new TaskLaunchRequest(artifactURL, null,