Skip to content

Commit caa7040

Browse files
committed
Fixup tests
1 parent 84c8772 commit caa7040

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,4 +302,10 @@ protected boolean supportsIndexModeLookup() throws IOException {
302302
protected boolean supportsSourceFieldMapping() {
303303
return false;
304304
}
305+
306+
@Override
307+
protected boolean supportsTook() throws IOException {
308+
// We don't read took properly in multi-cluster tests.
309+
return false;
310+
}
305311
}

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public abstract class EsqlSpecTestCase extends ESRestTestCase {
9292
protected final CsvTestCase testCase;
9393
protected final String instructions;
9494
protected final Mode mode;
95+
protected static Boolean supportsTook;
9596

9697
public enum Mode {
9798
SYNC,
@@ -272,7 +273,7 @@ protected final void doTest() throws Throwable {
272273
builder.tables(tables());
273274
}
274275

275-
Map<?, ?> prevTooks = tooks();
276+
Map<?, ?> prevTooks = supportsTook() ? tooks() : null;
276277
Map<String, Object> answer = runEsql(builder.query(testCase.query), testCase.assertWarnings(deduplicateExactWarnings()));
277278

278279
var expectedColumnsWithValues = loadCsvSpecValues(testCase.expectedResults);
@@ -290,9 +291,12 @@ protected final void doTest() throws Throwable {
290291

291292
assertResults(expectedColumnsWithValues, actualColumns, actualValues, testCase.ignoreOrder, logger);
292293

293-
long took = ((Number) answer.get("took")).longValue();
294-
int prevTookHisto = ((Number) prevTooks.remove(tookKey(took))).intValue();
295-
assertMap(tooks(), matchesMap(prevTooks).entry(tookKey(took), prevTookHisto + 1));
294+
if (supportsTook()) {
295+
LOGGER.info("checking took incremented from {}", prevTooks);
296+
long took = ((Number) answer.get("took")).longValue();
297+
int prevTookHisto = ((Number) prevTooks.remove(tookKey(took))).intValue();
298+
assertMap(tooks(), matchesMap(prevTooks).entry(tookKey(took), prevTookHisto + 1));
299+
}
296300
}
297301

298302
private Map<?, ?> tooks() throws IOException {
@@ -486,6 +490,13 @@ private Map<String, Map<String, RestEsqlTestCase.TypeAndValues>> tables() {
486490
return tables;
487491
}
488492

493+
protected boolean supportsTook() throws IOException {
494+
if (supportsTook == null) {
495+
supportsTook = hasCapabilities(client(), List.of("usage_contains_took"));
496+
}
497+
return supportsTook;
498+
}
499+
489500
private String tookKey(long took) {
490501
if (took < 10) {
491502
return "lt_10ms";

0 commit comments

Comments
 (0)