use of org.wso2.carbon.logging.view.stub.LogViewerLogViewerException in project product-iots by wso2.
the class SampleInstallationTest method serverRestartTest.
@Test(description = "Test restarting the server", groups = Constants.TestSample.SAMPLE_INSTALL, dependsOnMethods = { "sampleInstallationTest" })
public void serverRestartTest() {
ServerConfigurationManager serverManager;
try {
serverManager = new ServerConfigurationManager(automationContext);
log.info("Restart Triggered -------------------------------------------------------------------");
serverManager.restartGracefully();
logViewerClient.getAllRemoteSystemLogs();
waitForRestart();
} catch (AutomationUtilException | XPathExpressionException | MalformedURLException e) {
log.error("Restart failed due to : " + e.getLocalizedMessage());
} catch (RemoteException | LogViewerLogViewerException e) {
log.error("Cannot get server log due to : " + e.getLocalizedMessage());
}
}
use of org.wso2.carbon.logging.view.stub.LogViewerLogViewerException 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