[TEST] Reset all cluster if a test hit a failure

Closes #6734
This commit is contained in:
Simon Willnauer 2014-07-04 14:58:08 +02:00
parent 63852a2c44
commit 1e0506b6a0
1 changed files with 4 additions and 1 deletions

View File

@ -543,16 +543,19 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase
} }
throw e; throw e;
} finally { } finally {
if (!success) { if (!success || suiteFailureMarker.hadFailures()) {
// if we failed that means that something broke horribly so we should // if we failed that means that something broke horribly so we should
// clear all clusters and if the current cluster is the global we shut that one // clear all clusters and if the current cluster is the global we shut that one
// down as well to prevent subsequent tests from failing due to the same problem. // down as well to prevent subsequent tests from failing due to the same problem.
// we also reset everything in the case we had a failure in the suite to make sure subsequent
// tests get a new / clean cluster
clearClusters(); clearClusters();
if (currentCluster == GLOBAL_CLUSTER) { if (currentCluster == GLOBAL_CLUSTER) {
GLOBAL_CLUSTER.close(); GLOBAL_CLUSTER.close();
GLOBAL_CLUSTER = null; GLOBAL_CLUSTER = null;
initializeGlobalCluster(); // re-init that cluster initializeGlobalCluster(); // re-init that cluster
} }
currentCluster = null;
} }
if (currentCluster != null) { if (currentCluster != null) {
// this can be null if the test fails due to static initialization ie. missing parameter on the cmd // this can be null if the test fails due to static initialization ie. missing parameter on the cmd