Skip to content

Commit 8b78ca1

Browse files
committed
test fixes
1 parent c83f913 commit 8b78ca1

File tree

4 files changed

+28
-48
lines changed

4 files changed

+28
-48
lines changed

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

Lines changed: 24 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,10 @@ public void testBasicEsql() throws IOException {
8080
builder.pragmas(Settings.builder().put("data_partitioning", "shard").build());
8181
}
8282
Map<String, Object> result = runEsql(builder);
83-
assertEquals(3, result.size());
83+
8484
Map<String, String> colA = Map.of("name", "avg(value)", "type", "double");
85-
assertEquals(List.of(colA), result.get("columns"));
86-
assertEquals(List.of(List.of(499.5d)), result.get("values"));
85+
assertResultMap(result, colA, List.of(List.of(499.5d)));
8786
assertTrue(result.containsKey("took"));
88-
assertThat(((Number) result.get("took")).longValue(), greaterThanOrEqualTo(0L));
8987
}
9088

9189
public void testInvalidPragma() throws IOException {
@@ -118,11 +116,8 @@ public void testDoNotLogWithInfo() throws IOException {
118116
setLoggingLevel("INFO");
119117
RequestObjectBuilder builder = requestObjectBuilder().query("ROW DO_NOT_LOG_ME = 1");
120118
Map<String, Object> result = runEsql(builder);
121-
assertEquals(3, result.size());
122-
assertThat(((Integer) result.get("took")).intValue(), greaterThanOrEqualTo(0));
123119
Map<String, String> colA = Map.of("name", "DO_NOT_LOG_ME", "type", "integer");
124-
assertEquals(List.of(colA), result.get("columns"));
125-
assertEquals(List.of(List.of(1)), result.get("values"));
120+
assertResultMap(result, colA, List.of(List.of(1)));
126121
for (int i = 0; i < cluster.getNumNodes(); i++) {
127122
try (InputStream log = cluster.getNodeLog(i, LogType.SERVER)) {
128123
Streams.readAllLines(log, line -> assertThat(line, not(containsString("DO_NOT_LOG_ME"))));
@@ -138,11 +133,8 @@ public void testDoLogWithDebug() throws IOException {
138133
setLoggingLevel("DEBUG");
139134
RequestObjectBuilder builder = requestObjectBuilder().query("ROW DO_LOG_ME = 1");
140135
Map<String, Object> result = runEsql(builder);
141-
assertEquals(3, result.size());
142-
assertThat(((Integer) result.get("took")).intValue(), greaterThanOrEqualTo(0));
143136
Map<String, String> colA = Map.of("name", "DO_LOG_ME", "type", "integer");
144-
assertEquals(List.of(colA), result.get("columns"));
145-
assertEquals(List.of(List.of(1)), result.get("values"));
137+
assertResultMap(result, colA, List.of(List.of(1)));
146138
boolean[] found = new boolean[] { false };
147139
for (int i = 0; i < cluster.getNumNodes(); i++) {
148140
try (InputStream log = cluster.getNodeLog(i, LogType.SERVER)) {
@@ -289,13 +281,11 @@ public void testProfile() throws IOException {
289281
builder.pragmas(Settings.builder().put("data_partitioning", "shard").build());
290282
}
291283
Map<String, Object> result = runEsql(builder);
292-
MapMatcher mapMatcher = matchesMap();
293-
assertMap(
284+
assertResultMap(
294285
result,
295-
mapMatcher.entry("columns", matchesList().item(matchesMap().entry("name", "AVG(value)").entry("type", "double")))
296-
.entry("values", List.of(List.of(499.5d)))
297-
.entry("profile", matchesMap().entry("drivers", instanceOf(List.class)))
298-
.entry("took", greaterThanOrEqualTo(0))
286+
getResultMatcher(result).entry("profile", matchesMap().entry("drivers", instanceOf(List.class))),
287+
matchesList().item(matchesMap().entry("name", "AVG(value)").entry("type", "double")),
288+
equalTo(List.of(List.of(499.5d)))
299289
);
300290

301291
List<List<String>> signatures = new ArrayList<>();
@@ -373,24 +363,19 @@ public void testInlineStatsProfile() throws IOException {
373363
}
374364

375365
Map<String, Object> result = runEsql(builder);
376-
MapMatcher mapMatcher = matchesMap();
377366
ListMatcher values = matchesList();
378367
for (int i = 0; i < 1000; i++) {
379368
values = values.item(matchesList().item("2020-12-12T00:00:00.000Z").item("value" + i).item("value" + i).item(i).item(499.5));
380369
}
381-
assertMap(
370+
assertResultMap(
382371
result,
383-
mapMatcher.entry(
384-
"columns",
385-
matchesList().item(matchesMap().entry("name", "@timestamp").entry("type", "date"))
386-
.item(matchesMap().entry("name", "test").entry("type", "text"))
387-
.item(matchesMap().entry("name", "test.keyword").entry("type", "keyword"))
388-
.item(matchesMap().entry("name", "value").entry("type", "long"))
389-
.item(matchesMap().entry("name", "AVG(value)").entry("type", "double"))
390-
)
391-
.entry("values", values)
392-
.entry("profile", matchesMap().entry("drivers", instanceOf(List.class)))
393-
.entry("took", greaterThanOrEqualTo(0))
372+
getResultMatcher(result).entry("profile", matchesMap().entry("drivers", instanceOf(List.class))),
373+
matchesList().item(matchesMap().entry("name", "@timestamp").entry("type", "date"))
374+
.item(matchesMap().entry("name", "test").entry("type", "text"))
375+
.item(matchesMap().entry("name", "test.keyword").entry("type", "keyword"))
376+
.item(matchesMap().entry("name", "value").entry("type", "long"))
377+
.item(matchesMap().entry("name", "AVG(value)").entry("type", "double")),
378+
values
394379
);
395380

396381
List<List<String>> signatures = new ArrayList<>();
@@ -484,20 +469,15 @@ public void testForceSleepsProfile() throws IOException {
484469
for (int group2 = 0; group2 < 10; group2++) {
485470
expectedValues.add(List.of(1.0, 1, 1, 0, group2));
486471
}
487-
MapMatcher mapMatcher = matchesMap();
488-
assertMap(
472+
assertResultMap(
489473
result,
490-
mapMatcher.entry(
491-
"columns",
492-
matchesList().item(matchesMap().entry("name", "AVG(value)").entry("type", "double"))
493-
.item(matchesMap().entry("name", "MAX(value)").entry("type", "long"))
494-
.item(matchesMap().entry("name", "MIN(value)").entry("type", "long"))
495-
.item(matchesMap().entry("name", "group1").entry("type", "long"))
496-
.item(matchesMap().entry("name", "group2").entry("type", "long"))
497-
)
498-
.entry("values", expectedValues)
499-
.entry("profile", matchesMap().entry("drivers", instanceOf(List.class)))
500-
.entry("took", greaterThanOrEqualTo(0))
474+
getResultMatcher(result).entry("profile", matchesMap().entry("drivers", instanceOf(List.class))),
475+
matchesList().item(matchesMap().entry("name", "AVG(value)").entry("type", "double"))
476+
.item(matchesMap().entry("name", "MAX(value)").entry("type", "long"))
477+
.item(matchesMap().entry("name", "MIN(value)").entry("type", "long"))
478+
.item(matchesMap().entry("name", "group1").entry("type", "long"))
479+
.item(matchesMap().entry("name", "group2").entry("type", "long")),
480+
equalTo(expectedValues)
501481
);
502482

503483
@SuppressWarnings("unchecked")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public void testSimpleIndexFilteringWithEnrich() throws IOException {
232232
| keep *number, geo.dest, _index
233233
| sort geo.dest, _index
234234
""", b -> b.startObject("exists").field("field", "foobar").endObject());
235-
assertResultMap(result, columns, values);
235+
assertResultMap(result, columns, List.of());
236236
}
237237

238238
public void testIndexFilteringWithEnrich_RemoveOneIndex() throws IOException {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ public static RequestObjectBuilder jsonBuilder() throws IOException {
256256

257257
public void testGetAnswer() throws IOException {
258258
Map<String, Object> answer = runEsql(requestObjectBuilder().query("row a = 1, b = 2"));
259-
assertEquals(3, answer.size());
259+
assertEquals(4, answer.size());
260260
assertThat(((Integer) answer.get("took")).intValue(), greaterThanOrEqualTo(0));
261261
Map<String, String> colA = Map.of("name", "a", "type", "integer");
262262
Map<String, String> colB = Map.of("name", "b", "type", "integer");
@@ -301,7 +301,7 @@ public void testNullInAggs() throws IOException {
301301
assertResultMap(
302302
runEsql(builder),
303303
List.of(Map.of("name", "min(value)", "type", "long"), Map.of("name", "group", "type", "long")),
304-
List.of(List.of(0, 0), List.of(1, 1))
304+
List.of(List.of(2, 0), List.of(1, 1))
305305
);
306306
}
307307

x-pack/plugin/security/qa/multi-cluster/src/javaRestTest/java/org/elasticsearch/xpack/remotecluster/CrossClusterEsqlRCS1MissingIndicesIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ record ExpectedCluster(String clusterAlias, String indexExpression, String statu
7979
void assertExpectedClustersForMissingIndicesTests(Map<String, Object> responseMap, List<ExpectedCluster> expected) {
8080
Map<String, ?> clusters = (Map<String, ?>) responseMap.get("_clusters");
8181
assertThat((int) responseMap.get("took"), greaterThan(0));
82-
assertThat((boolean) clusters.get("is_partial"), is(false));
82+
assertThat((boolean) responseMap.get("is_partial"), is(false));
8383

8484
Map<String, ?> detailsMap = (Map<String, ?>) clusters.get("details");
8585
assertThat(detailsMap.size(), is(expected.size()));

0 commit comments

Comments
 (0)