Skip to content

Commit aef5775

Browse files
authored
re-enables awaitsfixed datemath tests (#38376)
Previously, date formats of `YYYY.MM.dd` would hit an issue where the year would jump towards the end of the calendar year. This was an issue that had since been resolved in tests by using `yyyy` to be the more accurate representation of the year. Closes #37037.
1 parent e4fa324 commit aef5775

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

server/src/test/java/org/elasticsearch/action/admin/indices/rollover/RolloverIT.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -272,46 +272,45 @@ public void testRolloverOnExistingIndex() throws Exception {
272272
}
273273
}
274274

275-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/37037")
276275
public void testRolloverWithDateMath() {
277276
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
278277
assumeTrue("only works on the same day", now.plusMinutes(5).getDayOfYear() == now.getDayOfYear());
279-
String index = "test-" + DateFormatter.forPattern("YYYY.MM.dd").format(now) + "-1";
278+
String index = "test-" + DateFormatter.forPattern("yyyy.MM.dd").format(now) + "-1";
280279
String dateMathExp = "<test-{now/d}-1>";
281280
assertAcked(prepareCreate(dateMathExp).addAlias(new Alias("test_alias")).get());
282281
ensureGreen(index);
283282
// now we modify the provided name such that we can test that the pattern is carried on
284283
client().admin().indices().prepareClose(index).get();
285284
client().admin().indices().prepareUpdateSettings(index).setSettings(Settings.builder()
286285
.put(IndexMetaData.SETTING_INDEX_PROVIDED_NAME,
287-
"<test-{now/M{YYYY.MM}}-1>")).get();
286+
"<test-{now/M{yyyy.MM}}-1>")).get();
288287

289288
client().admin().indices().prepareOpen(index).get();
290289
ensureGreen(index);
291290
RolloverResponse response = client().admin().indices().prepareRolloverIndex("test_alias").get();
292291
assertThat(response.getOldIndex(), equalTo(index));
293-
assertThat(response.getNewIndex(), equalTo("test-" + DateFormatter.forPattern("YYYY.MM").format(now) + "-000002"));
292+
assertThat(response.getNewIndex(), equalTo("test-" + DateFormatter.forPattern("yyyy.MM").format(now) + "-000002"));
294293
assertThat(response.isDryRun(), equalTo(false));
295294
assertThat(response.isRolledOver(), equalTo(true));
296295
assertThat(response.getConditionStatus().size(), equalTo(0));
297296

298297
response = client().admin().indices().prepareRolloverIndex("test_alias").get();
299-
assertThat(response.getOldIndex(), equalTo("test-" + DateFormatter.forPattern("YYYY.MM").format(now) + "-000002"));
300-
assertThat(response.getNewIndex(), equalTo("test-" + DateFormatter.forPattern("YYYY.MM").format(now) + "-000003"));
298+
assertThat(response.getOldIndex(), equalTo("test-" + DateFormatter.forPattern("yyyy.MM").format(now) + "-000002"));
299+
assertThat(response.getNewIndex(), equalTo("test-" + DateFormatter.forPattern("yyyy.MM").format(now) + "-000003"));
301300
assertThat(response.isDryRun(), equalTo(false));
302301
assertThat(response.isRolledOver(), equalTo(true));
303302
assertThat(response.getConditionStatus().size(), equalTo(0));
304303

305304
GetSettingsResponse getSettingsResponse = client().admin().indices().prepareGetSettings(response.getOldIndex(),
306305
response.getNewIndex()).get();
307-
assertEquals("<test-{now/M{YYYY.MM}}-000002>", getSettingsResponse.getSetting(response.getOldIndex(),
306+
assertEquals("<test-{now/M{yyyy.MM}}-000002>", getSettingsResponse.getSetting(response.getOldIndex(),
308307
IndexMetaData.SETTING_INDEX_PROVIDED_NAME));
309-
assertEquals("<test-{now/M{YYYY.MM}}-000003>", getSettingsResponse.getSetting(response.getNewIndex(),
308+
assertEquals("<test-{now/M{yyyy.MM}}-000003>", getSettingsResponse.getSetting(response.getNewIndex(),
310309
IndexMetaData.SETTING_INDEX_PROVIDED_NAME));
311310

312311
response = client().admin().indices().prepareRolloverIndex("test_alias").setNewIndexName("<test-{now/d}-000004>").get();
313-
assertThat(response.getOldIndex(), equalTo("test-" + DateFormatter.forPattern("YYYY.MM").format(now) + "-000003"));
314-
assertThat(response.getNewIndex(), equalTo("test-" + DateFormatter.forPattern("YYYY.MM.dd").format(now) + "-000004"));
312+
assertThat(response.getOldIndex(), equalTo("test-" + DateFormatter.forPattern("yyyy.MM").format(now) + "-000003"));
313+
assertThat(response.getNewIndex(), equalTo("test-" + DateFormatter.forPattern("yyyy.MM.dd").format(now) + "-000004"));
315314
assertThat(response.isDryRun(), equalTo(false));
316315
assertThat(response.isRolledOver(), equalTo(true));
317316
assertThat(response.getConditionStatus().size(), equalTo(0));

server/src/test/java/org/elasticsearch/cluster/metadata/DateMathExpressionResolverTests.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ public void testExpression_MultiParts() throws Exception {
9191
+ DateTimeFormat.forPattern("YYYY.MM.dd").print(new DateTime(context.getStartTime(), UTC).withDayOfMonth(1))));
9292
}
9393

94-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/37037")
9594
public void testExpression_CustomFormat() throws Exception {
9695
List<String> results = expressionResolver.resolve(context, Arrays.asList("<.marvel-{now/d{yyyy.MM.dd}}>"));
9796
assertThat(results.size(), equalTo(1));
@@ -106,7 +105,6 @@ public void testExpression_EscapeStatic() throws Exception {
106105
equalTo(".mar{v}el-" + DateTimeFormat.forPattern("yyyy.MM.dd").print(new DateTime(context.getStartTime(), UTC))));
107106
}
108107

109-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/37037")
110108
public void testExpression_EscapeDateFormat() throws Exception {
111109
List<String> result = expressionResolver.resolve(context, Arrays.asList("<.marvel-{now/d{'\\{year\\}'yyyy}}>"));
112110
assertThat(result.size(), equalTo(1));
@@ -127,7 +125,6 @@ public void testExpression_MixedArray() throws Exception {
127125
DateTimeFormat.forPattern("YYYY.MM").print(new DateTime(context.getStartTime(), UTC).withDayOfMonth(1))));
128126
}
129127

130-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/37037")
131128
public void testExpression_CustomTimeZoneInIndexName() throws Exception {
132129
DateTimeZone timeZone;
133130
int hoursOffset;

0 commit comments

Comments
 (0)