Skip to content

Commit

Permalink
fix intermittent failures
Browse files Browse the repository at this point in the history
leave some time after HornetQ server is activated before checking its
resources.
do the same after the :reload operation to avoid a false positive if the
server has not changed its server-state from running.

We had some failures in our integration server because the test was
checking a queue after the server activation while the queue was
installing (and not ready to handle a :read-attribute operation).
  • Loading branch information
jmesnil authored and jaikiran committed Apr 25, 2013
1 parent 7ca4794 commit 3d4bc44
Showing 1 changed file with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.READ_ATTRIBUTE_OPERATION;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.READ_RESOURCE_OPERATION;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RESULT;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUCCESS;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
Expand All @@ -54,7 +53,6 @@
import org.jboss.dmr.ModelNode;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;

Expand Down Expand Up @@ -269,6 +267,9 @@ private static void waitForHornetQServerActivation(ModelControllerClient client,
boolean started = result.get(RESULT, "started").asBoolean();
boolean active = result.get(RESULT, "active").asBoolean();
if (started && expectedActive == active) {
// leave some time to the hornetq children resources to be installed after the server is activated
Thread.sleep(TimeoutUtil.adjust(500));

return;
}
} catch (Exception e) {
Expand All @@ -284,6 +285,11 @@ private static void waitForHornetQServerActivation(ModelControllerClient client,
}

private void waitForBackupServerToReload(int timeout) throws Exception {
// FIXME use the CLI high-level reload operation that blocks instead of
// fiddling with timeouts...
// leave some time to have the server starts its reload process and change
// its server-starte from running.
Thread.sleep(TimeoutUtil.adjust(500));
long start = System.currentTimeMillis();
long now;
do {
Expand All @@ -292,10 +298,10 @@ private void waitForBackupServerToReload(int timeout) throws Exception {
ModelNode operation = new ModelNode();
operation.get(OP_ADDR).setEmptyList();
operation.get(OP).set(READ_ATTRIBUTE_OPERATION);
operation.get(NAME).set("running-mode");
operation.get(NAME).set("server-state");
try {
ModelNode result = execute(backupClient, operation);
boolean normal = "NORMAL".equals(result.get(RESULT).asString());
boolean normal = "running".equals(result.get(RESULT).asString());
if (normal) {
return;
}
Expand All @@ -312,6 +318,11 @@ private void waitForBackupServerToReload(int timeout) throws Exception {
}

private void waitForLiveServerToReload(int timeout) throws Exception {
// FIXME use the CLI high-level reload operation that blocks instead of
// fiddling with timeouts...
// leave some time to have the server starts its reload process and change
// its server-starte from running.
Thread.sleep(TimeoutUtil.adjust(500));
long start = System.currentTimeMillis();
long now;
do {
Expand All @@ -320,10 +331,10 @@ private void waitForLiveServerToReload(int timeout) throws Exception {
ModelNode operation = new ModelNode();
operation.get(OP_ADDR).setEmptyList();
operation.get(OP).set(READ_ATTRIBUTE_OPERATION);
operation.get(NAME).set("running-mode");
operation.get(NAME).set("server-state");
try {
ModelNode result = execute(liveClient, operation);
boolean normal = "NORMAL".equals(result.get(RESULT).asString());
boolean normal = "running".equals(result.get(RESULT).asString());
if (normal) {
return;
}
Expand Down

0 comments on commit 3d4bc44

Please sign in to comment.