use of org.apache.kafka.trogdor.task.AgentWorkerStatusTracker in project kafka by apache.
the class ExternalCommandWorkerTest method testProcessWithNormalExit.
/**
* Test running a process which exits successfully-- in this case, /bin/true.
*/
@Test
public void testProcessWithNormalExit() throws Exception {
if (OperatingSystem.IS_WINDOWS)
return;
ExternalCommandWorker worker = new ExternalCommandWorkerBuilder("trueTask").command("true").build();
KafkaFutureImpl<String> doneFuture = new KafkaFutureImpl<>();
worker.start(null, new AgentWorkerStatusTracker(), doneFuture);
assertEquals("", doneFuture.get());
worker.stop(null);
}
use of org.apache.kafka.trogdor.task.AgentWorkerStatusTracker in project kafka by apache.
the class ExternalCommandWorkerTest method testProcessNotFound.
/**
* Test attempting to run an executable which doesn't exist.
* We use a path which starts with /dev/null, since that should never be a
* directory in UNIX.
*/
@Test
public void testProcessNotFound() throws Exception {
ExternalCommandWorker worker = new ExternalCommandWorkerBuilder("notFoundTask").command("/dev/null/non/existent/script/path").build();
KafkaFutureImpl<String> doneFuture = new KafkaFutureImpl<>();
worker.start(null, new AgentWorkerStatusTracker(), doneFuture);
String errorString = doneFuture.get();
assertTrue(errorString.startsWith("Unable to start process"));
worker.stop(null);
}
use of org.apache.kafka.trogdor.task.AgentWorkerStatusTracker in project kafka by apache.
the class ExternalCommandWorkerTest method testProcessStop.
/**
* Test running a process which times out. We will send it a SIGTERM.
*/
@Test
public void testProcessStop() throws Exception {
if (OperatingSystem.IS_WINDOWS)
return;
ExternalCommandWorker worker = new ExternalCommandWorkerBuilder("testStopTask").command("sleep", "3600000").build();
KafkaFutureImpl<String> doneFuture = new KafkaFutureImpl<>();
worker.start(null, new AgentWorkerStatusTracker(), doneFuture);
worker.stop(null);
// We don't check the numeric return code, since that will vary based on
// platform.
assertTrue(doneFuture.get().startsWith("exited with return code "));
}
use of org.apache.kafka.trogdor.task.AgentWorkerStatusTracker in project kafka by apache.
the class ExternalCommandWorkerTest method testProcessWithFailedExit.
/**
* Test running a process which exits unsuccessfully-- in this case, /bin/false.
*/
@Test
public void testProcessWithFailedExit() throws Exception {
if (OperatingSystem.IS_WINDOWS)
return;
ExternalCommandWorker worker = new ExternalCommandWorkerBuilder("falseTask").command("false").build();
KafkaFutureImpl<String> doneFuture = new KafkaFutureImpl<>();
worker.start(null, new AgentWorkerStatusTracker(), doneFuture);
assertEquals("exited with return code 1", doneFuture.get());
worker.stop(null);
}
Aggregations