@Test(priority = 3) public void testUpdateJobInstance() { SchedulerJobInstanceHandle handle = instances.keySet().iterator().next(); SchedulerJobInstanceInfo info = instances.get(handle); SchedulerJobInstanceRun run = info.getInstanceRunList().get(0); run.setInstanceState(SchedulerJobInstanceState.LAUNCHED); schedulerDAO.updateJobInstanceRun(run); // Get the instance Assert.assertEquals(schedulerDAO.getSchedulerJobInstanceInfo(handle), info); }
@Test(priority = 2) public void testStoreInstance() throws Exception { long currentTime = System.currentTimeMillis(); SchedulerJobInstanceHandle instanceHandle = new SchedulerJobInstanceHandle(UUID.randomUUID()); SchedulerJobInstanceInfo firstInstance = new SchedulerJobInstanceInfo( instanceHandle, jobHandle, currentTime, new ArrayList<SchedulerJobInstanceRun>()); SchedulerJobInstanceRun run1 = new SchedulerJobInstanceRun( instanceHandle, 1, new LensSessionHandle(UUID.randomUUID(), UUID.randomUUID()), currentTime, currentTime, "/tmp/", QueryHandle.fromString(UUID.randomUUID().toString()), SchedulerJobInstanceState.WAITING); instances.put(firstInstance.getId(), firstInstance); schedulerDAO.storeJobInstance(firstInstance); schedulerDAO.storeJobInstanceRun(run1); // Put run in the instance firstInstance.getInstanceRunList().add(run1); currentTime = System.currentTimeMillis(); instanceHandle = new SchedulerJobInstanceHandle(UUID.randomUUID()); SchedulerJobInstanceInfo secondInstance = new SchedulerJobInstanceInfo( instanceHandle, jobHandle, currentTime, new ArrayList<SchedulerJobInstanceRun>()); SchedulerJobInstanceRun run2 = new SchedulerJobInstanceRun( instanceHandle, 1, new LensSessionHandle(UUID.randomUUID(), UUID.randomUUID()), currentTime, currentTime, "/tmp/", QueryHandle.fromString(UUID.randomUUID().toString()), SchedulerJobInstanceState.WAITING); instances.put(secondInstance.getId(), secondInstance); schedulerDAO.storeJobInstance(secondInstance); schedulerDAO.storeJobInstanceRun(run2); secondInstance.getInstanceRunList().add(run2); List<SchedulerJobInstanceInfo> handleList = schedulerDAO.getJobInstances(jobHandle); // Size should be 2 Assert.assertEquals(handleList.size(), 2); // Get the definition of instance from the store. SchedulerJobInstanceInfo instance1 = handleList.get(0); Assert.assertEquals(instances.get(handleList.get(0).getId()), instance1); SchedulerJobInstanceInfo instance2 = handleList.get(1); Assert.assertEquals(instances.get(handleList.get(1).getId()), instance2); }