@Test
public void testBatchChunkPartition() throws Exception {
JobOperator jobOperator = BatchRuntime.getJobOperator();
Long executionId = jobOperator.start("myJob", new Properties());
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
jobExecution = BatchTestHelper.keepTestAlive(jobExecution);
List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId);
for (StepExecution stepExecution : stepExecutions) {
if (stepExecution.getStepName().equals("myStep")) {
Map<Metric.MetricType, Long> metricsMap = BatchTestHelper.getMetricsMap(stepExecution.getMetrics());
(1)
assertEquals(20L, metricsMap.get(Metric.MetricType.READ_COUNT).longValue());
(2)
assertEquals(10L, metricsMap.get(Metric.MetricType.WRITE_COUNT).longValue());
// Number of elements by the item count value on myJob.xml, plus an additional transaction for the
// remaining elements by each partition.
long commitCount = (10L / 3 + (10 % 3 > 0 ? 1 : 0)) * 2;
(3)
assertEquals(commitCount, metricsMap.get(Metric.MetricType.COMMIT_COUNT).longValue());
}
}
(4)
assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus());
}