[Tests] improved automatic disruption healing after tests

This commit is contained in:
Boaz Leskes 2014-07-02 21:39:12 +02:00
parent 5e5f8a9daf
commit e897dccb52
1 changed files with 16 additions and 13 deletions

View File

@ -835,7 +835,15 @@ public final class InternalTestCluster extends TestCluster {
} }
private synchronized void reset(boolean wipeData) throws IOException { private synchronized void reset(boolean wipeData) throws IOException {
TimeValue expectedHealingTime = activeDisruptionScheme != null ? activeDisruptionScheme.expectedTimeToHeal() : null; // clear all rules for mock transport services
for (NodeAndClient nodeAndClient : nodes.values()) {
TransportService transportService = nodeAndClient.node.injector().getInstance(TransportService.class);
if (transportService instanceof MockTransportService) {
((MockTransportService) transportService).clearAllRules();
}
}
if (activeDisruptionScheme != null) {
TimeValue expectedHealingTime = activeDisruptionScheme.expectedTimeToHeal();
clearDisruptionScheme(); clearDisruptionScheme();
if (expectedHealingTime != null && expectedHealingTime.millis() > 0) { if (expectedHealingTime != null && expectedHealingTime.millis() > 0) {
try { try {
@ -844,17 +852,12 @@ public final class InternalTestCluster extends TestCluster {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
} }
assert !client().admin().cluster().prepareHealth().setWaitForNodes("" + nodes.size()).get().isTimedOut() : "cluster failed to form after disruption was healed";
}
randomlyResetClients(); randomlyResetClients();
if (wipeData) { if (wipeData) {
wipeDataDirectories(); wipeDataDirectories();
} }
// clear all rules for mock transport services
for (NodeAndClient nodeAndClient : nodes.values()) {
TransportService transportService = nodeAndClient.node.injector().getInstance(TransportService.class);
if (transportService instanceof MockTransportService) {
((MockTransportService) transportService).clearAllRules();
}
}
if (nextNodeId.get() == sharedNodesSeeds.length && nodes.size() == sharedNodesSeeds.length) { if (nextNodeId.get() == sharedNodesSeeds.length && nodes.size() == sharedNodesSeeds.length) {
logger.debug("Cluster hasn't changed - moving out - nodes: [{}] nextNodeId: [{}] numSharedNodes: [{}]", nodes.keySet(), nextNodeId.get(), sharedNodesSeeds.length); logger.debug("Cluster hasn't changed - moving out - nodes: [{}] nextNodeId: [{}] numSharedNodes: [{}]", nodes.keySet(), nextNodeId.get(), sharedNodesSeeds.length);
return; return;