Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide method for stopping Batch 5 Jobs upon user request #5990

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<module>spring-cloud-dataflow-shell</module>
<module>spring-cloud-dataflow-shell-core</module>
<module>spring-cloud-dataflow-completion</module>
<module>spring-cloud-skipper</module>
<!-- <module>spring-cloud-skipper</module>-->
onobc marked this conversation as resolved.
Show resolved Hide resolved
<module>spring-cloud-starter-dataflow-server</module>
<module>spring-cloud-starter-dataflow-ui</module>
<module>spring-cloud-dataflow-server</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,25 +193,25 @@ void exceptionsShouldBeThrownIfRequestForNonExistingJobInstance() {

@Test
void stoppingJobExecutionShouldLeaveJobExecutionWithStatusOfStopping() throws Exception {
JobExecution jobExecution = createJobExecution(BASE_JOB_INST_NAME,true);
JobExecution jobExecution = createRunningJobExecution(BASE_JOB_INST_NAME);
jobService.stop(jobExecution.getId());
assertJobHasStopped(jobExecution);
}

@Test
void stoppingAllJobExecutionsShouldLeaveJobExecutionsWithStatusOfStopping() throws Exception {
JobExecution jobExecutionOne = createJobExecution(BASE_JOB_INST_NAME,true);
JobExecution jobExecutionTwo = createJobExecution(BASE_JOB_INST_NAME+"_TWO",true);
JobExecution jobExecutionOne = createRunningJobExecution(BASE_JOB_INST_NAME);
JobExecution jobExecutionTwo = createRunningJobExecution(BASE_JOB_INST_NAME+"_TWO");
jobService.stop(jobExecutionOne.getId());
assertJobHasStopped(jobExecutionOne);
jobService.stop(jobExecutionTwo.getId());
assertJobHasStopped(jobExecutionTwo);
}

private void assertJobHasStopped(JobExecution jobExecution) throws NoSuchJobExecutionException, JobExecutionNotRunningException {
jobExecution = jobService.getJobExecution(jobExecution.getId());
assertThat(jobExecution.isRunning()).isTrue();
assertThat(jobExecution.getStatus()).isNotEqualTo(BatchStatus.STOPPING);
jobService.stop(jobExecution.getId());
jobExecution = jobService.getJobExecution(jobExecution.getId());
assertThat(jobExecution.getStatus()).isEqualTo(BatchStatus.STOPPING);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we wait for STOPPED as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

STOPPED only occurs once the batch job has completed. In this test we are just testing that SCDF sets the state to STOPPING. We are not running real jobs here, just creating / modifying the state of the JobExecution.

assertThat(jobExecution.isRunning()).isTrue();
}

private void verifyJobInstance(long id, String name) throws Exception {
Expand All @@ -235,9 +235,13 @@ private JobExecution createJobExecution(String name) throws Exception {
return createJobExecution(name, BatchStatus.STARTING, false);
}

private JobExecution createJobExecution(String name, boolean isRunning)
private JobExecution createRunningJobExecution(String name)
throws Exception {
return createJobExecution(name, BatchStatus.STARTING, isRunning);
JobExecution jobExecution = createJobExecution(name, BatchStatus.STARTING, true);
jobExecution = jobService.getJobExecution(jobExecution.getId());
assertThat(jobExecution.isRunning()).isTrue();
assertThat(jobExecution.getStatus()).isNotEqualTo(BatchStatus.STOPPING);
return jobExecution;
}

private JobExecution createJobExecution(String name, BatchStatus batchStatus, boolean isRunning) throws Exception {
Expand Down
Loading