@Test(expected = JqmInvalidRequestException.class) public void testPriorityLimits() { int qId = Queue.create(cnx, "testqueue", " ", false); DeploymentParameter.create(cnx, TestHelpers.node.getId(), 1, 1, qId); CreationTools.createJobDef(null, true, "pyl.Wait", null, "jqm-tests/jqm-test-pyl-nodep/target/test.jar", qId, 42, "jqm-test-wait", null, "Franquin", "ModuleMachin", "other", "other", false, cnx); cnx.commit(); // No priority = FIFO queue. JobRequest.create("jqm-test-wait", "test").addParameter("ms", "100").setPriority(Integer.MAX_VALUE).submit(); }
@Test public void testRmParameterCleanup() throws Exception { // Single thread available. int qId = Queue.create(cnx, "testqueue", " ", false); DeploymentParameter.create(cnx, TestHelpers.node.getId(), 2, 1, qId); // 2 slots Map<String, String> prms = new HashMap<>(1); prms.put("com.enioka.jqm.rm.quantity.thread.consumption", "2"); prms.put("whatever", "value"); CreationTools.createJobDef(null, true, "pyl.MessagePerParameter", prms, "jqm-tests/jqm-test-pyl/target/test.jar", qId, 42, "jqm-test-kill", null, "Franquin", "ModuleMachin", "other", "other", false, cnx); cnx.commit(); int i1 = JobRequest.create("jqm-test-kill", "test").setPriority(null).submit(); addAndStartEngine(); TestHelpers.waitFor(1, 60000, cnx); // Check only one of the two JI has started (asking for total 3 slots, only 2 available) Assert.assertEquals(1, TestHelpers.getOkCount(cnx)); Assert.assertEquals(0, TestHelpers.getNonOkCount(cnx)); Assert.assertEquals(0, TestHelpers.getQueueRunningCount(cnx)); Assert.assertEquals(0, TestHelpers.getQueueAllCount(cnx)); // Check the parameter wazs removed by the RM JobInstance ji = JqmClientFactory.getClient().getJob(i1); Assert.assertEquals(1, ji.getMessages().size()); }
@Test public void testFifo() throws Exception { // Single thread available. int qId = Queue.create(cnx, "testqueue", " ", false); DeploymentParameter.create(cnx, TestHelpers.node.getId(), 1, 1, qId); CreationTools.createJobDef(null, true, "pyl.Wait", null, "jqm-tests/jqm-test-pyl-nodep/target/test.jar", qId, 42, "jqm-test-wait", null, "Franquin", "ModuleMachin", "other", "other", false, cnx); cnx.commit(); // No priority = FIFO queue. int i1 = JobRequest.create("jqm-test-wait", "test").addParameter("ms", "100").setPriority(null).submit(); int i2 = JobRequest.create("jqm-test-wait", "test").addParameter("ms", "100").setPriority(null).submit(); addAndStartEngine(); TestHelpers.waitFor(2, 60000, cnx); Assert.assertEquals(2, TestHelpers.getOkCount(cnx)); Assert.assertEquals(0, TestHelpers.getNonOkCount(cnx)); Assert.assertEquals(0, TestHelpers.getQueueRunningCount(cnx)); JobInstance ji1 = Query.create().setJobInstanceId(i1).run().get(0); JobInstance ji2 = Query.create().setJobInstanceId(i2).run().get(0); Assert.assertTrue(ji1.getBeganRunningDate().compareTo(ji2.getEndDate()) <= 0); }
@Test public void testTakingMultipleResources() throws Exception { // Single thread available. int qId = Queue.create(cnx, "testqueue", " ", false); DeploymentParameter.create(cnx, TestHelpers.node.getId(), 2, 1, qId); // 2 slots Map<String, String> prms = new HashMap<>(1); prms.put("com.enioka.jqm.rm.quantity.thread.consumption", "2"); // using fully qualified RM with RM name 'thread' - not the generic // key CreationTools.createJobDef(null, true, "pyl.Wait", prms, "jqm-tests/jqm-test-pyl-nodep/target/test.jar", qId, 42, "jqm-test-wait-dual", null, "Franquin", "ModuleMachin", "other", "other", false, cnx); CreationTools.createJobDef(null, true, "pyl.Wait", null, "jqm-tests/jqm-test-pyl-nodep/target/test.jar", qId, 42, "jqm-test-wait-single", null, "Franquin", "ModuleMachin", "other", "other", false, cnx); cnx.commit(); int i1 = JobRequest.create("jqm-test-wait-single", "test").setPriority(null).submit(); int i2 = JobRequest.create("jqm-test-wait-dual", "test").setPriority(null).submit(); addAndStartEngine(); TestHelpers.waitForRunning(1, 60000, cnx); sleep(1); // Time to start another if case of bug... // Check only one of the two JI has started (asking for total 3 slots, only 2 available) Assert.assertEquals(0, TestHelpers.getOkCount(cnx)); Assert.assertEquals(0, TestHelpers.getNonOkCount(cnx)); Assert.assertEquals(1, TestHelpers.getQueueRunningCount(cnx)); Assert.assertEquals(2, TestHelpers.getQueueAllCount(cnx)); // Cleanup JqmClientFactory.getClient().killJob(i1); JqmClientFactory.getClient().killJob(i2); TestHelpers.waitFor(2, 1000, cnx); }
int i3 = JobRequest.create("MarsuApplication", "TestUser").setPriority(3).setRecurrence("* * * * *").submit();
@Test public void testPriority() throws Exception { // Single thread available. int qId = Queue.create(cnx, "testqueue", " ", false); DeploymentParameter.create(cnx, TestHelpers.node.getId(), 1, 1, qId); CreationTools.createJobDef(null, true, "pyl.Wait", null, "jqm-tests/jqm-test-pyl-nodep/target/test.jar", qId, 42, "jqm-test-wait", null, "Franquin", "ModuleMachin", "other", "other", false, cnx); cnx.commit(); // Enqueue a low priority first, then a higher priority one. The higher priority should run first. int i1 = JobRequest.create("jqm-test-wait", "test").addParameter("ms", "100").setPriority(1).submit(); int i2 = JobRequest.create("jqm-test-wait", "test").addParameter("ms", "100").setPriority(6).submit(); addAndStartEngine(); TestHelpers.waitFor(2, 60000, cnx); Assert.assertEquals(2, TestHelpers.getOkCount(cnx)); Assert.assertEquals(0, TestHelpers.getNonOkCount(cnx)); Assert.assertEquals(0, TestHelpers.getQueueRunningCount(cnx)); JobInstance ji1 = Query.create().setJobInstanceId(i1).run().get(0); JobInstance ji2 = Query.create().setJobInstanceId(i2).run().get(0); Assert.assertEquals(1, (int) ji1.getPriority()); Assert.assertEquals(6, (int) ji2.getPriority()); Assert.assertTrue(ji1.getBeganRunningDate().compareTo(ji2.getEndDate()) >= 0); }
cnx.commit(); JobRequest.create("jqm-test-kill", "test").setPriority(null).submit(); JobRequest.create("jqm-test-kill", "test").setPriority(null).submit(); JobRequest.create("jqm-test-kill", "test").setPriority(null).submit();