forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ESQL: Allow duplicate warnings in some tests (elastic#116199)
This fixes a test, actually in serverless Elasticsearch, that gets duplicate warnings. We'd like not to emit these duplicate warnings, but at this point it isn't worth it. So, for now, in some tests we allow duplicate warnings. In most of our tests we do not allow duplicate warnings so that we don't make *more* duplicate warnings without thinking about it.
- Loading branch information
Showing
7 changed files
with
133 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...lugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/AssertWarnings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.esql; | ||
|
||
import java.util.List; | ||
import java.util.regex.Pattern; | ||
|
||
import static org.elasticsearch.test.ListMatcher.matchesList; | ||
import static org.elasticsearch.test.MapMatcher.assertMap; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
/** | ||
* How should we assert the warnings returned by ESQL. | ||
*/ | ||
public interface AssertWarnings { | ||
void assertWarnings(List<String> warnings); | ||
|
||
record NoWarnings() implements AssertWarnings { | ||
@Override | ||
public void assertWarnings(List<String> warnings) { | ||
assertMap(warnings.stream().sorted().toList(), matchesList()); | ||
} | ||
} | ||
|
||
record ExactStrings(List<String> expected) implements AssertWarnings { | ||
@Override | ||
public void assertWarnings(List<String> warnings) { | ||
assertMap(warnings.stream().sorted().toList(), matchesList(expected.stream().sorted().toList())); | ||
} | ||
} | ||
|
||
record DeduplicatedStrings(List<String> expected) implements AssertWarnings { | ||
@Override | ||
public void assertWarnings(List<String> warnings) { | ||
assertMap(warnings.stream().sorted().distinct().toList(), matchesList(expected.stream().sorted().toList())); | ||
} | ||
} | ||
|
||
record AllowedRegexes(List<Pattern> expected) implements AssertWarnings { | ||
@Override | ||
public void assertWarnings(List<String> warnings) { | ||
for (String warning : warnings) { | ||
assertTrue("Unexpected warning: " + warning, expected.stream().anyMatch(x -> x.matcher(warning).matches())); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters