use of org.wso2.carbon.logging.view.stub.types.carbon.LogEvent in project product-iots by wso2.
the class SampleInstallationTest method waitForRestart.
/**
* Wait until the server restarts.
* This method looks for "Mgt console URL:" to be appeared in the terminal.
* If it does not appear within the given timeout an Exception will be thrown.
*/
private void waitForRestart() {
ExecutorService service = Executors.newSingleThreadExecutor();
try {
Runnable r = new Runnable() {
@Override
public void run() {
try {
LogEvent[] logEvents = logViewerClient.getAllRemoteSystemLogs();
for (LogEvent event : logEvents) {
log.info(event.getMessage() + " @ " + event.getLogTime());
if (event.getMessage().contains("Mgt Console URL : ")) {
log.info("Server restarted successfully");
Assert.assertTrue(true);
}
}
} catch (RemoteException | LogViewerLogViewerException e) {
log.error("Error reading logs. \n" + e.getMessage());
Assert.assertTrue(false);
}
}
};
Future<?> f = service.submit(r);
f.get(Constants.IOT_RESTART_THREAD_TIMEOUT, TimeUnit.MINUTES);
} catch (final InterruptedException e) {
log.error("Interrupted " + e.getMessage());
Assert.assertTrue(false);
} catch (final TimeoutException e) {
log.error("Timeout " + e.getMessage());
Assert.assertTrue(false);
} catch (final ExecutionException e) {
log.error("Execution failed " + e.getMessage());
Assert.assertTrue(false);
} finally {
service.shutdown();
}
}
Aggregations