Search in sources :

Example 1 with HeartbeatRemoteHome

use of org.jboss.as.test.clustering.cluster.ejb2.remote.bean.HeartbeatRemoteHome in project wildfly by wildfly.

the class SuspendResumeRemoteEJB2TestCase method testSuspendResumeAfterProxyInit.

/**
 * This test checks that suspending and then resuming the server during invocation results in correct behaviour
 * in the case that the proxy is created before the server is suspended.
 *
 * The test assertion is checked after each invocation result, and verifies that no invocation is sent to a suspended node.
 *
 * @throws Exception
 */
@Test
@InSequence(1)
public void testSuspendResumeAfterProxyInit() throws Exception {
    LOGGER.info("testSuspendResumeAfterProxyInit() - start");
    try (EJBDirectory directory = new RemoteEJBDirectory(MODULE_NAME)) {
        HeartbeatRemoteHome home = directory.lookupHome(SlowHeartbeatBean.class, HeartbeatRemoteHome.class);
        HeartbeatRemote bean = home.create();
        for (int i = 1; i < INVOCATION_LOOP_TIMES; i++) {
            performInvocation(bean);
        }
        suspendTheServer(NODE_1);
        for (int i = 1; i < INVOCATION_LOOP_TIMES; i++) {
            performInvocation(bean);
        }
        resumeTheServer(NODE_1);
        for (int i = 1; i < INVOCATION_LOOP_TIMES; i++) {
            performInvocation(bean);
        }
    } catch (Exception e) {
        LOGGER.info("Caught exception! e = " + e.getMessage());
        Assert.fail("Test failed with exception: e = " + e.getMessage());
    } finally {
        LOGGER.info("testSuspendResumeAfterProxyInit() - end");
    }
}
Also used : HeartbeatRemote(org.jboss.as.test.clustering.cluster.ejb2.remote.bean.HeartbeatRemote) RemoteEJBDirectory(org.jboss.as.test.clustering.ejb.RemoteEJBDirectory) RemoteEJBDirectory(org.jboss.as.test.clustering.ejb.RemoteEJBDirectory) EJBDirectory(org.jboss.as.test.clustering.ejb.EJBDirectory) IOException(java.io.IOException) HeartbeatRemoteHome(org.jboss.as.test.clustering.cluster.ejb2.remote.bean.HeartbeatRemoteHome) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 2 with HeartbeatRemoteHome

use of org.jboss.as.test.clustering.cluster.ejb2.remote.bean.HeartbeatRemoteHome in project wildfly by wildfly.

the class SuspendResumeRemoteEJB2TestCase method testSuspendResumeBeforeProxyInit.

/**
 * This test checks that suspending and then resuming the server during invocation results in correct behaviour
 * in the case that the proxy is created after the server is suspended.
 *
 *  The test assertion is checked after each invocation result, and verifies that no invocation is sent to a suspended node.
 *
 * @throws Exception
 */
@Test
@InSequence(2)
public void testSuspendResumeBeforeProxyInit() throws Exception {
    LOGGER.info("testSuspendResumeBeforeProxyInit() - start");
    try (EJBDirectory directory = new RemoteEJBDirectory(MODULE_NAME)) {
        suspendTheServer(NODE_1);
        HeartbeatRemoteHome home = directory.lookupHome(SlowHeartbeatBean.class, HeartbeatRemoteHome.class);
        HeartbeatRemote bean = home.create();
        for (int i = 1; i < INVOCATION_LOOP_TIMES; i++) {
            performInvocation(bean);
        }
        resumeTheServer(NODE_1);
        for (int i = 1; i < INVOCATION_LOOP_TIMES; i++) {
            performInvocation(bean);
        }
    } catch (Exception e) {
        LOGGER.info("Caught exception! e = " + e.getMessage());
        Assert.fail("Test failed with exception: e = " + e.getMessage());
    } finally {
        LOGGER.info("testSuspendResumeBeforeProxyInit() - end");
    }
}
Also used : HeartbeatRemote(org.jboss.as.test.clustering.cluster.ejb2.remote.bean.HeartbeatRemote) RemoteEJBDirectory(org.jboss.as.test.clustering.ejb.RemoteEJBDirectory) RemoteEJBDirectory(org.jboss.as.test.clustering.ejb.RemoteEJBDirectory) EJBDirectory(org.jboss.as.test.clustering.ejb.EJBDirectory) IOException(java.io.IOException) HeartbeatRemoteHome(org.jboss.as.test.clustering.cluster.ejb2.remote.bean.HeartbeatRemoteHome) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 3 with HeartbeatRemoteHome

use of org.jboss.as.test.clustering.cluster.ejb2.remote.bean.HeartbeatRemoteHome in project wildfly by wildfly.

the class SuspendResumeRemoteEJB2TestCase method testSuspendResumeContinuous.

/**
 * This test checks that suspending and then resuming the server during invocation results in correct behaviour
 * in the case that the proxy is created after the server is suspended.
 *
 * The test assertion is checked after each invocation result, and verifies that no invocation is sent to a suspended node.
 *
 * @throws Exception
 */
@Test
@InSequence(3)
public void testSuspendResumeContinuous() throws Exception {
    LOGGER.info("testSuspendResumeContinuous() - start");
    try (EJBDirectory directory = new RemoteEJBDirectory(MODULE_NAME)) {
        HeartbeatRemoteHome home = directory.lookupHome(SlowHeartbeatBean.class, HeartbeatRemoteHome.class);
        HeartbeatRemote bean = home.create();
        ContinuousInvoker continuousInvoker = new ContinuousInvoker(bean);
        Thread thread = new Thread(continuousInvoker);
        LOGGER.info("Starting the invoker ...");
        thread.start();
        for (int i = 0; i < SUSPEND_RESUME_LOOP_TIMES; i++) {
            // suspend and then resume each server in turn while invocations happen
            sleep(SUSPEND_RESUME_DURATION_MSECS);
            suspendTheServer(NODE_1);
            sleep(SUSPEND_RESUME_DURATION_MSECS);
            resumeTheServer(NODE_1);
            // suspend and then resume each server in turn while invocations happen
            sleep(SUSPEND_RESUME_DURATION_MSECS);
            suspendTheServer(NODE_2);
            sleep(SUSPEND_RESUME_DURATION_MSECS);
            resumeTheServer(NODE_2);
        }
        continuousInvoker.stopInvoking();
    } catch (Exception e) {
        LOGGER.info("Caught exception! e = " + e.getMessage());
        Assert.fail("Test failed with exception: e = " + e.getMessage());
    }
    LOGGER.info("testSuspendResumeContinuous() - end");
}
Also used : HeartbeatRemote(org.jboss.as.test.clustering.cluster.ejb2.remote.bean.HeartbeatRemote) RemoteEJBDirectory(org.jboss.as.test.clustering.ejb.RemoteEJBDirectory) RemoteEJBDirectory(org.jboss.as.test.clustering.ejb.RemoteEJBDirectory) EJBDirectory(org.jboss.as.test.clustering.ejb.EJBDirectory) IOException(java.io.IOException) HeartbeatRemoteHome(org.jboss.as.test.clustering.cluster.ejb2.remote.bean.HeartbeatRemoteHome) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Aggregations

IOException (java.io.IOException)3 InSequence (org.jboss.arquillian.junit.InSequence)3 HeartbeatRemote (org.jboss.as.test.clustering.cluster.ejb2.remote.bean.HeartbeatRemote)3 HeartbeatRemoteHome (org.jboss.as.test.clustering.cluster.ejb2.remote.bean.HeartbeatRemoteHome)3 EJBDirectory (org.jboss.as.test.clustering.ejb.EJBDirectory)3 RemoteEJBDirectory (org.jboss.as.test.clustering.ejb.RemoteEJBDirectory)3 Test (org.junit.Test)3