@Test
public void testBatchFlow() 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);
List<String> executedSteps = new ArrayList<>();
for (StepExecution stepExecution : stepExecutions) {
executedSteps.add(stepExecution.getStepName());
if (stepExecution.getStepName().equals("step2")) {
Map<Metric.MetricType, Long> metricsMap = BatchTestHelper.getMetricsMap(stepExecution.getMetrics());
System.out.println(metricsMap);
assertEquals(5L, metricsMap.get(Metric.MetricType.READ_COUNT).longValue());
assertEquals(5L, metricsMap.get(Metric.MetricType.WRITE_COUNT).longValue());
assertEquals(5L / 3 + (5 % 3 > 0 ? 1 : 0), metricsMap.get(Metric.MetricType.COMMIT_COUNT).longValue());
}
}
(1)
assertEquals(3, stepExecutions.size());
(2)
assertArrayEquals(new String[]{"step1", "step2", "step3"}, executedSteps.toArray());
(3)
assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus());
}