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