use of org.apache.activemq.artemis.tests.unit.util.InVMNamingContext in project activemq-artemis by apache.
the class StartStopDeadlockTest method testDeadlock.
/*
* simple test to make sure connect still works with some network latency built into netty
* */
@Test
@BMRules(rules = { @BMRule(name = "Server.start wait-init", targetClass = "org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl", targetMethod = "initialisePart2", targetLocation = "ENTRY", condition = "incrementCounter(\"server-Init\") == 2", action = "System.out.println(\"server backup init\"), waitFor(\"start-init\")"), @BMRule(name = "JMSServer.stop wait-init", targetClass = "org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl", targetMethod = "stop", targetLocation = "ENTRY", action = "signalWake(\"start-init\", true)"), @BMRule(name = "StartStopDeadlockTest tearDown", targetClass = "org.apache.activemq.artemis.tests.extras.byteman.StartStopDeadlockTest", targetMethod = "tearDown", targetLocation = "ENTRY", action = "deleteCounter(\"server-Init\")") })
public void testDeadlock() throws Exception {
// A live server that will always be crashed
Configuration confLive = createDefaultNettyConfig().setHAPolicyConfiguration(new SharedStoreMasterPolicyConfiguration());
final ActiveMQServer serverLive = addServer(ActiveMQServers.newActiveMQServer(confLive));
serverLive.start();
// A backup that will be waiting to be activated
Configuration config = createDefaultNettyConfig().setHAPolicyConfiguration(new SharedStoreSlavePolicyConfiguration());
final ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(config, true));
final JMSServerManagerImpl jmsServer = new JMSServerManagerImpl(server);
final InVMNamingContext context = new InVMNamingContext();
jmsServer.setRegistry(new JndiBindingRegistry(context));
jmsServer.start();
final AtomicInteger errors = new AtomicInteger(0);
final CountDownLatch align = new CountDownLatch(2);
final CountDownLatch startLatch = new CountDownLatch(1);
Thread tCrasher = new Thread("tStart") {
@Override
public void run() {
try {
align.countDown();
startLatch.await();
System.out.println("Crashing....");
serverLive.fail(true);
} catch (Exception e) {
errors.incrementAndGet();
e.printStackTrace();
}
}
};
Thread tStop = new Thread("tStop") {
@Override
public void run() {
try {
align.countDown();
startLatch.await();
jmsServer.stop();
} catch (Exception e) {
errors.incrementAndGet();
e.printStackTrace();
}
}
};
tCrasher.start();
tStop.start();
align.await();
startLatch.countDown();
tCrasher.join();
tStop.join();
assertEquals(0, errors.get());
}
use of org.apache.activemq.artemis.tests.unit.util.InVMNamingContext in project activemq-artemis by apache.
the class BridgeTestBase method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
// Start the servers
Configuration conf0 = createBasicConfig().setJournalDirectory(getJournalDir(0, false)).setBindingsDirectory(getBindingsDir(0, false)).addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY));
server0 = addServer(ActiveMQServers.newActiveMQServer(conf0, false));
context0 = new InVMNamingContext();
jmsServer0 = new JMSServerManagerImpl(server0);
jmsServer0.setRegistry(new JndiBindingRegistry(context0));
jmsServer0.start();
params1 = new HashMap<>();
params1.put(TransportConstants.SERVER_ID_PROP_NAME, 1);
Configuration conf1 = createBasicConfig().setJournalDirectory(getJournalDir(1, false)).setBindingsDirectory(getBindingsDir(1, false)).addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY, params1));
server1 = addServer(ActiveMQServers.newActiveMQServer(conf1, false));
context1 = new InVMNamingContext();
jmsServer1 = new JMSServerManagerImpl(server1);
jmsServer1.setRegistry(new JndiBindingRegistry(context1));
jmsServer1.start();
createQueue("sourceQueue", 0);
jmsServer0.createTopic(false, "sourceTopic", "/topic/sourceTopic");
createQueue("localTargetQueue", 0);
createQueue("targetQueue", 1);
setUpAdministeredObjects();
TxControl.enable();
// We need a local transaction and recovery manager
// We must start this after the remote servers have been created or it won't
// have deleted the database and the recovery manager may attempt to recover transactions
}
use of org.apache.activemq.artemis.tests.unit.util.InVMNamingContext in project activemq-artemis by apache.
the class JMSClusteredTestBase method setupServer2.
/**
* @throws Exception
*/
private void setupServer2() throws Exception {
Configuration configuration = createConfigServer(2, 1);
JMSConfigurationImpl jmsconfig = new JMSConfigurationImpl();
mBeanServer2 = MBeanServerFactory.createMBeanServer();
server2 = addServer(ActiveMQServers.newActiveMQServer(configuration, mBeanServer2, enablePersistence()));
jmsServer2 = new JMSServerManagerImpl(server2, jmsconfig);
context2 = new InVMNamingContext();
jmsServer2.setRegistry(new JndiBindingRegistry(context2));
}
use of org.apache.activemq.artemis.tests.unit.util.InVMNamingContext in project activemq-artemis by apache.
the class JMSTestBase method restartServer.
protected void restartServer() throws Exception {
namingContext = new InVMNamingContext();
jmsServer.setRegistry(new JndiBindingRegistry(namingContext));
jmsServer.start();
jmsServer.activated();
registerConnectionFactory();
}
use of org.apache.activemq.artemis.tests.unit.util.InVMNamingContext in project activemq-artemis by apache.
the class JMSTestBase method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
mbeanServer = MBeanServerFactory.createMBeanServer();
Configuration config = createDefaultConfig(true).setSecurityEnabled(useSecurity()).addConnectorConfiguration("invm", new TransportConfiguration(INVM_CONNECTOR_FACTORY)).setTransactionTimeoutScanPeriod(100);
config.getConnectorConfigurations().put("netty", new TransportConfiguration(NETTY_CONNECTOR_FACTORY));
server = addServer(ActiveMQServers.newActiveMQServer(config, mbeanServer, usePersistence()));
jmsServer = new JMSServerManagerImpl(server);
namingContext = new InVMNamingContext();
jmsServer.setRegistry(new JndiBindingRegistry(namingContext));
jmsServer.start();
registerConnectionFactory();
}
Aggregations