Skip to content

Commit e5d82c3

Browse files
authored
Test: Fix dv date bwc tests when no docs have a value (#32798)
This commit adds a guard around the rare case that no documents in the 10 iterations actually have any values, thus making the warning check incorrect. closes #32779
1 parent 770ad53 commit e5d82c3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

server/src/test/java/org/elasticsearch/index/fielddata/ScriptDocValuesDatesTests.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ public void testJavaTime() throws IOException {
4747
assertDateDocValues(true);
4848
}
4949

50-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/32779")
5150
public void testJodaTimeBwc() throws IOException {
5251
assertDateDocValues(false, "The joda time api for doc values is deprecated." +
5352
" Use -Des.scripting.use_java_time=true to use the java time api for date field doc values");
@@ -71,6 +70,7 @@ public void assertDateDocValues(boolean useJavaTime, String... expectedWarnings)
7170
}
7271
}
7372

73+
7474
Set<String> warnings = new HashSet<>();
7575
Dates dates = wrap(values, deprecationMessage -> {
7676
warnings.add(deprecationMessage);
@@ -86,12 +86,14 @@ public void assertDateDocValues(boolean useJavaTime, String... expectedWarnings)
8686
}
8787
);
8888

89+
boolean valuesExist = false;
8990
for (int round = 0; round < 10; round++) {
9091
int d = between(0, values.length - 1);
9192
dates.setNextDocId(d);
9293
if (expectedDates[d].length > 0) {
9394
Object dateValue = AccessController.doPrivileged((PrivilegedAction<Object>) dates::getValue, noPermissionsAcc);
9495
assertEquals(expectedDates[d][0] , dateValue);
96+
valuesExist = true;
9597
} else {
9698
Exception e = expectThrows(IllegalStateException.class, () -> dates.getValue());
9799
assertEquals("A document doesn't have a value for a field! " +
@@ -106,7 +108,9 @@ public void assertDateDocValues(boolean useJavaTime, String... expectedWarnings)
106108
}
107109
}
108110

109-
assertThat(warnings, containsInAnyOrder(expectedWarnings));
111+
if (valuesExist) {
112+
assertThat(warnings, containsInAnyOrder(expectedWarnings));
113+
}
110114
}
111115

112116
private Dates wrap(long[][] values, Consumer<String> deprecationHandler, boolean useJavaTime) {

0 commit comments

Comments
 (0)