mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-08 22:14:59 +00:00
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:
parent
dd5256c324
commit
9097abee04
@ -1986,19 +1986,17 @@ public abstract class ESIntegTestCase extends ESTestCase {
|
|||||||
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public final void before() throws Exception {
|
public final void setupTestCluster() throws Exception {
|
||||||
|
|
||||||
if (runTestScopeLifecycle()) {
|
if (runTestScopeLifecycle()) {
|
||||||
printTestMessage("setup");
|
printTestMessage("setting up");
|
||||||
beforeInternal();
|
beforeInternal();
|
||||||
|
printTestMessage("all set up");
|
||||||
}
|
}
|
||||||
printTestMessage("starting");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public final void after() throws Exception {
|
public final void cleanUpCluster() throws Exception {
|
||||||
printTestMessage("finished");
|
|
||||||
// Deleting indices is going to clear search contexts implicitly so we
|
// Deleting indices is going to clear search contexts implicitly so we
|
||||||
// need to check that there are no more in-flight search contexts before
|
// need to check that there are no more in-flight search contexts before
|
||||||
// we remove indices
|
// we remove indices
|
||||||
|
@ -245,9 +245,17 @@ public abstract class ESTestCase extends LuceneTestCase {
|
|||||||
Requests.INDEX_CONTENT_TYPE = XContentType.JSON;
|
Requests.INDEX_CONTENT_TYPE = XContentType.JSON;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public final void before() {
|
||||||
|
logger.info("[{}]: before test", getTestName());
|
||||||
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public final void ensureCleanedUp() throws Exception {
|
public final void after() throws Exception {
|
||||||
checkStaticState();
|
checkStaticState();
|
||||||
|
ensureAllSearchContextsReleased();
|
||||||
|
ensureCheckIndexPassed();
|
||||||
|
logger.info("[{}]: after test", getTestName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final List<StatusData> statusData = new ArrayList<>();
|
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
|
// 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 {
|
public final void ensureAllSearchContextsReleased() throws Exception {
|
||||||
assertBusy(() -> MockSearchService.assertNoInFlightContext());
|
assertBusy(() -> MockSearchService.assertNoInFlightContext());
|
||||||
}
|
}
|
||||||
@ -309,7 +316,6 @@ public abstract class ESTestCase extends LuceneTestCase {
|
|||||||
checkIndexFailed = false;
|
checkIndexFailed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
|
||||||
public final void ensureCheckIndexPassed() throws Exception {
|
public final void ensureCheckIndexPassed() throws Exception {
|
||||||
assertFalse("at least one shard failed CheckIndex", checkIndexFailed);
|
assertFalse("at least one shard failed CheckIndex", checkIndexFailed);
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ public abstract class ESRestTestCase extends ESTestCase {
|
|||||||
* Clean up after the test case.
|
* Clean up after the test case.
|
||||||
*/
|
*/
|
||||||
@After
|
@After
|
||||||
public final void after() throws Exception {
|
public final void cleanUpCluster() throws Exception {
|
||||||
wipeCluster();
|
wipeCluster();
|
||||||
logIfThereAreRunningTasks();
|
logIfThereAreRunningTasks();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user