@Override public void killThroughClientApi() { Properties props = new Properties(); props.put("com.enioka.jqm.jdbc.contextobject", Helpers.getDb()); JqmClientFactory.getClient("uncached", props, false).killJob(this.ji.getId()); }
@Override public void killThroughClientApi() { Properties props = new Properties(); props.put("com.enioka.jqm.jdbc.contextobject", Helpers.getDb()); JqmClientFactory.getClient("uncached", props, false).killJob(this.ji.getId()); }
JqmClientFactory.getClient().killJob(jobId);
JqmClientFactory.getClient().killJob(jobId);
@Test public void testJmxLeak() throws Exception { int i = JqmSimpleTest.create(cnx, "pyl.EngineJmxLeak").addWaitTime(10000).expectOk(0).run(this); MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); ObjectName name = new ObjectName("com.test:type=Node,name=test"); mbs.getAttribute(name, "One"); // Stop the job. Its MBean(s) should be cleaned up by the engine. JqmClientFactory.getClient().killJob(i); TestHelpers.waitFor(1, 3000, cnx); // Check the bean is really dead try { mbs.getAttribute(name, "One"); Assert.fail(); } catch (InstanceNotFoundException e) { // It's OK! } } }
@Test public void testKillJob() throws Exception { int i = JqmSimpleTest.create(cnx, "pyl.KillMe").expectOk(0).addWaitTime(3000).run(this); JqmClientFactory.getClient().killJob(i); TestHelpers.waitFor(1, 3000, cnx); List<JobInstance> res = Query.create().run(); Assert.assertEquals(1, res.size()); Assert.assertEquals(State.CRASHED, res.get(0).getState()); }
@Test public void testHighlanderEngineRunning() throws Exception { // This test launches an infinite loop as Highlander, checks if no other job can launch. Job is killed at the end - which allows a // second one to run, which also has to be killed. CreationTools.createJobDef(null, true, "pyl.KillMe", null, "jqm-tests/jqm-test-pyl/target/test.jar", TestHelpers.qVip, 42, "kill", null, "Franquin", "ModuleMachin", "other", "other", true, cnx); addAndStartEngine(); int firstJob = JobRequest.create("kill", "TestUser").submit(); for (int i = 0; i < 100; i++) { JobRequest.create("kill", "TestUser").submit(); } Thread.sleep(3000); Calendar killTime1 = Calendar.getInstance(); JqmClientFactory.getClient().killJob(firstJob); Thread.sleep(3000); JqmClientFactory.getClient().killJob(JqmClientFactory.getClient().getUserActiveJobs("TestUser").get(0).getId()); TestHelpers.waitFor(2, 10000, cnx); List<com.enioka.jqm.api.JobInstance> res = Query.create().addSortAsc(Sort.ID).run(); Assert.assertEquals(2, res.size()); Assert.assertEquals(State.CRASHED, res.get(0).getState()); Assert.assertEquals(State.CRASHED, res.get(1).getState()); Assert.assertTrue(killTime1.compareTo(res.get(1).getBeganRunningDate()) <= 0); }
.addStatusFilter(com.enioka.jqm.api.State.SUBMITTED).run().size()); JqmClientFactory.getClient().killJob(i1); JqmClientFactory.getClient().killJob(i2); .addStatusFilter(com.enioka.jqm.api.State.SUBMITTED).run().size()); JqmClientFactory.getClient().killJob(i3); JqmClientFactory.getClient().killJob(i4); JqmClientFactory.getClient().killJob(i5);
@Test public void testKill() { if (onWindows()) { // We explicitely start a sub shell here so as to have a process tree powershell-> powershell. CreationTools.createJobDef("test job", true, "none", new HashMap<>(), "powershell.exe -Command 'Start-Sleep 3600'", TestHelpers.qNormal, 0, "TestApp1", null, "module1", "kw1", "kw2", null, false, cnx, null, false, null, false, PathType.POWERSHELLCOMMAND); } else { // For Linux, sleep is a process, not a command, so we have a shell->sleep tree. CreationTools.createJobDef("test job", true, "none", new HashMap<>(), "sleep 3600", TestHelpers.qNormal, 0, "TestApp1", null, "module1", "kw1", "kw2", null, false, cnx, null, false, null, false, PathType.DEFAULTSHELLCOMMAND); } int i = JobRequest.create("TestApp1", "TestUser").submit(); Helpers.setSingleParam("internalPollingPeriodMs", "500", cnx); addAndStartEngine(); TestHelpers.waitForRunning(1, 20000, cnx); JqmClientFactory.getClient().killJob(i); TestHelpers.waitFor(1, 20000, cnx); Assert.assertEquals(0, TestHelpers.getOkCount(cnx)); Assert.assertEquals(1, TestHelpers.getNonOkCount(cnx)); }
@Test public void testExternalKill() throws Exception { Helpers.setSingleParam("internalPollingPeriodMs", "100", cnx); int i = JqmSimpleTest.create(cnx, "pyl.KillMeNot").setExternal().expectNonOk(0).expectOk(0).run(this); TestHelpers.waitForRunning(1, 20000, cnx); JqmClientFactory.getClient().killJob(i); TestHelpers.waitFor(1, 20000, cnx); Assert.assertEquals(0, TestHelpers.getOkCount(cnx)); Assert.assertEquals(1, TestHelpers.getNonOkCount(cnx)); } }
JqmClientFactory.getClient().killJob(running.get(0).getId()); TestHelpers.waitFor(1, 10000, cnx); TestHelpers.waitForRunning(3, 10000, cnx); JqmClientFactory.getClient().killJob(running.get(0).getId()); JqmClientFactory.getClient().killJob(running.get(1).getId()); JqmClientFactory.getClient().killJob(running.get(2).getId());
@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); }