summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse <dpursehouse@collab.net>2019-12-04 12:46:31 +0900
committerDavid Pursehouse <dpursehouse@collab.net>2019-12-04 12:51:24 +0900
commit53c6c2d393d6d16f6a7bcffd1003320b20e0f90a (patch)
tree22b5594db48d0facacadcc2af90aa81732f32ee0
parent105b303760cc6d25658fd0abc37b70d5992b54f7 (diff)
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
-rw-r--r--javatests/com/google/gerrit/elasticsearch/ElasticV6QueryChangesTest.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/javatests/com/google/gerrit/elasticsearch/ElasticV6QueryChangesTest.java b/javatests/com/google/gerrit/elasticsearch/ElasticV6QueryChangesTest.java
index 08f48396a0..94c5a04901 100644
--- a/javatests/com/google/gerrit/elasticsearch/ElasticV6QueryChangesTest.java
+++ b/javatests/com/google/gerrit/elasticsearch/ElasticV6QueryChangesTest.java
@@ -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();