Add before and after logging for unit tests

Currently we have these logs for integration tests only.

This adds the following log at the start:
```
logger.info("[{}]: before test", getTestName());
```

and this is logged at the end, but before any clean up done in sub classes

```
 logger.info("[{}]: after test", getTestName());
```
This commit is contained in:
Boaz Leskes 2016-12-01 12:56:37 +01:00
parent dd5256c324
commit 9097abee04
3 changed files with 14 additions and 10 deletions

View File

@ -1986,19 +1986,17 @@ public abstract class ESIntegTestCase extends ESTestCase {
@Before
public final void before() throws Exception {
public final void setupTestCluster() throws Exception {
if (runTestScopeLifecycle()) {
printTestMessage("setup");
printTestMessage("setting up");
beforeInternal();
printTestMessage("all set up");
}
printTestMessage("starting");
}
@After
public final void after() throws Exception {
printTestMessage("finished");
public final void cleanUpCluster() throws Exception {
// Deleting indices is going to clear search contexts implicitly so we
// need to check that there are no more in-flight search contexts before
// we remove indices

View File

@ -245,9 +245,17 @@ public abstract class ESTestCase extends LuceneTestCase {
Requests.INDEX_CONTENT_TYPE = XContentType.JSON;
}
@Before
public final void before() {
logger.info("[{}]: before test", getTestName());
}
@After
public final void ensureCleanedUp() throws Exception {
public final void after() throws Exception {
checkStaticState();
ensureAllSearchContextsReleased();
ensureCheckIndexPassed();
logger.info("[{}]: after test", getTestName());
}
private static final List<StatusData> statusData = new ArrayList<>();
@ -293,7 +301,6 @@ public abstract class ESTestCase extends LuceneTestCase {
}
// this must be a separate method from other ensure checks above so suite scoped integ tests can call...TODO: fix that
@After
public final void ensureAllSearchContextsReleased() throws Exception {
assertBusy(() -> MockSearchService.assertNoInFlightContext());
}
@ -309,7 +316,6 @@ public abstract class ESTestCase extends LuceneTestCase {
checkIndexFailed = false;
}
@After
public final void ensureCheckIndexPassed() throws Exception {
assertFalse("at least one shard failed CheckIndex", checkIndexFailed);
}

View File

@ -123,7 +123,7 @@ public abstract class ESRestTestCase extends ESTestCase {
* Clean up after the test case.
*/
@After
public final void after() throws Exception {
public final void cleanUpCluster() throws Exception {
wipeCluster();
logIfThereAreRunningTasks();
}