Skip to content

Commit

Permalink
[WFLY-2886] Correct RolloutPlanTestCase assumptions about test execution
Browse files Browse the repository at this point in the history
Add some trace logging to domain operation rollout
  • Loading branch information
bstansberry committed Feb 9, 2014
1 parent d7d7a1f commit 6d09835
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

package org.jboss.as.controller.remote;

import org.jboss.as.controller.ControllerLogger;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.dmr.ModelNode;
import org.jboss.threads.AsyncFuture;
Expand Down Expand Up @@ -59,13 +60,15 @@ public BlockingQueueOperationListener(final BlockingQueue<TransactionalProtocolC

@Override
public void operationPrepared(final TransactionalProtocolClient.PreparedOperation<T> prepared) {
ControllerLogger.MGMT_OP_LOGGER.tracef("received prepared operation %s", prepared.getOperation());
if(! queue.offer(prepared)) {
prepared.rollback();
}
}

@Override
public void operationFailed(T operation, ModelNode result) {
ControllerLogger.MGMT_OP_LOGGER.tracef("received failed operation %s", operation);
queue.offer(new FailedOperation<T>(operation, result));
}

Expand Down Expand Up @@ -256,4 +259,4 @@ public T get(long timeout, TimeUnit unit) throws InterruptedException, Execution
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import java.util.HashSet;
import java.util.Set;

import org.jboss.as.domain.controller.DomainControllerLogger;

/**
* Policy that controls whether concurrently executing updates to server groups
* can proceed. Acts a parent to the {@link ServerUpdatePolicy} that controls
Expand Down Expand Up @@ -105,6 +107,8 @@ public void recordServerGroupResult(final String serverGroup, final boolean fail
if (failed) {
this.failed = true;
}
DomainControllerLogger.DOMAIN_DEPLOYMENT_LOGGER.tracef("Recorded group result for '%s': failed = %s",
serverGroup, failed);
notifyAll();
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@

package org.jboss.as.domain.controller.plan;

import org.jboss.as.controller.remote.TransactionalProtocolClient;
import org.jboss.as.domain.controller.ServerIdentity;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.security.auth.Subject;

import org.jboss.as.controller.remote.TransactionalProtocolClient;
import org.jboss.as.domain.controller.DomainControllerLogger;
import org.jboss.as.domain.controller.ServerIdentity;

/**
* @author Emanuel Muckenhuber
*/
Expand All @@ -53,6 +54,7 @@ public void execute() {
outstanding.add(task.getServerIdentity());
}
} else {
DomainControllerLogger.DOMAIN_DEPLOYMENT_LOGGER.tracef("Skipping server update task for %s", identity);
sendCancelledResponse(identity);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@

package org.jboss.as.domain.controller.plan;

import org.jboss.as.controller.remote.TransactionalProtocolClient;
import org.jboss.as.domain.controller.ServerIdentity;

import java.util.List;

import javax.security.auth.Subject;

import org.jboss.as.controller.remote.TransactionalProtocolClient;
import org.jboss.as.domain.controller.DomainControllerLogger;
import org.jboss.as.domain.controller.ServerIdentity;

/**
* @author Emanuel Muckenhuber
*/
Expand All @@ -46,6 +47,7 @@ public void execute() {
for(final ServerUpdateTask task : tasks) {
final ServerIdentity identity = task.getServerIdentity();
if(interrupted || ! updatePolicy.canUpdateServer(identity)) {
DomainControllerLogger.DOMAIN_DEPLOYMENT_LOGGER.tracef("Skipping server update task for %s", identity);
sendCancelledResponse(identity);
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import java.util.Set;

import org.jboss.as.domain.controller.DomainControllerLogger;
import org.jboss.as.domain.controller.ServerIdentity;
import org.jboss.dmr.ModelNode;

Expand Down Expand Up @@ -135,6 +136,10 @@ public void recordServerResult(ServerIdentity server, ModelNode response) {

boolean serverFailed = response.has(FAILURE_DESCRIPTION);


DomainControllerLogger.DOMAIN_DEPLOYMENT_LOGGER.tracef("Recording server result for '%s': failed = %s",
server, server);

synchronized (this) {
int previousFailed = failureCount;
if (serverFailed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,11 @@
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.impl.base.exporter.zip.ZipExporterImpl;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runners.MethodSorters;

/**
*
Expand Down Expand Up @@ -93,6 +91,7 @@ public static void before() throws Exception {
public static void after() throws Exception {

if (warFile.exists()){
//noinspection ResultOfMethodCallIgnored
warFile.delete();
}

Expand All @@ -111,6 +110,16 @@ public static void after() throws Exception {
AbstractCliTestBase.closeCLI();
}

@After
public void afterTest() throws Exception {

// undeploy helper servlets
cli.sendLine("undeploy RolloutPlanTestCase.war --all-relevant-server-groups", true);

// remove socket binding
cli.sendLine("/socket-binding-group=standard-sockets/socket-binding=test-binding:remove", true);
}

@Test
public void testInSeriesRolloutPlan() throws Exception {

Expand Down Expand Up @@ -173,9 +182,6 @@ public void testInSeriesRolloutPlan() throws Exception {
Assert.assertTrue(mainThreeTime > otherTwoTime);
Assert.assertTrue(otherTwoTime > testOneTime);

// undeploy apps
cli.sendLine("undeploy RolloutPlanTestCase.war --all-relevant-server-groups");

// remove rollout plans
cli.sendLine("rollout-plan remove --name=testPlan");
cli.sendLine("rollout-plan remove --name=testPlan2");
Expand Down Expand Up @@ -241,17 +247,8 @@ public void testMaxFailServersRolloutPlan() throws Exception {
Assert.assertFalse(getServerStatus("main-two", ret));
Assert.assertFalse(getServerStatus("main-three", ret));
Assert.assertTrue(getServerStatus("test-one", ret));
ret = testRemoveConnector("maxFailOnePlan");
Assert.assertTrue(ret.isIsOutcomeSuccess());
Assert.assertFalse(getServerStatus("main-two", ret));
Assert.assertFalse(getServerStatus("main-three", ret));
Assert.assertTrue(getServerStatus("test-one", ret));

// undeploy helper servlets
cli.sendLine("undeploy RolloutPlanTestCase.war --all-relevant-server-groups");

// remove socket binding
cli.sendLine("/socket-binding-group=standard-sockets/socket-binding=test-binding:remove");
testCleanupConnector("maxFailOnePlan");

// remove rollout plan
cli.sendLine("rollout-plan remove --name=maxFailOnePlan");
Expand Down Expand Up @@ -302,17 +299,8 @@ public void testMaxFailServersPercentageRolloutPlan() throws Exception {
Assert.assertFalse(getServerStatus("main-two", ret));
Assert.assertFalse(getServerStatus("main-three", ret));
Assert.assertTrue(getServerStatus("test-one", ret));
ret = testRemoveConnector("maxFailPercPlan");
Assert.assertTrue(ret.isIsOutcomeSuccess());
Assert.assertFalse(getServerStatus("main-two", ret));
Assert.assertFalse(getServerStatus("main-three", ret));
Assert.assertTrue(getServerStatus("test-one", ret));

// undeploy helper servlets
cli.sendLine("undeploy RolloutPlanTestCase.war --all-relevant-server-groups");

// remove socket binding
cli.sendLine("/socket-binding-group=standard-sockets/socket-binding=test-binding:remove");
testCleanupConnector("maxFailPercPlan");

// remove rollout plan
cli.sendLine("rollout-plan remove --name=maxFailPercPlan");
Expand Down Expand Up @@ -357,12 +345,6 @@ public void testRollbackAcrossGroupsRolloutPlan() throws Exception {
Assert.assertFalse(getServerStatus("main-three", ret));
Assert.assertFalse(getServerStatus("test-one", ret));

// undeploy helper servlets
cli.sendLine("undeploy RolloutPlanTestCase.war --all-relevant-server-groups");

// remove socket binding
cli.sendLine("/socket-binding-group=standard-sockets/socket-binding=test-binding:remove");

// remove rollout plan
cli.sendLine("rollout-plan remove --name=groupsRollbackPlan");
}
Expand All @@ -380,6 +362,25 @@ private CLIOpResult testRemoveConnector(String rolloutPlanId) throws Exception {
return cli.readAllAsOpResult();
}

private void testCleanupConnector(String rolloutPlanId) throws Exception {
CLIOpResult ret = testRemoveConnector(rolloutPlanId);
Assert.assertTrue(ret.isIsOutcomeSuccess());
Assert.assertTrue(getServerStatus("test-one", ret));
boolean gotNoResponse = false;
for (String server : new String[]{"main-one", "main-two", "main-three"}) {
try {
Assert.assertFalse(getServerStatus(server, ret));
} catch (NoResponseException e) {
if (gotNoResponse) {
throw e;
}
gotNoResponse = true;
}
}
Assert.assertTrue("received no response from one server", gotNoResponse);

}


private boolean getServerStatus(String serverName, CLIOpResult result) throws Exception {
Map groups = (Map) result.getServerGroups();
Expand All @@ -397,7 +398,7 @@ private boolean getServerStatus(String serverName, CLIOpResult result) throws Ex
}
}
}
throw new Exception("Status of the server " + serverName + " not found in operation result.");
throw new NoResponseException(serverName);
}


Expand Down Expand Up @@ -431,9 +432,9 @@ private static String getServerHost(String server) {

private static void waitUntilState(final String serverName, final String state) throws TimeoutException {
final String serverHost = CLITestSuite.getServerHost(serverName);
RetryTaskExecutor taskExecutor = new RetryTaskExecutor();
taskExecutor.retryTask(new Callable() {
public Object call() throws Exception {
RetryTaskExecutor<Void> taskExecutor = new RetryTaskExecutor<Void>();
taskExecutor.retryTask(new Callable<Void>() {
public Void call() throws Exception {
cli.sendLine("/host=" + serverHost + "/server-config=" + serverName + ":read-attribute(name=status)");
CLIOpResult res = cli.readAllAsOpResult();
if (! res.getResult().equals(state)) throw new Exception("Server not in state.");
Expand All @@ -443,4 +444,12 @@ public Object call() throws Exception {

}

private static class NoResponseException extends Exception {
private static final long serialVersionUID = 1L;

private NoResponseException(String serverName) {
super("Status of the server " + serverName + " not found in operation result.");
}
}

}

0 comments on commit 6d09835

Please sign in to comment.