Skip to content

Commit 0b2b638

Browse files
authored
New QA module for heap attack tests (#102833) (#102892)
The heap attack test suite is very special. It deliberately tries to take down Elasticsearch testing instances. When one of Elasticsearch testing instance is terminated, other tests will fail. This PR avoids such noise by adding a new QA module for only heap attack tests.
1 parent 91f6f80 commit 0b2b638

File tree

4 files changed

+33
-14
lines changed

4 files changed

+33
-14
lines changed

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/RestrictedBuildApiService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ private static ListMultimap<Class<?>, String> createLegacyRestTestBasePluginUsag
140140
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:eql:qa:mixed-node");
141141
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:eql:qa:multi-cluster-with-security");
142142
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:esql:qa:security");
143+
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:esql:qa:server:heap-attack");
143144
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:esql:qa:server:multi-node");
144145
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:esql:qa:server:single-node");
145146
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:fleet:qa:rest");
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apply plugin: 'elasticsearch.legacy-yaml-rest-test'
2+
3+
dependencies {
4+
javaRestTestImplementation project(xpackModule('esql:qa:testFixtures'))
5+
}
6+
7+
restResources {
8+
restApi {
9+
include '_common', 'bulk', 'indices', 'esql', 'xpack', 'enrich'
10+
}
11+
}
12+
13+
testClusters.configureEach {
14+
numberOfNodes = 1
15+
testDistribution = 'DEFAULT'
16+
setting 'xpack.license.self_generated.type', 'trial'
17+
setting 'xpack.monitoring.collection.enabled', 'true'
18+
setting 'xpack.security.enabled', 'false'
19+
}
Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* 2.0.
66
*/
77

8-
package org.elasticsearch.xpack.esql.qa.single_node;
8+
package org.elasticsearch.xpack.esql.qa.heap_attack;
99

1010
import org.apache.http.client.config.RequestConfig;
1111
import org.apache.http.util.EntityUtils;
@@ -40,6 +40,7 @@
4040
import static org.elasticsearch.test.MapMatcher.matchesMap;
4141
import static org.hamcrest.Matchers.any;
4242
import static org.hamcrest.Matchers.equalTo;
43+
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
4344
import static org.hamcrest.Matchers.hasSize;
4445

4546
/**
@@ -472,25 +473,23 @@ private void initIndex(String name, String bulk) throws IOException {
472473

473474
Request request = new Request("POST", "/" + name + "/_refresh");
474475
Response response = client().performRequest(request);
475-
assertThat(
476-
EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8),
477-
equalTo("{\"_shards\":{\"total\":2,\"successful\":1,\"failed\":0}}")
478-
);
476+
assertWriteResponse(response);
479477

480478
request = new Request("POST", "/" + name + "/_forcemerge");
481479
request.addParameter("max_num_segments", "1");
482480
response = client().performRequest(request);
483-
assertThat(
484-
EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8),
485-
equalTo("{\"_shards\":{\"total\":2,\"successful\":1,\"failed\":0}}")
486-
);
481+
assertWriteResponse(response);
487482

488483
request = new Request("POST", "/" + name + "/_refresh");
489484
response = client().performRequest(request);
490-
assertThat(
491-
EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8),
492-
equalTo("{\"_shards\":{\"total\":2,\"successful\":1,\"failed\":0}}")
493-
);
485+
assertWriteResponse(response);
486+
}
487+
488+
@SuppressWarnings("unchecked")
489+
private static void assertWriteResponse(Response response) throws IOException {
490+
Map<String, Object> shards = (Map<String, Object>) entityAsMap(response).get("_shards");
491+
assertThat((int) shards.get("successful"), greaterThanOrEqualTo(1));
492+
assertThat(shards.get("failed"), equalTo(0));
494493
}
495494

496495
@Before

x-pack/plugin/esql/qa/server/multi-node/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dependencies {
66

77
restResources {
88
restApi {
9-
include '_common', 'bulk', 'indices', 'esql', 'xpack', 'enrich'
9+
include '_common', 'bulk', 'indices', 'esql', 'xpack'
1010
}
1111
}
1212

0 commit comments

Comments
 (0)