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");
}
}
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");
}
}
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");
}
Aggregations