ElasticV6QueryChangesTest: Close indices after test
For each test method, new indices are created with a unique name based on the test method name. This results in 4 indices (i.e. one each for accounts, changes, groups and projects) for each test method that is run, which in turn results in the number of allocated shards increasing. In Elasticsearch 7.0 a shard limit was introduced [1] which so far only causes a warning. However in a future version the limit will be enforced and result in an error. After each test, close the indices that were created. This results in the shards being deallocated, and prevents exceeding the limit. Note that this was originally fixed in Change I6644cf9ee for ES 7.x but the shard limit warning was backported to 6.x with [2] which was included since 6.8.5, so we are now also seeing warnings in the logs when running the tests for V6. [1] https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html#_cluster_wide_shard_soft_limit [2] https://github.com/elastic/elasticsearch/commit/aa8b5e8 Bug: Issue 10120 Change-Id: I61966c28c2640246e7a5edd026aa31d77c8533eb
This commit is contained in:
@@ -21,7 +21,12 @@ import com.google.gerrit.testing.InMemoryModule;
|
||||
import com.google.gerrit.testing.IndexConfig;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.protocol.HttpClientContext;
|
||||
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
|
||||
import org.apache.http.impl.nio.client.HttpAsyncClients;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
@@ -33,6 +38,7 @@ public class ElasticV6QueryChangesTest extends AbstractQueryChangesTest {
|
||||
|
||||
private static ElasticNodeInfo nodeInfo;
|
||||
private static ElasticContainer container;
|
||||
private static CloseableHttpAsyncClient client;
|
||||
|
||||
@BeforeClass
|
||||
public static void startIndexService() {
|
||||
@@ -43,6 +49,8 @@ public class ElasticV6QueryChangesTest extends AbstractQueryChangesTest {
|
||||
|
||||
container = ElasticContainer.createAndStart(ElasticVersion.V6_8);
|
||||
nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
|
||||
client = HttpAsyncClients.createDefault();
|
||||
client.start();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@@ -52,6 +60,16 @@ public class ElasticV6QueryChangesTest extends AbstractQueryChangesTest {
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
public void closeIndex() {
|
||||
client.execute(
|
||||
new HttpPost(
|
||||
String.format(
|
||||
"http://localhost:%d/%s*/_close", nodeInfo.port, getSanitizedMethodName())),
|
||||
HttpClientContext.create(),
|
||||
null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initAfterLifecycleStart() throws Exception {
|
||||
super.initAfterLifecycleStart();
|
||||
|
Reference in New Issue
Block a user