mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-25 17:38:44 +00:00
Adds a preserveIndicesUponCompletion method to ESRestTestCase
that can be overridden by subclasses if the test must not delete indices it created after exiting.
This commit is contained in:
parent
83adc87015
commit
98230d035a
@ -46,7 +46,7 @@ class ClusterFormationTasks {
|
||||
/**
|
||||
* Adds dependent tasks to the given task to start and stop a cluster with the given configuration.
|
||||
*
|
||||
* Returns a NodeInfo object for the first node in the cluster.
|
||||
* Returns a list of NodeInfo objects for each node in the cluster.
|
||||
*/
|
||||
static List<NodeInfo> setup(Project project, Task task, ClusterConfiguration config) {
|
||||
if (task.getEnabled() == false) {
|
||||
@ -102,7 +102,6 @@ class ClusterFormationTasks {
|
||||
Task wait = configureWaitTask("${task.name}#wait", project, nodes, startTasks)
|
||||
task.dependsOn(wait)
|
||||
|
||||
// delay the resolution of the uri by wrapping in a closure, so it is not used until read for tests
|
||||
return nodes
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,6 @@ task oldClusterTest(type: RestIntegTestTask) {
|
||||
clusterName = 'rolling-upgrade'
|
||||
}
|
||||
systemProperty 'tests.rest.suite', 'old_cluster'
|
||||
systemProperty 'tests.rest.preserve_indices', 'true'
|
||||
}
|
||||
|
||||
task mixedClusterTest(type: RestIntegTestTask) {
|
||||
@ -47,7 +46,6 @@ task mixedClusterTest(type: RestIntegTestTask) {
|
||||
dataDir = "${-> oldClusterTest.nodes[1].dataDir}"
|
||||
}
|
||||
systemProperty 'tests.rest.suite', 'mixed_cluster'
|
||||
systemProperty 'tests.rest.preserve_indices', 'true'
|
||||
finalizedBy 'oldClusterTest#node0.stop'
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,11 @@ import java.io.IOException;
|
||||
@TimeoutSuite(millis = 40 * TimeUnits.MINUTE) // some of the windows test VMs are slow as hell
|
||||
public class UpgradeClusterClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
|
||||
|
||||
@Override
|
||||
protected boolean preserveIndicesUponCompletion() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public UpgradeClusterClientYamlTestSuiteIT(ClientYamlTestCandidate testCandidate) {
|
||||
super(testCandidate);
|
||||
}
|
||||
|
@ -114,6 +114,7 @@ public class ESRestTestCase extends ESTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clean up after the test case.
|
||||
*/
|
||||
@ -138,9 +139,19 @@ public class ESRestTestCase extends ESTestCase {
|
||||
return adminClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether to preserve the indices created during this test on completion of this test.
|
||||
* Defaults to {@code false}. Override this method if indices should be preserved after the test,
|
||||
* with the assumption that some other process or test will clean up the indices afterward.
|
||||
* This is useful if the data directory and indices need to be preserved between test runs
|
||||
* (for example, when testing rolling upgrades).
|
||||
*/
|
||||
protected boolean preserveIndicesUponCompletion() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void wipeCluster() throws IOException {
|
||||
final boolean preserveIndices = Boolean.parseBoolean(System.getProperty("tests.rest.preserve_indices"));
|
||||
if (preserveIndices == false) {
|
||||
if (preserveIndicesUponCompletion() == false) {
|
||||
// wipe indices
|
||||
try {
|
||||
adminClient().performRequest("DELETE", "*");
|
||||
|
Loading…
x
Reference in New Issue
Block a user