boolean running = operator.getSummary(exec1).contains("STARTED") && operator.getSummary(exec2).contains("STARTED"); running = operator.getSummary(exec1).contains("STARTED") && operator.getSummary(exec2).contains("STARTED"); assertTrue(String.format("Jobs not started: [%s] and [%s]", operator.getSummary(exec1), operator .getSummary(exec1)), running);
/** * @param executionId id of running job execution */ private void stopAndCheckStatus(long executionId) throws Exception { // wait to the job to get up and running Thread.sleep(1000); Set<Long> runningExecutions = operator.getRunningExecutions(job.getName()); assertTrue("Wrong executions: " + runningExecutions + " expected: " + executionId, runningExecutions .contains(executionId)); assertTrue("Wrong summary: " + operator.getSummary(executionId), operator.getSummary(executionId).contains( BatchStatus.STARTED.toString())); operator.stop(executionId); int count = 0; while (operator.getRunningExecutions(job.getName()).contains(executionId) && count <= 10) { LOG.info("Checking for running JobExecution: count=" + count); Thread.sleep(100); count++; } runningExecutions = operator.getRunningExecutions(job.getName()); assertFalse("Wrong executions: " + runningExecutions + " expected: " + executionId, runningExecutions .contains(executionId)); assertTrue("Wrong summary: " + operator.getSummary(executionId), operator.getSummary(executionId).contains( BatchStatus.STOPPED.toString())); // there is just a single step in the test job Map<Long, String> summaries = operator.getStepExecutionSummaries(executionId); LOG.info(summaries); assertTrue(summaries.values().toString().contains(BatchStatus.STOPPED.toString())); }
@Test public void testPauseJob() throws Exception { final int SLEEP_INTERVAL = 600; assertTrue(isConnected()); assertTrue(launcher.getJobNames().contains("loopJob")); long executionId = launcher.start("loopJob", ""); // sleep long enough to avoid race conditions (serializable tx isolation // doesn't work with HSQL) Thread.sleep(SLEEP_INTERVAL); launcher.stop(executionId); Thread.sleep(SLEEP_INTERVAL); logger.debug(launcher.getSummary(executionId)); long resumedId = launcher.restart(executionId); assertNotSame("Picked up the same execution after pause and resume", executionId, resumedId); Thread.sleep(SLEEP_INTERVAL); launcher.stop(resumedId); Thread.sleep(SLEEP_INTERVAL); logger.debug(launcher.getSummary(resumedId)); long resumeId2 = launcher.restart(resumedId); assertNotSame("Picked up the same execution after pause and resume", executionId, resumeId2); Thread.sleep(SLEEP_INTERVAL); launcher.stop(resumeId2); }