Search in sources :

Example 11 with JMSOperations

use of org.jboss.as.test.integration.common.jms.JMSOperations in project wildfly by wildfly.

the class FailoverTestCase method testBackupFailoverAfterFailback.

@Test
public void testBackupFailoverAfterFailback() throws Exception {
    ModelControllerClient client2 = createClient2();
    JMSOperations backupJMSOperations = JMSOperationsProvider.getInstance(client2);
    checkJMSQueue(backupJMSOperations, jmsQueueName, false);
    InitialContext context1 = createJNDIContextFromServer1();
    String text = "sent to server1, received from server2 (after failover)";
    sendMessage(context1, jmsQueueLookup, text);
    context1.close();
    log.trace("############## 1 #############");
    //listSharedStoreDir();
    log.trace("===================");
    log.trace("STOP SERVER1...");
    log.trace("===================");
    container.stop(SERVER1);
    log.trace("############## 2 #############");
    //listSharedStoreDir();
    // let some time for the backup to detect the failure
    waitForHornetQServerActivation(backupJMSOperations, true);
    checkJMSQueue(backupJMSOperations, jmsQueueName, true);
    InitialContext context2 = createJNDIContextFromServer2();
    // receive the message that was sent to server1 before failover occurs
    receiveMessage(context2, jmsQueueLookup, text);
    // send a message to server2 before server1 fails back
    String text2 = "sent to server2, received from server 1 (after failback)";
    sendMessage(context2, jmsQueueLookup, text2);
    context2.close();
    log.trace("====================");
    log.trace("START SERVER1...");
    log.trace("====================");
    // restart the live server
    container.start(SERVER1);
    // let some time for the backup to detect the live node and failback
    ModelControllerClient client1 = createClient1();
    JMSOperations liveJMSOperations = JMSOperationsProvider.getInstance(client1);
    waitForHornetQServerActivation(liveJMSOperations, true);
    checkHornetQServerStartedAndActiveAttributes(liveJMSOperations, true, true);
    // let some time for the backup to detect the failure
    waitForHornetQServerActivation(backupJMSOperations, false);
    // backup server has been restarted in passive mode
    checkHornetQServerStartedAndActiveAttributes(backupJMSOperations, true, false);
    checkJMSQueue(backupJMSOperations, jmsQueueName, false);
    context1 = createJNDIContextFromServer1();
    // receive the message that was sent to server2 before failback
    receiveMessage(context1, jmsQueueLookup, text2);
    String text3 = "sent to server1, received from server2 (after 2nd failover)";
    // send a message to server1 before it is stopped a 2nd time
    sendMessage(context1, jmsQueueLookup, text3);
    context1.close();
    log.trace("==============================");
    log.trace("STOP SERVER1 A 2ND TIME...");
    log.trace("==============================");
    // shutdown server1 a 2nd time
    container.stop(SERVER1);
    // let some time for the backup to detect the failure
    waitForHornetQServerActivation(backupJMSOperations, true);
    checkHornetQServerStartedAndActiveAttributes(backupJMSOperations, true, true);
    checkJMSQueue(backupJMSOperations, jmsQueueName, true);
    context2 = createJNDIContextFromServer2();
    // receive the message that was sent to server1 before failover occurs a 2nd time
    receiveMessage(context2, jmsQueueLookup, text3);
    context2.close();
//Assert.fail("wth");
}
Also used : ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient) JMSOperations(org.jboss.as.test.integration.common.jms.JMSOperations) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Example 12 with JMSOperations

use of org.jboss.as.test.integration.common.jms.JMSOperations in project wildfly by wildfly.

the class FailoverTestCase method testBackupActivation.

@Test
public void testBackupActivation() throws Exception {
    ModelControllerClient client2 = createClient2();
    JMSOperations jmsOperations2 = JMSOperationsProvider.getInstance(client2);
    checkJMSQueue(jmsOperations2, jmsQueueName, false);
    InitialContext context1 = createJNDIContextFromServer1();
    sendAndReceiveMessage(context1, jmsQueueLookup);
    // send a message to server1 before it is stopped
    String text = "sent to server1, received from server2 (after failover)";
    sendMessage(context1, jmsQueueLookup, text);
    context1.close();
    log.trace("===================");
    log.trace("STOP SERVER1...");
    log.trace("===================");
    container.stop(SERVER1);
    // let some time for the backup to detect the failure
    waitForHornetQServerActivation(jmsOperations2, true);
    checkJMSQueue(jmsOperations2, jmsQueueName, true);
    InitialContext context2 = createJNDIContextFromServer2();
    // receive the message that was sent to server1 before failover occurs
    receiveMessage(context2, jmsQueueLookup, text);
    sendAndReceiveMessage(context2, jmsQueueLookup);
    String text2 = "sent to server2, received from server 1 (after failback)";
    sendMessage(context2, jmsQueueLookup, text2);
    context2.close();
    log.trace("====================");
    log.trace("START SERVER1...");
    log.trace("====================");
    // restart the live server
    container.start(SERVER1);
    // let some time for the backup to detect the live node and failback
    ModelControllerClient client1 = createClient1();
    JMSOperations jmsOperations1 = JMSOperationsProvider.getInstance(client1);
    waitForHornetQServerActivation(jmsOperations1, true);
    checkHornetQServerStartedAndActiveAttributes(jmsOperations1, true, true);
    // let some time for the backup to detect the failure
    waitForHornetQServerActivation(jmsOperations2, false);
    // backup server has been restarted in passive mode
    checkHornetQServerStartedAndActiveAttributes(jmsOperations2, true, false);
    checkJMSQueue(jmsOperations2, jmsQueueName, false);
    context1 = createJNDIContextFromServer1();
    // receive the message that was sent to server2 before failback
    receiveMessage(context1, jmsQueueLookup, text2);
    // send & receive a message from server1
    sendAndReceiveMessage(context1, jmsQueueLookup);
    context1.close();
    log.trace("=============================");
    log.trace("RETURN TO NORMAL OPERATION...");
    log.trace("=============================");
}
Also used : ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient) JMSOperations(org.jboss.as.test.integration.common.jms.JMSOperations) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Example 13 with JMSOperations

use of org.jboss.as.test.integration.common.jms.JMSOperations in project wildfly by wildfly.

the class ClusteredMessagingTestCase method tearDown.

@After
public void tearDown() throws Exception {
    try (ModelControllerClient client = createClient1()) {
        JMSOperations jmsOperations = JMSOperationsProvider.getInstance(client);
        jmsOperations.removeJmsQueue(jmsQueueName);
        jmsOperations.removeJmsTopic(jmsTopicName);
    }
    try (ModelControllerClient client = createClient2()) {
        JMSOperations jmsOperations = JMSOperationsProvider.getInstance(client);
        jmsOperations.removeJmsQueue(jmsQueueName);
        jmsOperations.removeJmsTopic(jmsTopicName);
    }
    container.stop(CONTAINER_0);
    container.stop(CONTAINER_1);
}
Also used : ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient) JMSOperations(org.jboss.as.test.integration.common.jms.JMSOperations) After(org.junit.After)

Example 14 with JMSOperations

use of org.jboss.as.test.integration.common.jms.JMSOperations in project wildfly by wildfly.

the class ExportImportJournalTestCase method setUp.

@Before
public void setUp() {
    JMSOperations jmsOperations = JMSOperationsProvider.getInstance(managementClient.getControllerClient());
    jmsOperations.createJmsQueue(jmsQueueName, "java:jboss/exported/" + jmsQueueLookup);
    jmsOperations.close();
}
Also used : JMSOperations(org.jboss.as.test.integration.common.jms.JMSOperations) Before(org.junit.Before)

Example 15 with JMSOperations

use of org.jboss.as.test.integration.common.jms.JMSOperations in project wildfly by wildfly.

the class JmsClientTestCase method tearDown.

@After
public void tearDown() throws IOException {
    JMSOperations jmsOperations = JMSOperationsProvider.getInstance(managementClient);
    jmsOperations.removeJmsQueue(QUEUE_NAME);
}
Also used : JMSOperations(org.jboss.as.test.integration.common.jms.JMSOperations) After(org.junit.After)

Aggregations

JMSOperations (org.jboss.as.test.integration.common.jms.JMSOperations)15 ModelNode (org.jboss.dmr.ModelNode)7 ModelControllerClient (org.jboss.as.controller.client.ModelControllerClient)4 After (org.junit.After)4 Before (org.junit.Before)4 Test (org.junit.Test)3 InitialContext (javax.naming.InitialContext)2 MgmtOperationException (org.jboss.as.test.integration.management.util.MgmtOperationException)1