mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-20 03:45:02 +00:00
Prevent page-tracking checks from spreading across tests.
This commit is contained in:
parent
7af63700c9
commit
5723603987
@ -35,12 +35,15 @@ public class MockPageCacheRecycler extends PageCacheRecycler {
|
|||||||
|
|
||||||
private static final ConcurrentMap<Object, Throwable> ACQUIRED_PAGES = Maps.newConcurrentMap();
|
private static final ConcurrentMap<Object, Throwable> ACQUIRED_PAGES = Maps.newConcurrentMap();
|
||||||
|
|
||||||
|
public static void reset() {
|
||||||
|
ACQUIRED_PAGES.clear();
|
||||||
|
}
|
||||||
|
|
||||||
public static void ensureAllPagesAreReleased() {
|
public static void ensureAllPagesAreReleased() {
|
||||||
if (ACQUIRED_PAGES.size() > 0) {
|
if (ACQUIRED_PAGES.size() > 0) {
|
||||||
final Throwable t = ACQUIRED_PAGES.entrySet().iterator().next().getValue();
|
final Throwable t = ACQUIRED_PAGES.entrySet().iterator().next().getValue();
|
||||||
throw new RuntimeException(ACQUIRED_PAGES.size() + " pages have not been released", t);
|
throw new RuntimeException(ACQUIRED_PAGES.size() + " pages have not been released", t);
|
||||||
}
|
}
|
||||||
ACQUIRED_PAGES.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Random random;
|
private final Random random;
|
||||||
|
@ -122,6 +122,11 @@ public abstract class ElasticsearchTestCase extends AbstractRandomizedTest {
|
|||||||
return new File(uri);
|
return new File(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void resetPageTracking() {
|
||||||
|
MockPageCacheRecycler.reset();
|
||||||
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void ensureAllPagesReleased() {
|
public void ensureAllPagesReleased() {
|
||||||
MockPageCacheRecycler.ensureAllPagesAreReleased();
|
MockPageCacheRecycler.ensureAllPagesAreReleased();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user