Fix build - wrong assumption about expected rollbacks

This commit is contained in:
Dave Syer
2011-03-22 09:10:10 +00:00
parent 571c7fc801
commit 87c7671faa

View File

@@ -88,15 +88,25 @@ public class FootballJobSkipIntegrationTests {
for (StepExecution stepExecution : execution.getStepExecutions()) {
logger.info("Processed: " + stepExecution);
}
// They all skip on the second execution because of a primary key violation
execution = jobLauncher.run(job, new JobParametersBuilder().addLong("skip.limit", 100000L).addLong("retry.limit", 2L)
.toJobParameters());
// They all skip on the second execution because of a primary key
// violation
long retryLimit = 2L;
execution = jobLauncher.run(job,
new JobParametersBuilder().addLong("skip.limit", 100000L).addLong("retry.limit", retryLimit)
.toJobParameters());
assertEquals(BatchStatus.COMPLETED, execution.getStatus());
for (StepExecution stepExecution : execution.getStepExecutions()) {
logger.info("Processed: " + stepExecution);
if (stepExecution.getStepName().equals("playerload")) {
// The effect of the retries
assertEquals(stepExecution.getReadCount()*2, stepExecution.getRollbackCount());
// The effect of the retries is to increase the number of
// rollbacks
int commitInterval = stepExecution.getReadCount() / (stepExecution.getCommitCount() - 1);
// Account for the extra empty commit if the read count is
// commensurate with the commit interval
int effectiveCommitCount = stepExecution.getReadCount() % commitInterval == 0 ? stepExecution
.getCommitCount() - 1 : stepExecution.getCommitCount();
long expectedRollbacks = Math.max(1, retryLimit) * effectiveCommitCount + stepExecution.getReadCount();
assertEquals(expectedRollbacks, stepExecution.getRollbackCount());
assertEquals(stepExecution.getReadCount(), stepExecution.getWriteSkipCount());
}
}