Search in sources :

Example 1 with TransactionStatusElement

use of org.jboss.jbossts.star.util.media.txstatusext.TransactionStatusElement in project narayana by jbosstm.

the class RecoveryIntegrationTestCase method testCrashBeforeCommit.

@Test
public void testCrashBeforeCommit() throws Exception {
    startContainer(VM_ARGUMENTS + " " + BYTEMAN_ARGUMENTS.replace("@BMScript@", "CrashBeforeCommit"));
    txSupport.startTx();
    enlistParticipant(txSupport.getDurableParticipantEnlistmentURI(), new Prepared());
    enlistParticipant(txSupport.getDurableParticipantEnlistmentURI(), new Prepared());
    Assert.assertEquals(2, txSupport.getTransactionInfo().getTwoPhaseAware().size());
    try {
        // JVM is killed here.
        txSupport.commitTx();
    } catch (HttpResponseException e) {
    }
    restartContainer(VM_ARGUMENTS);
    registerDeserializer();
    TransactionStatusElement status;
    int cycles = 0;
    do {
        Thread.sleep(RECOVERY_PERIOD * 2000);
        status = null;
        try {
            // Updates coordinator's active transactions list
            txSupport.getTransactions();
            // After successful recovery transaction is removed and 404 is returned.
            status = txSupport.getTransactionInfo().getStatus();
        } catch (HttpResponseException e) {
        }
    } while (status != null && cycles++ < RECOVERY_WAIT_CYCLES);
    if (status != null) {
        Assert.fail("Recovery failed unexpected status " + status);
    }
}
Also used : TransactionStatusElement(org.jboss.jbossts.star.util.media.txstatusext.TransactionStatusElement) Prepared(org.jboss.narayana.rest.integration.api.Prepared) HttpResponseException(org.jboss.jbossts.star.provider.HttpResponseException) Test(org.junit.Test)

Example 2 with TransactionStatusElement

use of org.jboss.jbossts.star.util.media.txstatusext.TransactionStatusElement in project narayana by jbosstm.

the class InboundBridgeRecoveryTestCase method testCrashBeforeCommit.

@Test
public void testCrashBeforeCommit() throws Exception {
    startContainer(VM_ARGUMENTS + " " + BYTEMAN_ARGUMENTS.replace("@BMScript@", "CrashBeforeCommit"));
    txSupport.startTx();
    enlistRestATParticipant(LOGGING_REST_AT_RESOURCE_URL);
    postRestATResource(SIMPLE_INBOUND_BRIDGE_RESOURCE_URL);
    try {
        txSupport.commitTx();
        Assert.fail("Container was not killed.");
    } catch (HttpResponseException e) {
    // After crash participant won't return any response and exception will be thrown.
    }
    restartContainer(VM_ARGUMENTS);
    TransactionStatusElement status;
    int cycles = 0;
    do {
        Thread.sleep(RECOVERY_PERIOD * 3000);
        status = null;
        try {
            // Updates coordinator's active transactions list
            txSupport.getTransactions();
            // After successful recovery transaction is removed and 404 is returned.
            status = txSupport.getTransactionInfo().getStatus();
        } catch (HttpResponseException e) {
        }
    } while (status != null && cycles++ < RECOVERY_WAIT_CYCLES);
    if (status != null) {
        Assert.fail("Recovery failed");
    }
}
Also used : TransactionStatusElement(org.jboss.jbossts.star.util.media.txstatusext.TransactionStatusElement) HttpResponseException(org.jboss.jbossts.star.provider.HttpResponseException) Test(org.junit.Test)

Example 3 with TransactionStatusElement

use of org.jboss.jbossts.star.util.media.txstatusext.TransactionStatusElement in project narayana by jbosstm.

the class InboundBridgeRecoveryWithMultipleDeploymentsTestCase method testCrashBeforeCommit.

@Test
public void testCrashBeforeCommit() throws Exception {
    startContainer(VM_ARGUMENTS + " " + BYTEMAN_ARGUMENTS.replace("@BMScript@", "CrashBeforeCommit"));
    txSupport.startTx();
    enlistRestATParticipant(LOGGING_REST_AT_RESOURCE_URL);
    postRestATResource(FIRST_DEPLOYMENT_URL);
    postRestATResource(SECOND_DEPLOYMENT_URL);
    try {
        txSupport.commitTx();
        Assert.fail("Container was not killed.");
    } catch (HttpResponseException e) {
    // After crash participant won't return any response and exception will be thrown.
    }
    restartContainer(VM_ARGUMENTS);
    TransactionStatusElement status;
    int cycles = 0;
    do {
        Thread.sleep(RECOVERY_PERIOD * 3000);
        status = null;
        try {
            // Updates coordinator's active transactions list
            txSupport.getTransactions();
            // After successful recovery transaction is removed and 404 is returned.
            status = txSupport.getTransactionInfo().getStatus();
        } catch (HttpResponseException e) {
        }
    } while (status != null && cycles++ < RECOVERY_WAIT_CYCLES);
    if (status != null) {
        Assert.fail("Recovery failed");
    }
}
Also used : TransactionStatusElement(org.jboss.jbossts.star.util.media.txstatusext.TransactionStatusElement) HttpResponseException(org.jboss.jbossts.star.provider.HttpResponseException) Test(org.junit.Test)

Example 4 with TransactionStatusElement

use of org.jboss.jbossts.star.util.media.txstatusext.TransactionStatusElement in project narayana by jbosstm.

the class RecoveryIntegrationTestCase method testCrashAfterPrepare.

@Test
public void testCrashAfterPrepare() throws Exception {
    startContainer(VM_ARGUMENTS + " " + BYTEMAN_ARGUMENTS.replace("@BMScript@", "CrashAfterPrepare"));
    txSupport.startTx();
    enlistParticipant(txSupport.getDurableParticipantEnlistmentURI(), new Prepared());
    enlistParticipant(txSupport.getDurableParticipantEnlistmentURI(), new Prepared());
    Assert.assertEquals(2, txSupport.getTransactionInfo().getTwoPhaseAware().size());
    try {
        // JVM is killed here.
        txSupport.commitTx();
    } catch (HttpResponseException e) {
    }
    restartContainer(VM_ARGUMENTS);
    registerDeserializer();
    TransactionStatusElement status;
    int cycles = 0;
    JSONArray partricipantsInformation;
    do {
        Thread.sleep(RECOVERY_PERIOD * 2000);
        partricipantsInformation = getParticipantsInformation();
    } while (cycles++ < RECOVERY_WAIT_CYCLES && partricipantsInformation.length() > 0);
    if (partricipantsInformation.length() > 0) {
        Assert.fail("Recovery failed");
    }
}
Also used : TransactionStatusElement(org.jboss.jbossts.star.util.media.txstatusext.TransactionStatusElement) Prepared(org.jboss.narayana.rest.integration.api.Prepared) JSONArray(org.codehaus.jettison.json.JSONArray) HttpResponseException(org.jboss.jbossts.star.provider.HttpResponseException) Test(org.junit.Test)

Aggregations

HttpResponseException (org.jboss.jbossts.star.provider.HttpResponseException)4 TransactionStatusElement (org.jboss.jbossts.star.util.media.txstatusext.TransactionStatusElement)4 Test (org.junit.Test)4 Prepared (org.jboss.narayana.rest.integration.api.Prepared)2 JSONArray (org.codehaus.jettison.json.JSONArray)1