[TEST] better test start and end messages

print when cleaning up also for SingleNodeTests
distinguish between after suite and after test cleanup
This commit is contained in:
Britta Weber 2015-04-11 13:13:56 +02:00
parent 3cc3390f17
commit 4934def035
2 changed files with 14 additions and 5 deletions

View File

@ -290,7 +290,7 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase
cluster().beforeTest(getRandom(), getPerTestTransportClientRatio());
cluster().wipe();
randomIndexTemplate();
logger.info("[{}#{}]: before test", getTestClass().getSimpleName(), getTestName());
printTestMessage("before");
} catch (OutOfMemoryError e) {
if (e.getMessage().contains("unable to create new native thread")) {
ElasticsearchTestCase.printStackDump(logger);
@ -299,6 +299,14 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase
}
}
private void printTestMessage(String message) {
if (isSuiteScopedTest(getClass())) {
logger.info("[{}]: {} suite", getTestClass().getSimpleName(), message);
} else {
logger.info("[{}#{}]: {} test", getTestClass().getSimpleName(), getTestName(), message);
}
}
private Loading randomLoadingValues() {
return randomFrom(Loading.values());
}
@ -590,9 +598,9 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase
protected final void afterInternal(boolean afterClass) throws Exception {
boolean success = false;
try {
logger.info("[{}#{}]: cleaning up after test", getTestClass().getSimpleName(), getTestName());
clearDisruptionScheme();
final Scope currentClusterScope = getCurrentClusterScope();
printTestMessage("cleaning up after");
clearDisruptionScheme();
try {
if (cluster() != null) {
if (currentClusterScope != Scope.TEST) {
@ -614,7 +622,7 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase
clearClusters(); // it is ok to leave persistent / transient cluster state behind if scope is TEST
}
}
logger.info("[{}#{}]: cleaned up after test", getTestClass().getSimpleName(), getTestName());
printTestMessage("cleaned up after");
success = true;
} finally {
if (!success) {

View File

@ -87,6 +87,7 @@ public abstract class ElasticsearchSingleNodeTest extends ElasticsearchTestCase
@After
public void tearDown() throws Exception {
logger.info("[{}#{}]: cleaning up after test", getTestClass().getSimpleName(), getTestName());
super.tearDown();
cleanup(resetNodeAfterTest());
}
@ -230,7 +231,7 @@ public abstract class ElasticsearchSingleNodeTest extends ElasticsearchTestCase
* It is useful to ensure that all action on the cluster have finished and all shards that were currently relocating
* are now allocated and started.
*/
public ClusterHealthStatus ensureGreen(String... indices) {
public ClusterHealthStatus ensureGreen(String... indices) {
return ensureGreen(TimeValue.timeValueSeconds(30), indices);
}