@Test(groups="Integration") public void testNonRunningPidRequired() { ProcessTaskWrapper<?> t = submit(SshEffectorTasks.requirePidRunning(99999)); setExpectingFailure(); try { t.getTask().getUnchecked(); } catch (Exception e) { log.info("The error if required PID is not found is: "+e); clearExpectedFailure(); Assert.assertTrue(e.toString().contains("Process with PID"), "Expected nice clue in error but got: "+e); } checkExpectedFailure(); }
protected void checkIsRunningAndStops(Entity mysql, SshMachineLocation lh) { Integer pid = getPid(mysql); Assert.assertNotNull(pid, "PID should be set as an attribute (or getPid() overridden to supply)"); Entities.submit(app, SshEffectorTasks.requirePidRunning(pid).machine(lh).newTask() ).get(); app.stop(); // let the kill -1 take effect Time.sleep(Duration.ONE_SECOND); // and assert it has died log.info("mysql in pid "+pid+" should be dead now"); // (app has stopped, so submit on mgmt context) ProcessTaskWrapper<Integer> t = SshEffectorTasks.codePidRunning(pid).machine(lh).newTask(); mgmt.getExecutionManager().submit(t); Assert.assertNotEquals(t.block().getExitCode(), 0); } }