// Make sure still only one app is running
Iterable<TwillRunner.LiveInfo> apps = runner.lookupLive();
Assert.assertTrue(YarnTestUtils.waitForSize(apps, 1, 60));
// Creates a new runner service to check it can regain control over running app.
TwillRunnerService runnerService = YarnTestUtils.createTwillRunnerService(tmpFolder.newFolder());
runnerService.startAndWait();
try {
Iterable <TwillController> controllers = runnerService.lookup("EchoServer");
Assert.assertTrue(YarnTestUtils.waitForSize(controllers, 1, 60));
for (TwillController c : controllers) {
LOG.info("Stopping application: " + c.getRunId());
c.stop().get(30, TimeUnit.SECONDS);
}
Assert.assertTrue(YarnTestUtils.waitForSize(apps, 0, 60));
} finally {
runnerService.stopAndWait();
}
// Sleep a bit before exiting.
TimeUnit.SECONDS.sleep(2);
}