Skip to content

Commit 2c57f5f

Browse files
Make tests more deterministic
1 parent 5855380 commit 2c57f5f

File tree

1 file changed

+9
-9
lines changed
  • x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node

1 file changed

+9
-9
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -793,9 +793,9 @@ public void testDateMathIndexPattern() throws IOException {
793793
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
794794

795795
String[] indices = {
796-
"test-index-" + DateTimeFormatter.ofPattern("yyyy.MM.dd", Locale.ROOT).format(now),
797-
"test-index-" + DateTimeFormatter.ofPattern("yyyy.MM.dd", Locale.ROOT).format(now.minusDays(1)),
798-
"test-index-" + DateTimeFormatter.ofPattern("yyyy.MM.dd", Locale.ROOT).format(now.minusDays(2)) };
796+
"test-index-" + DateTimeFormatter.ofPattern("yyyy", Locale.ROOT).format(now),
797+
"test-index-" + DateTimeFormatter.ofPattern("yyyy", Locale.ROOT).format(now.minusYears(1)),
798+
"test-index-" + DateTimeFormatter.ofPattern("yyyy", Locale.ROOT).format(now.minusYears(2)) };
799799

800800
int idx = 0;
801801
for (String index : indices) {
@@ -810,7 +810,7 @@ public void testDateMathIndexPattern() throws IOException {
810810

811811
String query = """
812812
{
813-
"query": "from <test-index-{now/d}> | sort f asc | limit 1 | keep f"
813+
"query": "from <test-index-{now/d{yyyy}}> | sort f asc | limit 1 | keep f"
814814
}
815815
""";
816816
Request request = new Request("POST", "/_query");
@@ -824,7 +824,7 @@ public void testDateMathIndexPattern() throws IOException {
824824

825825
query = """
826826
{
827-
"query": "from <test-index-{now/d-1d}> | sort f asc | limit 1 | keep f"
827+
"query": "from <test-index-{now/d-1y{yyyy}}> | sort f asc | limit 1 | keep f"
828828
}
829829
""";
830830
request = new Request("POST", "/_query");
@@ -860,8 +860,8 @@ public void testDateMathInJoin() throws IOException {
860860
assertOK(client().performRequest(request));
861861

862862
String[] lookupIndices = {
863-
"lookup-index-" + DateTimeFormatter.ofPattern("yyyy.MM.dd", Locale.ROOT).format(now),
864-
"lookup-index-" + DateTimeFormatter.ofPattern("yyyy.MM.dd", Locale.ROOT).format(now.minusDays(1)) };
863+
"lookup-index-" + DateTimeFormatter.ofPattern("yyyy", Locale.ROOT).format(now),
864+
"lookup-index-" + DateTimeFormatter.ofPattern("yyyy", Locale.ROOT).format(now.minusYears(1)) };
865865

866866
for (String index : lookupIndices) {
867867
createIndex(index, Settings.builder().put("mode", "lookup").build(), """
@@ -880,8 +880,8 @@ public void testDateMathInJoin() throws IOException {
880880
}
881881

882882
String[] queries = {
883-
"from idx | lookup join <lookup-index-{now/d}> on key | limit 1",
884-
"from idx | lookup join <lookup-index-{now/d-1d}> on key | limit 1" };
883+
"from idx | lookup join <lookup-index-{now/d{yyyy}}> on key | limit 1",
884+
"from idx | lookup join <lookup-index-{now/d-1y{yyyy}}> on key | limit 1" };
885885
for (int i = 0; i < queries.length; i++) {
886886
String queryPayload = "{\"query\": \"" + queries[i] + "\"}";
887887
request = new Request("POST", "/_query");

0 commit comments

Comments
 (0)