Search in sources :

Example 1 with LogViewerLogViewerException

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());
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) ServerConfigurationManager(org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager) XPathExpressionException(javax.xml.xpath.XPathExpressionException) LogViewerLogViewerException(org.wso2.carbon.logging.view.stub.LogViewerLogViewerException) RemoteException(java.rmi.RemoteException) AutomationUtilException(org.wso2.carbon.integration.common.utils.exceptions.AutomationUtilException) Test(org.testng.annotations.Test)

Example 2 with LogViewerLogViewerException

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();
    }
}
Also used : LogEvent(org.wso2.carbon.logging.view.stub.types.carbon.LogEvent) LogViewerLogViewerException(org.wso2.carbon.logging.view.stub.LogViewerLogViewerException) ExecutorService(java.util.concurrent.ExecutorService) RemoteException(java.rmi.RemoteException) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

RemoteException (java.rmi.RemoteException)2 LogViewerLogViewerException (org.wso2.carbon.logging.view.stub.LogViewerLogViewerException)2 MalformedURLException (java.net.MalformedURLException)1 ExecutionException (java.util.concurrent.ExecutionException)1 ExecutorService (java.util.concurrent.ExecutorService)1 TimeoutException (java.util.concurrent.TimeoutException)1 XPathExpressionException (javax.xml.xpath.XPathExpressionException)1 Test (org.testng.annotations.Test)1 AutomationUtilException (org.wso2.carbon.integration.common.utils.exceptions.AutomationUtilException)1 ServerConfigurationManager (org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager)1 LogEvent (org.wso2.carbon.logging.view.stub.types.carbon.LogEvent)1