Skip to content

Commit beb5b04

Browse files
dnhatngmjehovich
authored andcommitted
Fix inlinestats tests in release builds (elastic#134915)
Some InlineStats tests failed in release builds (see elastic#134768). We need to guard these tests with capability checks.
1 parent fe3d24d commit beb5b04

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/AbstractCrossClusterTestCase.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import java.util.concurrent.atomic.AtomicLong;
4646

4747
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
48+
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.INLINESTATS_SUPPORTS_REMOTE;
4849
import static org.hamcrest.Matchers.aMapWithSize;
4950
import static org.hamcrest.Matchers.equalTo;
5051
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
@@ -367,4 +368,8 @@ protected static Exception randomFailure() {
367368
new EsRejectedExecutionException("node is shutting down")
368369
);
369370
}
371+
372+
protected static String randomStats() {
373+
return INLINESTATS_SUPPORTS_REMOTE.isEnabled() ? randomFrom("STATS", "INLINESTATS") : "STATS";
374+
}
370375
}

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/CrossClusterCancellationIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private void createRemoteIndex(int numDocs) throws Exception {
8484
public void testCancel() throws Exception {
8585
createRemoteIndex(between(10, 100));
8686
EsqlQueryRequest request = EsqlQueryRequest.syncEsqlQueryRequest();
87-
String stats = randomFrom("STATS", "INLINESTATS");
87+
String stats = randomStats();
8888
request.query("FROM *:test | " + stats + " total=sum(const) | LIMIT 1");
8989
request.pragmas(randomPragmas());
9090
PlainActionFuture<EsqlQueryResponse> requestFuture = new PlainActionFuture<>();
@@ -162,7 +162,7 @@ public void testSameRemoteClusters() throws Exception {
162162
public void testTasks() throws Exception {
163163
createRemoteIndex(between(10, 100));
164164
EsqlQueryRequest request = EsqlQueryRequest.syncEsqlQueryRequest();
165-
String stats = randomFrom("STATS", "INLINESTATS");
165+
String stats = randomStats();
166166
request.query("FROM *:test | " + stats + " total=sum(const) | LIMIT 1");
167167
request.pragmas(randomPragmas());
168168
ActionFuture<EsqlQueryResponse> requestFuture = client().execute(EsqlQueryAction.INSTANCE, request);
@@ -201,7 +201,7 @@ public void testTasks() throws Exception {
201201
public void testCancelSkipUnavailable() throws Exception {
202202
createRemoteIndex(between(10, 100));
203203
EsqlQueryRequest request = EsqlQueryRequest.syncEsqlQueryRequest();
204-
String stats = randomFrom("STATS", "INLINESTATS");
204+
String stats = randomStats();
205205
request.query("FROM *:test | " + stats + " total=sum(const) | LIMIT 1");
206206
request.pragmas(randomPragmas());
207207
request.includeCCSMetadata(true);

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/CrossClusterQueryIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,7 @@ public void testRemoteFailureSkipUnavailableTrue() throws IOException {
791791
}
792792

793793
public void testRemoteFailureInlinestats() throws IOException {
794+
assumeTrue("requires inlinestats", EsqlCapabilities.Cap.INLINESTATS_SUPPORTS_REMOTE.isEnabled());
794795
Map<String, Object> testClusterInfo = setupFailClusters();
795796
String localIndex = (String) testClusterInfo.get("local.index");
796797
String remote1Index = (String) testClusterInfo.get("remote.index");

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/CrossClusterQueryUnavailableRemotesIT.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ public void testCCSAgainstDisconnectedRemoteWithSkipUnavailableTrue() throws Exc
159159
}
160160

161161
public void testCCSAgainstDisconnectedRemoteWithSkipUnavailableTrueInlinestats() throws Exception {
162+
assumeTrue("requires inlinestats", EsqlCapabilities.Cap.INLINESTATS_SUPPORTS_REMOTE.isEnabled());
162163
int numClusters = 3;
163164
Map<String, Object> testClusterInfo = setupClusters(numClusters);
164165
int localNumShards = (Integer) testClusterInfo.get("local.num_shards");
@@ -289,7 +290,7 @@ public void testRemoteOnlyCCSAgainstDisconnectedRemoteWithSkipUnavailableTrue()
289290
Boolean requestIncludeMeta = includeCCSMetadata.v1();
290291
boolean responseExpectMeta = includeCCSMetadata.v2();
291292

292-
String stats = randomFrom("STATS", "INLINESTATS");
293+
String stats = randomStats();
293294
// query only the REMOTE_CLUSTER_1
294295
try (
295296
EsqlQueryResponse resp = runQuery(
@@ -379,7 +380,7 @@ public void testCCSAgainstDisconnectedRemoteWithSkipUnavailableFalse() throws Ex
379380
Tuple<Boolean, Boolean> includeCCSMetadata = randomIncludeCCSMetadata();
380381
Boolean requestIncludeMeta = includeCCSMetadata.v1();
381382

382-
String stats = randomFrom("STATS", "INLINESTATS");
383+
String stats = randomStats();
383384
final Exception exception = expectThrows(
384385
Exception.class,
385386
() -> runQuery("FROM logs-*,*:logs-* | " + stats + " sum (v) | SORT v", requestIncludeMeta)
@@ -399,7 +400,7 @@ public void testRemoteOnlyCCSAgainstDisconnectedRemoteWithSkipUnavailableFalse()
399400
try {
400401
Tuple<Boolean, Boolean> includeCCSMetadata = randomIncludeCCSMetadata();
401402
Boolean requestIncludeMeta = includeCCSMetadata.v1();
402-
String stats = randomFrom("STATS", "INLINESTATS");
403+
String stats = randomStats();
403404
{
404405
// close the remote cluster so that it is unavailable
405406
cluster(REMOTE_CLUSTER_1).close();

0 commit comments

Comments
 (0)