Skip to content

Commit 5d9056e

Browse files
committed
test fixes
1 parent c83f913 commit 5d9056e

File tree

6 files changed

+30
-51
lines changed

6 files changed

+30
-51
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 & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import static org.hamcrest.Matchers.containsString;
4545
import static org.hamcrest.Matchers.equalTo;
4646
import static org.hamcrest.Matchers.greaterThan;
47-
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
4847
import static org.hamcrest.Matchers.hasItem;
4948
import static org.hamcrest.Matchers.instanceOf;
5049
import static org.hamcrest.Matchers.not;
@@ -80,12 +79,10 @@ public void testBasicEsql() throws IOException {
8079
builder.pragmas(Settings.builder().put("data_partitioning", "shard").build());
8180
}
8281
Map<String, Object> result = runEsql(builder);
83-
assertEquals(3, result.size());
82+
8483
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"));
84+
assertResultMap(result, colA, List.of(List.of(499.5d)));
8785
assertTrue(result.containsKey("took"));
88-
assertThat(((Number) result.get("took")).longValue(), greaterThanOrEqualTo(0L));
8986
}
9087

9188
public void testInvalidPragma() throws IOException {
@@ -118,11 +115,8 @@ public void testDoNotLogWithInfo() throws IOException {
118115
setLoggingLevel("INFO");
119116
RequestObjectBuilder builder = requestObjectBuilder().query("ROW DO_NOT_LOG_ME = 1");
120117
Map<String, Object> result = runEsql(builder);
121-
assertEquals(3, result.size());
122-
assertThat(((Integer) result.get("took")).intValue(), greaterThanOrEqualTo(0));
123118
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"));
119+
assertResultMap(result, colA, List.of(List.of(1)));
126120
for (int i = 0; i < cluster.getNumNodes(); i++) {
127121
try (InputStream log = cluster.getNodeLog(i, LogType.SERVER)) {
128122
Streams.readAllLines(log, line -> assertThat(line, not(containsString("DO_NOT_LOG_ME"))));
@@ -138,11 +132,8 @@ public void testDoLogWithDebug() throws IOException {
138132
setLoggingLevel("DEBUG");
139133
RequestObjectBuilder builder = requestObjectBuilder().query("ROW DO_LOG_ME = 1");
140134
Map<String, Object> result = runEsql(builder);
141-
assertEquals(3, result.size());
142-
assertThat(((Integer) result.get("took")).intValue(), greaterThanOrEqualTo(0));
143135
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"));
136+
assertResultMap(result, colA, List.of(List.of(1)));
146137
boolean[] found = new boolean[] { false };
147138
for (int i = 0; i < cluster.getNumNodes(); i++) {
148139
try (InputStream log = cluster.getNodeLog(i, LogType.SERVER)) {
@@ -289,13 +280,11 @@ public void testProfile() throws IOException {
289280
builder.pragmas(Settings.builder().put("data_partitioning", "shard").build());
290281
}
291282
Map<String, Object> result = runEsql(builder);
292-
MapMatcher mapMatcher = matchesMap();
293-
assertMap(
283+
assertResultMap(
294284
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))
285+
getResultMatcher(result).entry("profile", matchesMap().entry("drivers", instanceOf(List.class))),
286+
matchesList().item(matchesMap().entry("name", "AVG(value)").entry("type", "double")),
287+
equalTo(List.of(List.of(499.5d)))
299288
);
300289

301290
List<List<String>> signatures = new ArrayList<>();
@@ -373,24 +362,19 @@ public void testInlineStatsProfile() throws IOException {
373362
}
374363

375364
Map<String, Object> result = runEsql(builder);
376-
MapMatcher mapMatcher = matchesMap();
377365
ListMatcher values = matchesList();
378366
for (int i = 0; i < 1000; i++) {
379367
values = values.item(matchesList().item("2020-12-12T00:00:00.000Z").item("value" + i).item("value" + i).item(i).item(499.5));
380368
}
381-
assertMap(
369+
assertResultMap(
382370
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))
371+
getResultMatcher(result).entry("profile", matchesMap().entry("drivers", instanceOf(List.class))),
372+
matchesList().item(matchesMap().entry("name", "@timestamp").entry("type", "date"))
373+
.item(matchesMap().entry("name", "test").entry("type", "text"))
374+
.item(matchesMap().entry("name", "test.keyword").entry("type", "keyword"))
375+
.item(matchesMap().entry("name", "value").entry("type", "long"))
376+
.item(matchesMap().entry("name", "AVG(value)").entry("type", "double")),
377+
values
394378
);
395379

396380
List<List<String>> signatures = new ArrayList<>();
@@ -484,20 +468,15 @@ public void testForceSleepsProfile() throws IOException {
484468
for (int group2 = 0; group2 < 10; group2++) {
485469
expectedValues.add(List.of(1.0, 1, 1, 0, group2));
486470
}
487-
MapMatcher mapMatcher = matchesMap();
488-
assertMap(
471+
assertResultMap(
489472
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))
473+
getResultMatcher(result).entry("profile", matchesMap().entry("drivers", instanceOf(List.class))),
474+
matchesList().item(matchesMap().entry("name", "AVG(value)").entry("type", "double"))
475+
.item(matchesMap().entry("name", "MAX(value)").entry("type", "long"))
476+
.item(matchesMap().entry("name", "MIN(value)").entry("type", "long"))
477+
.item(matchesMap().entry("name", "group1").entry("type", "long"))
478+
.item(matchesMap().entry("name", "group2").entry("type", "long")),
479+
equalTo(expectedValues)
501480
);
502481

503482
@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()));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,14 @@ private void clusterShutDownWithRandomSkipUnavailable() throws Exception {
9494
assertThat((int) map.get("took"), greaterThan(0));
9595
assertThat(columns.size(), is(4));
9696
assertThat(values.size(), is(9));
97+
assertThat((boolean) map.get("is_partial"), is(false));
9798

9899
assertThat((int) clusters.get("total"), is(2));
99100
assertThat((int) clusters.get("successful"), is(2));
100101
assertThat((int) clusters.get("running"), is(0));
101102
assertThat((int) clusters.get("skipped"), is(0));
102103
assertThat((int) clusters.get("partial"), is(0));
103104
assertThat((int) clusters.get("failed"), is(0));
104-
assertThat((boolean) clusters.get("is_partial"), is(false));
105105

106106
assertThat(clusterDetails.size(), is(2));
107107
assertThat((int) localClusterDetails.get("took"), greaterThan(0));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,14 @@ private void clusterShutDownWithRandomSkipUnavailable() throws Exception {
112112
assertThat((int) map.get("took"), greaterThan(0));
113113
assertThat(columns.size(), is(4));
114114
assertThat(values.size(), is(9));
115+
assertThat((boolean) map.get("is_partial"), is(false));
115116

116117
assertThat((int) clusters.get("total"), is(2));
117118
assertThat((int) clusters.get("successful"), is(2));
118119
assertThat((int) clusters.get("running"), is(0));
119120
assertThat((int) clusters.get("skipped"), is(0));
120121
assertThat((int) clusters.get("partial"), is(0));
121122
assertThat((int) clusters.get("failed"), is(0));
122-
assertThat((boolean) clusters.get("is_partial"), is(false));
123123

124124
assertThat(clusterDetails.size(), is(2));
125125
assertThat((int) localClusterDetails.get("took"), greaterThan(0));

0 commit comments

Comments
 (0)