mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 10:25:15 +00:00
[TEST] Don't reuse single node tests node instance across tests
Similar to the shared cluster we should not reuse the node from singlenodetest across tests.
This commit is contained in:
parent
1848d1ba8b
commit
668d09db08
@ -23,6 +23,8 @@ import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.IndexService;
|
||||
import org.elasticsearch.search.internal.SearchContext;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
|
||||
/**
|
||||
@ -37,6 +39,17 @@ public abstract class ElasticsearchSingleNodeLuceneTestCase extends Elasticsearc
|
||||
ElasticsearchSingleNodeTest.cleanup(resetNodeAfterTest());
|
||||
}
|
||||
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
ElasticsearchSingleNodeTest.setUpClass();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() {
|
||||
ElasticsearchSingleNodeTest.tearDownClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns <code>true</code> if the node that is used in the background should be reset
|
||||
* after each test. This is useful if the test changes the cluster state metadata etc. The default is
|
||||
|
@ -42,8 +42,7 @@ import org.elasticsearch.node.NodeBuilder;
|
||||
import org.elasticsearch.node.internal.InternalNode;
|
||||
import org.elasticsearch.search.internal.SearchContext;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.junit.After;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.*;
|
||||
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
@ -56,14 +55,26 @@ import static org.hamcrest.Matchers.*;
|
||||
public abstract class ElasticsearchSingleNodeTest extends ElasticsearchTestCase {
|
||||
|
||||
private static class Holder {
|
||||
// lazy init on first access
|
||||
private static Node NODE = newNode();
|
||||
private static Node NODE = null;
|
||||
|
||||
private static void reset() {
|
||||
assert NODE != null;
|
||||
node().stop();
|
||||
Holder.NODE = newNode();
|
||||
}
|
||||
|
||||
private static void startNode() {
|
||||
assert NODE == null;
|
||||
NODE = newNode();
|
||||
}
|
||||
|
||||
private static void stopNode() {
|
||||
if (NODE != null) {
|
||||
Node node = NODE;
|
||||
NODE = null;
|
||||
node.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void cleanup(boolean resetNode) {
|
||||
@ -79,10 +90,22 @@ public abstract class ElasticsearchSingleNodeTest extends ElasticsearchTestCase
|
||||
}
|
||||
|
||||
@After
|
||||
public void after() {
|
||||
public void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
cleanup(resetNodeAfterTest());
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
Holder.stopNode();
|
||||
Holder.startNode();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() {
|
||||
Holder.stopNode();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns <code>true</code> if the node that is used in the background should be reset
|
||||
* after each test. This is useful if the test changes the cluster state metadata etc. The default is
|
||||
|
Loading…
x
Reference in New Issue
Block a user