Skip to content

Commit b284c41

Browse files
committed
Removed overloads without ProfileLogger, and implemented it on other tests
1 parent 0eae933 commit b284c41

File tree

11 files changed

+87
-52
lines changed

11 files changed

+87
-52
lines changed

x-pack/plugin/esql/qa/server/multi-clusters/src/javaRestTest/java/org/elasticsearch/xpack/esql/ccq/MultiClustersIT.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@
2121
import org.elasticsearch.test.cluster.ElasticsearchCluster;
2222
import org.elasticsearch.test.rest.ESRestTestCase;
2323
import org.elasticsearch.test.rest.TestFeatureService;
24+
import org.elasticsearch.xpack.esql.AssertWarnings;
25+
import org.elasticsearch.xpack.esql.qa.rest.ProfileLogger;
2426
import org.elasticsearch.xpack.esql.qa.rest.RestEsqlTestCase;
2527
import org.junit.After;
2628
import org.junit.Before;
2729
import org.junit.ClassRule;
30+
import org.junit.Rule;
2831
import org.junit.rules.RuleChain;
2932
import org.junit.rules.TestRule;
3033

@@ -57,6 +60,9 @@ public class MultiClustersIT extends ESRestTestCase {
5760
@ClassRule
5861
public static TestRule clusterRule = RuleChain.outerRule(remoteCluster).around(localCluster);
5962

63+
@Rule(order = Integer.MIN_VALUE)
64+
public ProfileLogger profileLogger = new ProfileLogger();
65+
6066
private static TestFeatureService remoteFeaturesService;
6167

6268
@Override
@@ -199,9 +205,9 @@ protected boolean supportsAsync() {
199205

200206
private Map<String, Object> runEsql(RestEsqlTestCase.RequestObjectBuilder requestObject) throws IOException {
201207
if (supportsAsync()) {
202-
return RestEsqlTestCase.runEsqlAsync(requestObject);
208+
return RestEsqlTestCase.runEsqlAsync(requestObject, new AssertWarnings.NoWarnings(), profileLogger);
203209
} else {
204-
return RestEsqlTestCase.runEsqlSync(requestObject);
210+
return RestEsqlTestCase.runEsqlSync(requestObject, new AssertWarnings.NoWarnings(), profileLogger);
205211
}
206212
}
207213

x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/PushQueriesIT.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@
2121
import org.elasticsearch.test.rest.ESRestTestCase;
2222
import org.elasticsearch.xcontent.XContentType;
2323
import org.elasticsearch.xpack.esql.AssertWarnings;
24+
import org.elasticsearch.xpack.esql.qa.rest.ProfileLogger;
2425
import org.elasticsearch.xpack.esql.qa.rest.RestEsqlTestCase;
2526
import org.hamcrest.Matcher;
2627
import org.junit.Before;
2728
import org.junit.ClassRule;
29+
import org.junit.Rule;
2830

2931
import java.io.IOException;
3032
import java.util.ArrayList;
@@ -55,6 +57,9 @@ public class PushQueriesIT extends ESRestTestCase {
5557
@ClassRule
5658
public static ElasticsearchCluster cluster = Clusters.testCluster(spec -> spec.plugin("inference-service-test"));
5759

60+
@Rule(order = Integer.MIN_VALUE)
61+
public ProfileLogger profileLogger = new ProfileLogger();
62+
5863
@ParametersFactory(argumentFormatting = "%1s")
5964
public static List<Object[]> args() {
6065
return Arrays.stream(Type.values()).map(s -> new Object[] { s }).toList();
@@ -348,7 +353,7 @@ private void testPushQuery(
348353
String replacedQuery = esqlQuery.replaceAll("%value", value).replaceAll("%different_value", differentValue);
349354
RestEsqlTestCase.RequestObjectBuilder builder = requestObjectBuilder().query(replacedQuery + "\n| KEEP test");
350355
builder.profile(true);
351-
Map<String, Object> result = runEsql(builder, new AssertWarnings.NoWarnings(), RestEsqlTestCase.Mode.SYNC);
356+
Map<String, Object> result = runEsql(builder, new AssertWarnings.NoWarnings(), profileLogger, RestEsqlTestCase.Mode.SYNC);
352357
assertResultMap(
353358
result,
354359
getResultMatcher(result).entry(

x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/StoredFieldsSequentialIT.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020
import org.elasticsearch.test.rest.ESRestTestCase;
2121
import org.elasticsearch.xcontent.XContentType;
2222
import org.elasticsearch.xpack.esql.AssertWarnings;
23+
import org.elasticsearch.xpack.esql.qa.rest.ProfileLogger;
2324
import org.elasticsearch.xpack.esql.qa.rest.RestEsqlTestCase;
2425
import org.junit.Before;
2526
import org.junit.ClassRule;
27+
import org.junit.Rule;
2628

2729
import java.io.IOException;
2830
import java.util.List;
@@ -52,6 +54,9 @@ public class StoredFieldsSequentialIT extends ESRestTestCase {
5254
@ClassRule
5355
public static ElasticsearchCluster cluster = Clusters.testCluster();
5456

57+
@Rule(order = Integer.MIN_VALUE)
58+
public ProfileLogger profileLogger = new ProfileLogger();
59+
5560
public void testFetchTen() throws IOException {
5661
testQuery(null, """
5762
FROM test
@@ -106,7 +111,7 @@ private void testQuery(Double percent, String query, int documentsFound, boolean
106111
setPercent(percent);
107112
RestEsqlTestCase.RequestObjectBuilder builder = requestObjectBuilder().query(query);
108113
builder.profile(true);
109-
Map<String, Object> result = runEsql(builder, new AssertWarnings.NoWarnings(), RestEsqlTestCase.Mode.SYNC);
114+
Map<String, Object> result = runEsql(builder, new AssertWarnings.NoWarnings(), profileLogger, RestEsqlTestCase.Mode.SYNC);
110115
assertMap(
111116
result,
112117
matchesMap().entry("documents_found", documentsFound)

x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/TSDBRestEsqlIT.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@
1616
import org.elasticsearch.test.TestClustersThreadFilter;
1717
import org.elasticsearch.test.cluster.ElasticsearchCluster;
1818
import org.elasticsearch.test.rest.ESRestTestCase;
19+
import org.elasticsearch.xpack.esql.AssertWarnings;
1920
import org.elasticsearch.xpack.esql.CsvTestsDataLoader;
21+
import org.elasticsearch.xpack.esql.qa.rest.ProfileLogger;
2022
import org.elasticsearch.xpack.esql.qa.rest.RestEsqlTestCase;
2123
import org.junit.ClassRule;
24+
import org.junit.Rule;
2225

2326
import java.io.IOException;
2427
import java.nio.charset.StandardCharsets;
@@ -36,6 +39,9 @@ public class TSDBRestEsqlIT extends ESRestTestCase {
3639
@ClassRule
3740
public static ElasticsearchCluster cluster = Clusters.testCluster();
3841

42+
@Rule(order = Integer.MIN_VALUE)
43+
public ProfileLogger profileLogger = new ProfileLogger();
44+
3945
@Override
4046
protected String getTestRestCluster() {
4147
return cluster.getHttpAddresses();
@@ -64,7 +70,7 @@ public void testTimeSeriesQuerying() throws IOException {
6470
RestEsqlTestCase.RequestObjectBuilder builder = RestEsqlTestCase.requestObjectBuilder()
6571
.query("FROM k8s | KEEP k8s.pod.name, @timestamp | SORT @timestamp, k8s.pod.name");
6672
builder.pragmas(Settings.builder().put("time_series", true).build());
67-
Map<String, Object> result = runEsqlSync(builder);
73+
Map<String, Object> result = runEsqlSync(builder, new AssertWarnings.NoWarnings(), profileLogger);
6874
@SuppressWarnings("unchecked")
6975
List<Map<?, ?>> columns = (List<Map<?, ?>>) result.get("columns");
7076
assertEquals(2, columns.size());

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/FieldExtractorTestCase.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@
3030
import org.elasticsearch.xcontent.XContentBuilder;
3131
import org.elasticsearch.xcontent.XContentType;
3232
import org.elasticsearch.xcontent.json.JsonXContent;
33+
import org.elasticsearch.xpack.esql.AssertWarnings;
3334
import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
3435
import org.elasticsearch.xpack.esql.core.type.DataType;
3536
import org.elasticsearch.xpack.esql.plugin.QueryPragmas;
3637
import org.hamcrest.Matcher;
38+
import org.junit.Rule;
3739

3840
import java.io.IOException;
3941
import java.math.BigDecimal;
@@ -68,6 +70,9 @@
6870
public abstract class FieldExtractorTestCase extends ESRestTestCase {
6971
private static final Logger logger = LogManager.getLogger(FieldExtractorTestCase.class);
7072

73+
@Rule(order = Integer.MIN_VALUE)
74+
public ProfileLogger profileLogger = new ProfileLogger();
75+
7176
@ParametersFactory(argumentFormatting = "%s")
7277
public static List<Object[]> args() throws Exception {
7378
return List.of(
@@ -336,7 +341,11 @@ public void testEmptyMapping() throws IOException {
336341
assertThat(err, containsString("Unknown column [missing]"));
337342

338343
// TODO this is broken in main too
339-
// Map<String, Object> result = runEsqlSync(new RestEsqlTestCase.RequestObjectBuilder().query("FROM test* | LIMIT 2"));
344+
// Map<String, Object> result = runEsqlSync(
345+
// new RestEsqlTestCase.RequestObjectBuilder().query("FROM test* | LIMIT 2"),
346+
// new AssertWarnings.NoWarnings(),
347+
// profileLogger
348+
// );
340349
// assertResultMap(
341350
// result,
342351
// matchesMap().entry("columns", List.of(columnInfo("f", "unsupported"), columnInfo("f.raw", "unsupported")))
@@ -1777,7 +1786,7 @@ private Map<String, Object> runEsql(String query) throws IOException {
17771786
);
17781787
request.pragmasOk();
17791788
}
1780-
return runEsqlSync(request);
1789+
return runEsqlSync(request, new AssertWarnings.NoWarnings(), profileLogger);
17811790
}
17821791

17831792
protected abstract void canUsePragmasOk();

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RequestIndexFilteringTestCase.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.hamcrest.Matcher;
2020
import org.junit.After;
2121
import org.junit.Assert;
22+
import org.junit.Rule;
2223

2324
import java.io.IOException;
2425
import java.nio.charset.StandardCharsets;
@@ -40,6 +41,9 @@
4041

4142
public abstract class RequestIndexFilteringTestCase extends ESRestTestCase {
4243

44+
@Rule(order = Integer.MIN_VALUE)
45+
public ProfileLogger profileLogger = new ProfileLogger();
46+
4347
@After
4448
public void wipeTestData() throws IOException {
4549
try {
@@ -238,12 +242,18 @@ private static RestEsqlTestCase.RequestObjectBuilder existsFilter(String field)
238242
}
239243

240244
public Map<String, Object> runEsql(RestEsqlTestCase.RequestObjectBuilder requestObject) throws IOException {
241-
return RestEsqlTestCase.runEsql(requestObject, new AssertWarnings.NoWarnings(), RestEsqlTestCase.Mode.SYNC);
245+
return RestEsqlTestCase.runEsql(requestObject, new AssertWarnings.NoWarnings(), profileLogger, RestEsqlTestCase.Mode.SYNC);
242246
}
243247

244248
public Map<String, Object> runEsql(RestEsqlTestCase.RequestObjectBuilder requestObject, boolean checkPartialResults)
245249
throws IOException {
246-
return RestEsqlTestCase.runEsql(requestObject, new AssertWarnings.NoWarnings(), RestEsqlTestCase.Mode.SYNC, checkPartialResults);
250+
return RestEsqlTestCase.runEsql(
251+
requestObject,
252+
new AssertWarnings.NoWarnings(),
253+
profileLogger,
254+
RestEsqlTestCase.Mode.SYNC,
255+
checkPartialResults
256+
);
247257
}
248258

249259
protected void indexTimestampData(int docs, String indexName, String date, String differentiatorFieldName) throws IOException {

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RestEnrichTestCase.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
import org.elasticsearch.core.CheckedConsumer;
1616
import org.elasticsearch.test.rest.ESRestTestCase;
1717
import org.elasticsearch.xcontent.XContentBuilder;
18+
import org.elasticsearch.xpack.esql.AssertWarnings;
1819
import org.junit.After;
1920
import org.junit.Before;
21+
import org.junit.Rule;
2022

2123
import java.io.IOException;
2224
import java.util.Arrays;
@@ -27,6 +29,9 @@
2729

2830
public abstract class RestEnrichTestCase extends ESRestTestCase {
2931

32+
@Rule(order = Integer.MIN_VALUE)
33+
public ProfileLogger profileLogger = new ProfileLogger();
34+
3035
private static final String sourceIndexName = "countries";
3136
private static final String policyName = "countries";
3237

@@ -330,9 +335,9 @@ private Map<String, Object> runEsql(String query, CheckedConsumer<XContentBuilde
330335
}
331336
requestObject.query(query);
332337
if (mode == Mode.ASYNC) {
333-
return RestEsqlTestCase.runEsqlAsync(requestObject);
338+
return RestEsqlTestCase.runEsqlAsync(requestObject, new AssertWarnings.NoWarnings(), profileLogger);
334339
} else {
335-
return RestEsqlTestCase.runEsqlSync(requestObject);
340+
return RestEsqlTestCase.runEsqlSync(requestObject, new AssertWarnings.NoWarnings(), profileLogger);
336341
}
337342
}
338343

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RestEsqlTestCase.java

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,21 +1247,12 @@ public Map<String, Object> runEsql(RequestObjectBuilder requestObject) throws IO
12471247
return runEsql(requestObject, new AssertWarnings.NoWarnings(), profileLogger, mode);
12481248
}
12491249

1250-
public static Map<String, Object> runEsqlSync(RequestObjectBuilder requestObject) throws IOException {
1251-
return runEsqlSync(requestObject, new AssertWarnings.NoWarnings());
1250+
public Map<String, Object> runEsqlSync(RequestObjectBuilder requestObject) throws IOException {
1251+
return runEsqlSync(requestObject, new AssertWarnings.NoWarnings(), profileLogger);
12521252
}
12531253

1254-
public static Map<String, Object> runEsqlAsync(RequestObjectBuilder requestObject) throws IOException {
1255-
return runEsqlAsync(requestObject, randomBoolean(), new AssertWarnings.NoWarnings());
1256-
}
1257-
1258-
public static Map<String, Object> runEsql(
1259-
RequestObjectBuilder requestObject,
1260-
AssertWarnings assertWarnings,
1261-
Mode mode,
1262-
boolean checkPartialResults
1263-
) throws IOException {
1264-
return runEsql(requestObject, assertWarnings, null, mode, checkPartialResults);
1254+
public Map<String, Object> runEsqlAsync(RequestObjectBuilder requestObject) throws IOException {
1255+
return runEsqlAsync(requestObject, randomBoolean(), new AssertWarnings.NoWarnings(), profileLogger);
12651256
}
12661257

12671258
public static Map<String, Object> runEsql(
@@ -1280,21 +1271,15 @@ public static Map<String, Object> runEsql(
12801271
return results;
12811272
}
12821273

1283-
public static Map<String, Object> runEsql(RequestObjectBuilder requestObject, AssertWarnings assertWarnings, Mode mode)
1284-
throws IOException {
1285-
return runEsql(requestObject, assertWarnings, mode, true);
1286-
}
1287-
1288-
public static Map<String, Object> runEsql(RequestObjectBuilder requestObject, AssertWarnings assertWarnings,
1289-
@Nullable ProfileLogger profileLogger, Mode mode)
1290-
throws IOException {
1274+
public static Map<String, Object> runEsql(
1275+
RequestObjectBuilder requestObject,
1276+
AssertWarnings assertWarnings,
1277+
@Nullable ProfileLogger profileLogger,
1278+
Mode mode
1279+
) throws IOException {
12911280
return runEsql(requestObject, assertWarnings, profileLogger, mode, true);
12921281
}
12931282

1294-
public static Map<String, Object> runEsqlSync(RequestObjectBuilder requestObject, AssertWarnings assertWarnings) throws IOException {
1295-
return runEsqlSync(requestObject, assertWarnings, null);
1296-
}
1297-
12981283
public static Map<String, Object> runEsqlSync(
12991284
RequestObjectBuilder requestObject,
13001285
AssertWarnings assertWarnings,
@@ -1319,10 +1304,6 @@ public static Map<String, Object> runEsqlSync(
13191304
return json;
13201305
}
13211306

1322-
public static Map<String, Object> runEsqlAsync(RequestObjectBuilder requestObject, AssertWarnings assertWarnings) throws IOException {
1323-
return runEsqlAsync(requestObject, randomBoolean(), assertWarnings);
1324-
}
1325-
13261307
public static Map<String, Object> runEsqlAsync(
13271308
RequestObjectBuilder requestObject,
13281309
AssertWarnings assertWarnings,
@@ -1331,14 +1312,6 @@ public static Map<String, Object> runEsqlAsync(
13311312
return runEsqlAsync(requestObject, randomBoolean(), assertWarnings, profileLogger);
13321313
}
13331314

1334-
public static Map<String, Object> runEsqlAsync(
1335-
RequestObjectBuilder requestObject,
1336-
boolean keepOnCompletion,
1337-
AssertWarnings assertWarnings
1338-
) throws IOException {
1339-
return runEsqlAsync(requestObject, keepOnCompletion, assertWarnings, null);
1340-
}
1341-
13421315
public static Map<String, Object> runEsqlAsync(
13431316
RequestObjectBuilder requestObject,
13441317
boolean keepOnCompletion,

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RestRerankTestCase.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
import org.elasticsearch.client.Request;
1111
import org.elasticsearch.client.ResponseException;
1212
import org.elasticsearch.test.rest.ESRestTestCase;
13+
import org.elasticsearch.xpack.esql.AssertWarnings;
1314
import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
1415
import org.junit.After;
1516
import org.junit.Before;
17+
import org.junit.Rule;
1618

1719
import java.io.IOException;
1820
import java.util.List;
@@ -24,6 +26,9 @@
2426

2527
public class RestRerankTestCase extends ESRestTestCase {
2628

29+
@Rule(order = Integer.MIN_VALUE)
30+
public ProfileLogger profileLogger = new ProfileLogger();
31+
2732
@Before
2833
public void skipWhenRerankDisabled() throws IOException {
2934
assumeTrue(
@@ -182,11 +187,11 @@ private static List<Map<String, String>> defaultOutputColumns() {
182187

183188
private Map<String, Object> runEsqlQuery(String query) throws IOException {
184189
RestEsqlTestCase.RequestObjectBuilder builder = RestEsqlTestCase.requestObjectBuilder().query(query);
185-
return RestEsqlTestCase.runEsqlSync(builder);
190+
return RestEsqlTestCase.runEsqlSync(builder, new AssertWarnings.NoWarnings(), profileLogger);
186191
}
187192

188193
private Map<String, Object> runEsqlQuery(String query, String params) throws IOException {
189194
RestEsqlTestCase.RequestObjectBuilder builder = RestEsqlTestCase.requestObjectBuilder().query(query).params(params);
190-
return RestEsqlTestCase.runEsqlSync(builder);
195+
return RestEsqlTestCase.runEsqlSync(builder, new AssertWarnings.NoWarnings(), profileLogger);
191196
}
192197
}

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RestSampleTestCase.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
import org.elasticsearch.client.Request;
1111
import org.elasticsearch.client.ResponseException;
1212
import org.elasticsearch.test.rest.ESRestTestCase;
13+
import org.elasticsearch.xpack.esql.AssertWarnings;
1314
import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
1415
import org.hamcrest.Description;
1516
import org.hamcrest.TypeSafeMatcher;
1617
import org.junit.After;
1718
import org.junit.Before;
19+
import org.junit.Rule;
1820

1921
import java.io.IOException;
2022
import java.util.HashSet;
@@ -29,6 +31,9 @@
2931

3032
public class RestSampleTestCase extends ESRestTestCase {
3133

34+
@Rule(order = Integer.MIN_VALUE)
35+
public ProfileLogger profileLogger = new ProfileLogger();
36+
3237
@Before
3338
public void skipWhenSampleDisabled() throws IOException {
3439
assumeTrue(
@@ -111,7 +116,7 @@ private static List<Map<String, String>> defaultOutputColumns() {
111116

112117
private Map<String, Object> runEsqlQuery(String query) throws IOException {
113118
RestEsqlTestCase.RequestObjectBuilder builder = RestEsqlTestCase.requestObjectBuilder().query(query);
114-
return RestEsqlTestCase.runEsqlSync(builder);
119+
return RestEsqlTestCase.runEsqlSync(builder, new AssertWarnings.NoWarnings(), profileLogger);
115120
}
116121

117122
private void createTestIndex() throws IOException {

0 commit comments

Comments
 (0)