From 0e0a88a4641c8d0831c3f1b8e383f0a4ac856f45 Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Thu, 3 Jan 2019 09:31:35 -0500 Subject: [PATCH 1/2] Fix DateMathExpressionResolverTests tests #37037 https://www.juandebravo.com/2015/04/10/java-yyyy-date-format/ In short for the Java SimpleDateFormat class: YYYY is "4 digit year for use with week number notation" yyyy is "4 digit year for use with month day notation" See https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html Roughly, cases with YYYY/YY + W/WW/WWW should be using YYYY/YY, and pretty much everything else wants yyyy/yy. Notably: Joda's DateTimeFormat class is different: https://www.joda.org/joda-time/apidocs/org/joda/time/format/DateTimeFormat.html --- .../java/org/elasticsearch/client/CrudIT.java | 2 +- ...painless-ingest-processor-context.asciidoc | 2 +- docs/reference/api-conventions.asciidoc | 10 +++--- .../reference/monitoring/http-export.asciidoc | 2 +- .../settings/monitoring-settings.asciidoc | 2 +- .../sql/functions/date-time.asciidoc | 2 +- .../src/main/resources/patterns/grok-patterns | 2 +- .../script/mustache/MustacheTests.java | 4 +-- .../test/ingest/20_combine_processors.yml | 2 +- .../index/mapper/DocumentParser.java | 2 +- .../time/format/StrictISODateTimeFormat.java | 14 ++++---- .../admin/indices/rollover/RolloverIT.java | 18 +++++----- .../DateMathExpressionResolverTests.java | 33 +++++++++---------- .../rounding/TimeZoneRoundingTests.java | 2 +- .../common/time/DateFormattersTests.java | 12 +++---- ...DateMathIndexExpressionsIntegrationIT.java | 18 +++++----- .../JodaCompatibleZonedDateTimeTests.java | 4 +-- .../aggregations/bucket/DateHistogramIT.java | 2 +- x-pack/docs/en/watcher/release-notes.asciidoc | 2 +- .../xpack/core/scheduler/Cron.java | 2 +- .../watcher/history/HistoryStoreField.java | 2 +- .../xpack/monitoring/exporter/Exporter.java | 2 +- .../AbstractIndicesCleanerTestCase.java | 4 +-- .../MonitoringTemplateUtilsTests.java | 4 +-- .../exporter/http/HttpExporterIT.java | 4 +-- .../local/LocalExporterIntegTests.java | 4 +-- .../monitoring/integration/MonitoringIT.java | 2 +- .../authz/AuthorizationServiceTests.java | 8 ++--- .../authz/IndicesAndAliasesResolverTests.java | 4 +-- .../test/security/authz/13_index_datemath.yml | 8 ++--- .../elasticsearch/xpack/watcher/Watcher.java | 2 +- .../build.gradle | 4 +-- 32 files changed, 91 insertions(+), 94 deletions(-) diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java index 59135204c5be1..bca67504d4c23 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java @@ -1169,7 +1169,7 @@ private void validateBulkResponses(int nbItems, boolean[] errors, BulkResponse b public void testUrlEncode() throws IOException { String indexPattern = ""; String expectedIndex = "logstash-" + - DateTimeFormat.forPattern("YYYY.MM.dd").print(new DateTime(DateTimeZone.UTC).monthOfYear().roundFloorCopy()); + DateTimeFormat.forPattern("yyyy.MM.dd").print(new DateTime(DateTimeZone.UTC).monthOfYear().roundFloorCopy()); { IndexRequest indexRequest = new IndexRequest(indexPattern).id("id#1"); indexRequest.source("field", "value"); diff --git a/docs/painless/painless-contexts/painless-ingest-processor-context.asciidoc b/docs/painless/painless-contexts/painless-ingest-processor-context.asciidoc index 546057ab1a0b8..fcc0350a3e3bc 100644 --- a/docs/painless/painless-contexts/painless-ingest-processor-context.asciidoc +++ b/docs/painless/painless-contexts/painless-ingest-processor-context.asciidoc @@ -47,7 +47,7 @@ To run this example, first follow the steps in The seat data contains: -* A date in the format `YYYY-MM-DD` where the second digit of both month and day +* A date in the format `yyyy-MM-DD` where the second digit of both month and day is optional. * A time in the format HH:MM* where the second digit of both hours and minutes is optional. The star (*) represents either the `String` `AM` or `PM`. diff --git a/docs/reference/api-conventions.asciidoc b/docs/reference/api-conventions.asciidoc index be41c0fdc77e5..d67223832b5ac 100644 --- a/docs/reference/api-conventions.asciidoc +++ b/docs/reference/api-conventions.asciidoc @@ -82,7 +82,7 @@ Where: [horizontal] `static_name`:: is the static text part of the name `date_math_expr`:: is a dynamic date math expression that computes the date dynamically -`date_format`:: is the optional format in which the computed date should be rendered. Defaults to `YYYY.MM.dd`. +`date_format`:: is the optional format in which the computed date should be rendered. Defaults to `yyyy.MM.dd`. `time_zone`:: is the optional time zone . Defaults to `utc`. You must enclose date math index name expressions within angle brackets, and @@ -129,9 +129,9 @@ they resolve to given the current time is 22rd March 2024 noon utc. | Expression |Resolves to | `` | `logstash-2024.03.22` | `` | `logstash-2024.03.01` -| `` | `logstash-2024.03` -| `` | `logstash-2024.02` -| `` | `logstash-2024.03.23` +| `` | `logstash-2024.03` +| `` | `logstash-2024.02` +| `` | `logstash-2024.03.23` |====== To use the characters `{` and `}` in the static part of an index name template, escape them @@ -141,7 +141,7 @@ with a backslash `\`, for example: The following example shows a search request that searches the Logstash indices for the past three days, assuming the indices use the default Logstash index name format, -`logstash-YYYY.MM.dd`. +`logstash-yyyy.MM.dd`. [source,js] ---------------------------------------------------------------------- diff --git a/docs/reference/monitoring/http-export.asciidoc b/docs/reference/monitoring/http-export.asciidoc index fce22bd5d78be..9e96757b5573e 100644 --- a/docs/reference/monitoring/http-export.asciidoc +++ b/docs/reference/monitoring/http-export.asciidoc @@ -39,7 +39,7 @@ xpack.monitoring.exporters: headers: <7> My-Proxy-Header: abc123 My-Other-Thing: [ def456, ... ] - index.name.time_format: YYYY-MM <8> + index.name.time_format: yyyy-MM <8> ---------------------------------- <1> A `local` exporter defined explicitly whose arbitrary name is `my_local`. diff --git a/docs/reference/settings/monitoring-settings.asciidoc b/docs/reference/settings/monitoring-settings.asciidoc index 56bfaf5d4f863..863d7c963ee26 100644 --- a/docs/reference/settings/monitoring-settings.asciidoc +++ b/docs/reference/settings/monitoring-settings.asciidoc @@ -244,7 +244,7 @@ anything defined here. `index.name.time_format`:: A mechanism for changing the default date suffix for the, by default, daily Monitoring indices. -The default value is `YYYY.MM.DD`, which is why the indices are created daily. +The default value is `yyyy.MM.DD`, which is why the indices are created daily. `use_ingest`:: diff --git a/docs/reference/sql/functions/date-time.asciidoc b/docs/reference/sql/functions/date-time.asciidoc index 416e927903961..c7b657f005464 100644 --- a/docs/reference/sql/functions/date-time.asciidoc +++ b/docs/reference/sql/functions/date-time.asciidoc @@ -23,7 +23,7 @@ The table below shows the mapping between {es} and {es-sql}: s|{es} s|{es-sql} 2+h| Index/Table date math -2+| +2+| 2+h| Query date math | 1y | INTERVAL 1 YEAR | 2M | INTERVAL 2 MONTH diff --git a/libs/grok/src/main/resources/patterns/grok-patterns b/libs/grok/src/main/resources/patterns/grok-patterns index 6351a7710164e..144fd3b67267a 100644 --- a/libs/grok/src/main/resources/patterns/grok-patterns +++ b/libs/grok/src/main/resources/patterns/grok-patterns @@ -62,7 +62,7 @@ MINUTE (?:[0-5][0-9]) # '60' is a leap second in most time standards and thus is valid. SECOND (?:(?:[0-5]?[0-9]|60)(?:[:.,][0-9]+)?) TIME (?!<[0-9])%{HOUR}:%{MINUTE}(?::%{SECOND})(?![0-9]) -# datestamp is YYYY/MM/DD-HH:MM:SS.UUUU (or something like it) +# datestamp is yyyy/MM/DD-HH:MM:SS.UUUU (or something like it) DATE_US %{MONTHNUM}[/-]%{MONTHDAY}[/-]%{YEAR} DATE_EU %{MONTHDAY}[./-]%{MONTHNUM}[./-]%{YEAR} ISO8601_TIMEZONE (?:Z|[+-]%{HOUR}(?::?%{MINUTE})) diff --git a/modules/lang-mustache/src/test/java/org/elasticsearch/script/mustache/MustacheTests.java b/modules/lang-mustache/src/test/java/org/elasticsearch/script/mustache/MustacheTests.java index 354d92500904c..2972eb10dad1b 100644 --- a/modules/lang-mustache/src/test/java/org/elasticsearch/script/mustache/MustacheTests.java +++ b/modules/lang-mustache/src/test/java/org/elasticsearch/script/mustache/MustacheTests.java @@ -355,8 +355,8 @@ public void testUrlEncoder() { } public void testUrlEncoderWithParam() throws Exception { - assertScript("{{#url}}{{index}}{{/url}}", singletonMap("index", ""), - equalTo("%3Clogstash-%7Bnow%2Fd%7BYYYY.MM.dd%7C%2B12%3A00%7D%7D%3E")); + assertScript("{{#url}}{{index}}{{/url}}", singletonMap("index", ""), + equalTo("%3Clogstash-%7Bnow%2Fd%7Byyyy.MM.dd%7C%2B12%3A00%7D%7D%3E")); final String random = randomAlphaOfLength(10); assertScript("{{#url}}prefix_{{s}}{{/url}}", singletonMap("s", random), diff --git a/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/20_combine_processors.yml b/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/20_combine_processors.yml index 85fa6db10ed17..3c2280b786557 100644 --- a/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/20_combine_processors.yml +++ b/qa/smoke-test-ingest-with-all-dependencies/src/test/resources/rest-api-spec/test/ingest/20_combine_processors.yml @@ -28,7 +28,7 @@ "date" : { "field" : "timestamp", "target_field" : "timestamp", - "formats" : ["dd/MMM/YYYY:HH:mm:ss Z"] + "formats" : ["dd/MMM/yyyy:HH:mm:ss Z"] } }, { diff --git a/server/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java b/server/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java index 54e59691f80d5..1b95bc5465848 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java @@ -714,7 +714,7 @@ private static Mapper.Builder createBuilderFromDynamicValue(final ParseCont } else if (parseableAsLong == false && parseableAsDouble == false && context.root().dateDetection()) { // We refuse to match pure numbers, which are too likely to be // false positives with date formats that include eg. - // `epoch_millis` or `YYYY` + // `epoch_millis` or `yyyy` for (DateFormatter dateTimeFormatter : context.root().dynamicDateTimeFormatters()) { try { dateTimeFormatter.parseMillis(text); diff --git a/server/src/main/java/org/joda/time/format/StrictISODateTimeFormat.java b/server/src/main/java/org/joda/time/format/StrictISODateTimeFormat.java index aacb7cf330687..2d1b83521ad3e 100644 --- a/server/src/main/java/org/joda/time/format/StrictISODateTimeFormat.java +++ b/server/src/main/java/org/joda/time/format/StrictISODateTimeFormat.java @@ -90,7 +90,7 @@ protected StrictISODateTimeFormat() { *

* This method examines the fields provided and returns an ISO-style * formatter that best fits. This can be useful for outputting - * less-common ISO styles, such as YearMonth (YYYY-MM) or MonthDay (--MM-DD). + * less-common ISO styles, such as YearMonth (yyyy-MM) or MonthDay (--MM-DD). *

* The list provided may have overlapping fields, such as dayOfWeek and * dayOfMonth. In this case, the style is chosen based on the following @@ -234,26 +234,26 @@ private static boolean dateByMonth( bld.append(Constants.ye); if (fields.remove(DateTimeFieldType.monthOfYear())) { if (fields.remove(DateTimeFieldType.dayOfMonth())) { - // YYYY-MM-DD/YYYYMMDD + // yyyy-MM-DD/yyyyMMDD appendSeparator(bld, extended); bld.appendMonthOfYear(2); appendSeparator(bld, extended); bld.appendDayOfMonth(2); } else { - // YYYY-MM/YYYY-MM + // yyyy-MM/yyyy-MM bld.appendLiteral('-'); bld.appendMonthOfYear(2); reducedPrec = true; } } else { if (fields.remove(DateTimeFieldType.dayOfMonth())) { - // YYYY--DD/YYYY--DD (non-iso) + // yyyy--DD/yyyy--DD (non-iso) checkNotStrictISO(fields, strictISO); bld.appendLiteral('-'); bld.appendLiteral('-'); bld.appendDayOfMonth(2); } else { - // YYYY/YYYY + // yyyy/yyyy reducedPrec = true; } } @@ -299,11 +299,11 @@ private static boolean dateByOrdinal( if (fields.remove(DateTimeFieldType.year())) { bld.append(Constants.ye); if (fields.remove(DateTimeFieldType.dayOfYear())) { - // YYYY-DDD/YYYYDDD + // yyyy-DDD/yyyyDDD appendSeparator(bld, extended); bld.appendDayOfYear(3); } else { - // YYYY/YYYY + // yyyy/yyyy reducedPrec = true; } diff --git a/server/src/test/java/org/elasticsearch/action/admin/indices/rollover/RolloverIT.java b/server/src/test/java/org/elasticsearch/action/admin/indices/rollover/RolloverIT.java index 6b8d1ab4fafb7..eb904035d371f 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/indices/rollover/RolloverIT.java +++ b/server/src/test/java/org/elasticsearch/action/admin/indices/rollover/RolloverIT.java @@ -276,7 +276,7 @@ public void testRolloverOnExistingIndex() throws Exception { public void testRolloverWithDateMath() { ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC); assumeTrue("only works on the same day", now.plusMinutes(5).getDayOfYear() == now.getDayOfYear()); - String index = "test-" + DateFormatters.forPattern("YYYY.MM.dd").format(now) + "-1"; + String index = "test-" + DateFormatters.forPattern("yyyy.MM.dd").format(now) + "-1"; String dateMathExp = ""; assertAcked(prepareCreate(dateMathExp).addAlias(new Alias("test_alias")).get()); ensureGreen(index); @@ -284,34 +284,34 @@ public void testRolloverWithDateMath() { client().admin().indices().prepareClose(index).get(); client().admin().indices().prepareUpdateSettings(index).setSettings(Settings.builder() .put(IndexMetaData.SETTING_INDEX_PROVIDED_NAME, - "")).get(); + "")).get(); client().admin().indices().prepareOpen(index).get(); ensureGreen(index); RolloverResponse response = client().admin().indices().prepareRolloverIndex("test_alias").get(); assertThat(response.getOldIndex(), equalTo(index)); - assertThat(response.getNewIndex(), equalTo("test-" + DateFormatters.forPattern("YYYY.MM").format(now) + "-000002")); + assertThat(response.getNewIndex(), equalTo("test-" + DateFormatters.forPattern("yyyy.MM").format(now) + "-000002")); assertThat(response.isDryRun(), equalTo(false)); assertThat(response.isRolledOver(), equalTo(true)); assertThat(response.getConditionStatus().size(), equalTo(0)); response = client().admin().indices().prepareRolloverIndex("test_alias").get(); - assertThat(response.getOldIndex(), equalTo("test-" + DateFormatters.forPattern("YYYY.MM").format(now) + "-000002")); - assertThat(response.getNewIndex(), equalTo("test-" + DateFormatters.forPattern("YYYY.MM").format(now) + "-000003")); + assertThat(response.getOldIndex(), equalTo("test-" + DateFormatters.forPattern("yyyy.MM").format(now) + "-000002")); + assertThat(response.getNewIndex(), equalTo("test-" + DateFormatters.forPattern("yyyy.MM").format(now) + "-000003")); assertThat(response.isDryRun(), equalTo(false)); assertThat(response.isRolledOver(), equalTo(true)); assertThat(response.getConditionStatus().size(), equalTo(0)); GetSettingsResponse getSettingsResponse = client().admin().indices().prepareGetSettings(response.getOldIndex(), response.getNewIndex()).get(); - assertEquals("", getSettingsResponse.getSetting(response.getOldIndex(), + assertEquals("", getSettingsResponse.getSetting(response.getOldIndex(), IndexMetaData.SETTING_INDEX_PROVIDED_NAME)); - assertEquals("", getSettingsResponse.getSetting(response.getNewIndex(), + assertEquals("", getSettingsResponse.getSetting(response.getNewIndex(), IndexMetaData.SETTING_INDEX_PROVIDED_NAME)); response = client().admin().indices().prepareRolloverIndex("test_alias").setNewIndexName("").get(); - assertThat(response.getOldIndex(), equalTo("test-" + DateFormatters.forPattern("YYYY.MM").format(now) + "-000003")); - assertThat(response.getNewIndex(), equalTo("test-" + DateFormatters.forPattern("YYYY.MM.dd").format(now) + "-000004")); + assertThat(response.getOldIndex(), equalTo("test-" + DateFormatters.forPattern("yyyy.MM").format(now) + "-000003")); + assertThat(response.getNewIndex(), equalTo("test-" + DateFormatters.forPattern("yyyy.MM.dd").format(now) + "-000004")); assertThat(response.isDryRun(), equalTo(false)); assertThat(response.isRolledOver(), equalTo(true)); assertThat(response.getConditionStatus().size(), equalTo(0)); diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/DateMathExpressionResolverTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/DateMathExpressionResolverTests.java index 5c67e1bbe566c..b130e753e57d8 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/DateMathExpressionResolverTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/DateMathExpressionResolverTests.java @@ -64,11 +64,11 @@ public void testExpression() throws Exception { List result = expressionResolver.resolve(context, indexExpressions); assertThat(result.size(), equalTo(3)); assertThat(result.get(0), - equalTo(".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(new DateTime(context.getStartTime(), UTC)))); + equalTo(".marvel-" + DateTimeFormat.forPattern("yyyy.MM.dd").print(new DateTime(context.getStartTime(), UTC)))); assertThat(result.get(1), - equalTo(".watch_history-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(new DateTime(context.getStartTime(), UTC)))); + equalTo(".watch_history-" + DateTimeFormat.forPattern("yyyy.MM.dd").print(new DateTime(context.getStartTime(), UTC)))); assertThat(result.get(2), - equalTo("logstash-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(new DateTime(context.getStartTime(), UTC)))); + equalTo("logstash-" + DateTimeFormat.forPattern("yyyy.MM.dd").print(new DateTime(context.getStartTime(), UTC)))); } public void testEmpty() throws Exception { @@ -86,48 +86,45 @@ public void testExpression_MultiParts() throws Exception { List result = expressionResolver.resolve(context, Arrays.asList("<.text1-{now/d}-text2-{now/M}>")); assertThat(result.size(), equalTo(1)); assertThat(result.get(0), equalTo(".text1-" - + DateTimeFormat.forPattern("YYYY.MM.dd").print(new DateTime(context.getStartTime(), UTC)) + + DateTimeFormat.forPattern("yyyy.MM.dd").print(new DateTime(context.getStartTime(), UTC)) + "-text2-" - + DateTimeFormat.forPattern("YYYY.MM.dd").print(new DateTime(context.getStartTime(), UTC).withDayOfMonth(1)))); + + DateTimeFormat.forPattern("yyyy.MM.dd").print(new DateTime(context.getStartTime(), UTC).withDayOfMonth(1)))); } - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/37037") public void testExpression_CustomFormat() throws Exception { - List results = expressionResolver.resolve(context, Arrays.asList("<.marvel-{now/d{YYYY.MM.dd}}>")); + List results = expressionResolver.resolve(context, Arrays.asList("<.marvel-{now/d{yyyy.MM.dd}}>")); assertThat(results.size(), equalTo(1)); assertThat(results.get(0), - equalTo(".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(new DateTime(context.getStartTime(), UTC)))); + equalTo(".marvel-" + DateTimeFormat.forPattern("yyyy.MM.dd").print(new DateTime(context.getStartTime(), UTC)))); } public void testExpression_EscapeStatic() throws Exception { List result = expressionResolver.resolve(context, Arrays.asList("<.mar\\{v\\}el-{now/d}>")); assertThat(result.size(), equalTo(1)); assertThat(result.get(0), - equalTo(".mar{v}el-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(new DateTime(context.getStartTime(), UTC)))); + equalTo(".mar{v}el-" + DateTimeFormat.forPattern("yyyy.MM.dd").print(new DateTime(context.getStartTime(), UTC)))); } - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/37037") public void testExpression_EscapeDateFormat() throws Exception { - List result = expressionResolver.resolve(context, Arrays.asList("<.marvel-{now/d{'\\{year\\}'YYYY}}>")); + List result = expressionResolver.resolve(context, Arrays.asList("<.marvel-{now/d{'\\{year\\}'yyyy}}>")); assertThat(result.size(), equalTo(1)); assertThat(result.get(0), - equalTo(".marvel-" + DateTimeFormat.forPattern("'{year}'YYYY").print(new DateTime(context.getStartTime(), UTC)))); + equalTo(".marvel-" + DateTimeFormat.forPattern("'{year}'yyyy").print(new DateTime(context.getStartTime(), UTC)))); } public void testExpression_MixedArray() throws Exception { List result = expressionResolver.resolve(context, Arrays.asList( - "name1", "<.marvel-{now/d}>", "name2", "<.logstash-{now/M{YYYY.MM}}>" + "name1", "<.marvel-{now/d}>", "name2", "<.logstash-{now/M{yyyy.MM}}>" )); assertThat(result.size(), equalTo(4)); assertThat(result.get(0), equalTo("name1")); assertThat(result.get(1), - equalTo(".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(new DateTime(context.getStartTime(), UTC)))); + equalTo(".marvel-" + DateTimeFormat.forPattern("yyyy.MM.dd").print(new DateTime(context.getStartTime(), UTC)))); assertThat(result.get(2), equalTo("name2")); assertThat(result.get(3), equalTo(".logstash-" + - DateTimeFormat.forPattern("YYYY.MM").print(new DateTime(context.getStartTime(), UTC).withDayOfMonth(1)))); + DateTimeFormat.forPattern("yyyy.MM").print(new DateTime(context.getStartTime(), UTC).withDayOfMonth(1)))); } - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/37037") public void testExpression_CustomTimeZoneInIndexName() throws Exception { DateTimeZone timeZone; int hoursOffset; @@ -150,10 +147,10 @@ public void testExpression_CustomTimeZoneInIndexName() throws Exception { now = DateTime.now(UTC).withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0); } Context context = new Context(this.context.getState(), this.context.getOptions(), now.getMillis()); - List results = expressionResolver.resolve(context, Arrays.asList("<.marvel-{now/d{YYYY.MM.dd|" + timeZone.getID() + "}}>")); + List results = expressionResolver.resolve(context, Arrays.asList("<.marvel-{now/d{yyyy.MM.dd|" + timeZone.getID() + "}}>")); assertThat(results.size(), equalTo(1)); logger.info("timezone: [{}], now [{}], name: [{}]", timeZone, now, results.get(0)); - assertThat(results.get(0), equalTo(".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(now.withZone(timeZone)))); + assertThat(results.get(0), equalTo(".marvel-" + DateTimeFormat.forPattern("yyyy.MM.dd").print(now.withZone(timeZone)))); } public void testExpressionInvalidUnescaped() throws Exception { diff --git a/server/src/test/java/org/elasticsearch/common/rounding/TimeZoneRoundingTests.java b/server/src/test/java/org/elasticsearch/common/rounding/TimeZoneRoundingTests.java index e49f25772a726..430ec166a0679 100644 --- a/server/src/test/java/org/elasticsearch/common/rounding/TimeZoneRoundingTests.java +++ b/server/src/test/java/org/elasticsearch/common/rounding/TimeZoneRoundingTests.java @@ -662,7 +662,7 @@ public void testsTimeZoneParsing() { // Formatter used to print and parse the sample date. // Printing the date works but parsing it back fails // with Joda 2.9.4 - DateTimeFormatter formatter = DateTimeFormat.forPattern("YYYY-MM-dd'T'HH:mm:ss " + randomFrom("ZZZ", "[ZZZ]", "'['ZZZ']'")); + DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss " + randomFrom("ZZZ", "[ZZZ]", "'['ZZZ']'")); String dateTimeAsString = formatter.print(expected); assertThat(dateTimeAsString, startsWith("2016-11-10T05:37:59 ")); diff --git a/server/src/test/java/org/elasticsearch/common/time/DateFormattersTests.java b/server/src/test/java/org/elasticsearch/common/time/DateFormattersTests.java index 0f58e30f7a2bf..d594545b98b23 100644 --- a/server/src/test/java/org/elasticsearch/common/time/DateFormattersTests.java +++ b/server/src/test/java/org/elasticsearch/common/time/DateFormattersTests.java @@ -168,20 +168,20 @@ public void testTimeZones() { public void testEqualsAndHashcode() { assertThat(DateFormatters.forPattern("strict_date_optional_time"), sameInstance(DateFormatters.forPattern("strict_date_optional_time"))); - assertThat(DateFormatters.forPattern("YYYY"), equalTo(DateFormatters.forPattern("YYYY"))); - assertThat(DateFormatters.forPattern("YYYY").hashCode(), - is(DateFormatters.forPattern("YYYY").hashCode())); + assertThat(DateFormatters.forPattern("yyyy"), equalTo(DateFormatters.forPattern("yyyy"))); + assertThat(DateFormatters.forPattern("yyyy").hashCode(), + is(DateFormatters.forPattern("yyyy").hashCode())); // different timezone, thus not equals - assertThat(DateFormatters.forPattern("YYYY").withZone(ZoneId.of("CET")), not(equalTo(DateFormatters.forPattern("YYYY")))); + assertThat(DateFormatters.forPattern("yyyy").withZone(ZoneId.of("CET")), not(equalTo(DateFormatters.forPattern("yyyy")))); // different locale, thus not equals - DateFormatter f1 = DateFormatters.forPattern("YYYY").withLocale(Locale.CANADA); + DateFormatter f1 = DateFormatters.forPattern("yyyy").withLocale(Locale.CANADA); DateFormatter f2 = f1.withLocale(Locale.FRENCH); assertThat(f1, not(equalTo(f2))); // different pattern, thus not equals - assertThat(DateFormatters.forPattern("YYYY"), not(equalTo(DateFormatters.forPattern("YY")))); + assertThat(DateFormatters.forPattern("yyyy"), not(equalTo(DateFormatters.forPattern("yy")))); DateFormatter epochSecondFormatter = DateFormatters.forPattern("epoch_second"); assertThat(epochSecondFormatter, sameInstance(DateFormatters.forPattern("epoch_second"))); diff --git a/server/src/test/java/org/elasticsearch/indices/DateMathIndexExpressionsIntegrationIT.java b/server/src/test/java/org/elasticsearch/indices/DateMathIndexExpressionsIntegrationIT.java index fe4ab2e363a88..7f610095cfbba 100644 --- a/server/src/test/java/org/elasticsearch/indices/DateMathIndexExpressionsIntegrationIT.java +++ b/server/src/test/java/org/elasticsearch/indices/DateMathIndexExpressionsIntegrationIT.java @@ -44,9 +44,9 @@ public class DateMathIndexExpressionsIntegrationIT extends ESIntegTestCase { public void testIndexNameDateMathExpressions() { DateTime now = new DateTime(DateTimeZone.UTC); - String index1 = ".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(now); - String index2 = ".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(now.minusDays(1)); - String index3 = ".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(now.minusDays(2)); + String index1 = ".marvel-" + DateTimeFormat.forPattern("yyyy.MM.dd").print(now); + String index2 = ".marvel-" + DateTimeFormat.forPattern("yyyy.MM.dd").print(now.minusDays(1)); + String index3 = ".marvel-" + DateTimeFormat.forPattern("yyyy.MM.dd").print(now.minusDays(2)); createIndex(index1, index2, index3); GetSettingsResponse getSettingsResponse = client().admin().indices().prepareGetSettings(index1, index2, index3).get(); @@ -110,9 +110,9 @@ public void testIndexNameDateMathExpressions() { public void testAutoCreateIndexWithDateMathExpression() throws Exception { DateTime now = new DateTime(DateTimeZone.UTC); - String index1 = ".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(now); - String index2 = ".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(now.minusDays(1)); - String index3 = ".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(now.minusDays(2)); + String index1 = ".marvel-" + DateTimeFormat.forPattern("yyyy.MM.dd").print(now); + String index2 = ".marvel-" + DateTimeFormat.forPattern("yyyy.MM.dd").print(now.minusDays(1)); + String index3 = ".marvel-" + DateTimeFormat.forPattern("yyyy.MM.dd").print(now.minusDays(2)); String dateMathExp1 = "<.marvel-{now/d}>"; String dateMathExp2 = "<.marvel-{now/d-1d}>"; @@ -134,9 +134,9 @@ public void testAutoCreateIndexWithDateMathExpression() throws Exception { public void testCreateIndexWithDateMathExpression() throws Exception { DateTime now = new DateTime(DateTimeZone.UTC); - String index1 = ".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(now); - String index2 = ".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(now.minusDays(1)); - String index3 = ".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(now.minusDays(2)); + String index1 = ".marvel-" + DateTimeFormat.forPattern("yyyy.MM.dd").print(now); + String index2 = ".marvel-" + DateTimeFormat.forPattern("yyyy.MM.dd").print(now.minusDays(1)); + String index3 = ".marvel-" + DateTimeFormat.forPattern("yyyy.MM.dd").print(now.minusDays(2)); String dateMathExp1 = "<.marvel-{now/d}>"; String dateMathExp2 = "<.marvel-{now/d-1d}>"; diff --git a/server/src/test/java/org/elasticsearch/script/JodaCompatibleZonedDateTimeTests.java b/server/src/test/java/org/elasticsearch/script/JodaCompatibleZonedDateTimeTests.java index f01079d092fa7..c6473b786fdd4 100644 --- a/server/src/test/java/org/elasticsearch/script/JodaCompatibleZonedDateTimeTests.java +++ b/server/src/test/java/org/elasticsearch/script/JodaCompatibleZonedDateTimeTests.java @@ -228,8 +228,8 @@ public void testYearOfEra() { } public void testToString1() { - assertMethodDeprecation(() -> assertThat(javaTime.toString("YYYY/MM/dd HH:mm:ss.SSS"), - equalTo(jodaTime.toString("YYYY/MM/dd HH:mm:ss.SSS"))), "toString(String)", "a DateTimeFormatter"); + assertMethodDeprecation(() -> assertThat(javaTime.toString("yyyy/MM/dd HH:mm:ss.SSS"), + equalTo(jodaTime.toString("yyyy/MM/dd HH:mm:ss.SSS"))), "toString(String)", "a DateTimeFormatter"); } public void testToString2() { diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramIT.java b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramIT.java index f65f2bde9662a..10cdd9b4549b1 100644 --- a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramIT.java +++ b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramIT.java @@ -1371,7 +1371,7 @@ public void testFormatIndexUnmapped() throws InterruptedException, ExecutionExce SearchResponse response = client().prepareSearch(indexDateUnmapped) .addAggregation( - dateHistogram("histo").field("dateField").dateHistogramInterval(DateHistogramInterval.MONTH).format("YYYY-MM") + dateHistogram("histo").field("dateField").dateHistogramInterval(DateHistogramInterval.MONTH).format("yyyy-MM") .minDocCount(0).extendedBounds(new ExtendedBounds("2018-01", "2018-01"))) .get(); assertSearchResponse(response); diff --git a/x-pack/docs/en/watcher/release-notes.asciidoc b/x-pack/docs/en/watcher/release-notes.asciidoc index 627c45829d3e2..0efd638c77896 100644 --- a/x-pack/docs/en/watcher/release-notes.asciidoc +++ b/x-pack/docs/en/watcher/release-notes.asciidoc @@ -201,7 +201,7 @@ October 28, 2015 they did before the upgrade. For example if `watcher.dynamic_indices.time_zone` setting was set to `+01:00` and a watch has the following index name `` then after the upgrade you need to update this watch to - use the following index name ``. + use the following index name ``. .New Features * Added new <> diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/scheduler/Cron.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/scheduler/Cron.java index d4ccc22d32ab4..a09054610392b 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/scheduler/Cron.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/scheduler/Cron.java @@ -200,7 +200,7 @@ */ public class Cron implements ToXContentFragment { protected static final TimeZone UTC = DateTimeZone.UTC.toTimeZone(); - protected static final DateTimeFormatter formatter = DateTimeFormat.forPattern("YYYY-MM-dd'T'HH:mm:ss"); + protected static final DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss"); private static final int SECOND = 0; private static final int MINUTE = 1; diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/history/HistoryStoreField.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/history/HistoryStoreField.java index e655be8beff6b..13204e6688ba3 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/history/HistoryStoreField.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/history/HistoryStoreField.java @@ -14,7 +14,7 @@ public final class HistoryStoreField { public static final String INDEX_PREFIX = ".watcher-history-"; public static final String INDEX_PREFIX_WITH_TEMPLATE = INDEX_PREFIX + WatcherIndexTemplateRegistryField.INDEX_TEMPLATE_VERSION + "-"; - static final DateTimeFormatter indexTimeFormat = DateTimeFormat.forPattern("YYYY.MM.dd"); + static final DateTimeFormatter indexTimeFormat = DateTimeFormat.forPattern("yyyy.MM.dd"); /** * Calculates the correct history index name for a given time diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/Exporter.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/Exporter.java index 85a6da15177f9..e509b21d5a93d 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/Exporter.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/Exporter.java @@ -70,7 +70,7 @@ public abstract class Exporter implements AutoCloseable { Setting.affixKeySetting("xpack.monitoring.exporters.","index.name.time_format", (key) -> Setting.simpleString(key, Property.Dynamic, Property.NodeScope)); - private static final String INDEX_FORMAT = "YYYY.MM.dd"; + private static final String INDEX_FORMAT = "yyyy.MM.dd"; protected final Config config; diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/AbstractIndicesCleanerTestCase.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/AbstractIndicesCleanerTestCase.java index 762ab49bba73c..b93326e25d362 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/AbstractIndicesCleanerTestCase.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/AbstractIndicesCleanerTestCase.java @@ -197,7 +197,7 @@ protected void createWatcherHistoryIndex(final DateTime creationDate) { * Creates a watcher history index from the specified version. */ protected void createWatcherHistoryIndex(final DateTime creationDate, final String version) { - final DateTimeFormatter formatter = DateTimeFormat.forPattern("YYYY.MM.dd").withZoneUTC(); + final DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy.MM.dd").withZoneUTC(); final String index = ".watcher-history-" + version + "-" + formatter.print(creationDate.getMillis()); createIndex(index, creationDate); @@ -214,7 +214,7 @@ protected void createTimestampedIndex(DateTime creationDate) { * Creates a monitoring timestamped index using a given template version. */ protected void createTimestampedIndex(DateTime creationDate, String version) { - final DateTimeFormatter formatter = DateTimeFormat.forPattern("YYYY.MM.dd").withZoneUTC(); + final DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy.MM.dd").withZoneUTC(); final String index = ".monitoring-es-" + version + "-" + formatter.print(creationDate.getMillis()); createIndex(index, creationDate); } diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringTemplateUtilsTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringTemplateUtilsTests.java index 5c010439243a0..82c98b4a5f6fe 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringTemplateUtilsTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringTemplateUtilsTests.java @@ -95,7 +95,7 @@ public void testEmptyPipeline() throws IOException { public void testIndexName() { final long timestamp = new DateTime(2017, 8, 3, 13, 47, 58, DateTimeZone.UTC).getMillis(); - DateTimeFormatter formatter = DateTimeFormat.forPattern("YYYY.MM.dd").withZoneUTC(); + DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy.MM.dd").withZoneUTC(); assertThat(indexName(formatter, MonitoredSystem.ES, timestamp), equalTo(".monitoring-es-" + TEMPLATE_VERSION + "-2017.08.03")); assertThat(indexName(formatter, MonitoredSystem.KIBANA, timestamp), @@ -105,7 +105,7 @@ public void testIndexName() { assertThat(indexName(formatter, MonitoredSystem.BEATS, timestamp), equalTo(".monitoring-beats-" + TEMPLATE_VERSION + "-2017.08.03")); - formatter = DateTimeFormat.forPattern("YYYY-dd-MM-HH.mm.ss").withZoneUTC(); + formatter = DateTimeFormat.forPattern("yyyy-dd-MM-HH.mm.ss").withZoneUTC(); assertThat(indexName(formatter, MonitoredSystem.ES, timestamp), equalTo(".monitoring-es-" + TEMPLATE_VERSION + "-2017-03-08-13.47.58")); assertThat(indexName(formatter, MonitoredSystem.KIBANA, timestamp), diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java index 1f9ab90e86542..3114195c20655 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java @@ -350,7 +350,7 @@ public void testDynamicIndexFormatChange() throws Exception { remoteClusterAllowsWatcher, currentLicenseAllowsWatcher, watcherAlreadyExists); MockRequest recordedRequest = assertBulk(webServer); - String indexName = indexName(DateTimeFormat.forPattern("YYYY.MM.dd").withZoneUTC(), doc.getSystem(), doc.getTimestamp()); + String indexName = indexName(DateTimeFormat.forPattern("yyyy.MM.dd").withZoneUTC(), doc.getSystem(), doc.getTimestamp()); byte[] bytes = recordedRequest.getBody().getBytes(StandardCharsets.UTF_8); Map data = XContentHelper.convertToMap(new BytesArray(bytes), false, XContentType.JSON).v2(); @@ -358,7 +358,7 @@ public void testDynamicIndexFormatChange() throws Exception { Map index = (Map) data.get("index"); assertThat(index.get("_index"), equalTo(indexName)); - String newTimeFormat = randomFrom("YY", "YYYY", "YYYY.MM", "YYYY-MM", "MM.YYYY", "MM"); + String newTimeFormat = randomFrom("yy", "yyyy", "yyyy.MM", "yyyy-MM", "MM.yyyy", "MM"); final Settings newSettings = Settings.builder() .put(settings) diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTests.java index c23ef3c8ee51c..df2f7ba698f09 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTests.java @@ -61,7 +61,7 @@ @ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE, numDataNodes = 1, numClientNodes = 0, transportClientRatio = 0.0, supportsDedicatedMasters = false) public class LocalExporterIntegTests extends LocalExporterIntegTestCase { - private final String indexTimeFormat = randomFrom("YY", "YYYY", "YYYY.MM", "YYYY-MM", "MM.YYYY", "MM", null); + private final String indexTimeFormat = randomFrom("yy", "yyyy", "yyyy.MM", "yyyy-MM", "MM.yyyy", "MM", null); private void stopMonitoring() { // Now disabling the monitoring service, so that no more collection are started @@ -256,7 +256,7 @@ private void checkMonitoringDocs() { .get("xpack.monitoring.exporters._local.index.name.time_format"); assertEquals(indexTimeFormat, customTimeFormat); if (customTimeFormat == null) { - customTimeFormat = "YYYY.MM.dd"; + customTimeFormat = "yyyy.MM.dd"; } DateTimeFormatter dateParser = ISODateTimeFormat.dateTime().withZoneUTC(); diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java index dd45c3e06db5d..4bdba91281e92 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java @@ -275,7 +275,7 @@ private void assertMonitoringDoc(final Map document, assertThat(((Number) source.get("interval_ms")).longValue(), equalTo(interval.getMillis())); - assertThat(index, equalTo(MonitoringTemplateUtils.indexName(DateTimeFormat.forPattern("YYYY.MM.dd").withZoneUTC(), + assertThat(index, equalTo(MonitoringTemplateUtils.indexName(DateTimeFormat.forPattern("yyyy.MM.dd").withZoneUTC(), expectedSystem, ISODateTimeFormat.dateTime().parseMillis(timestamp)))); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java index 2a9d832f0f012..6488086a81a2f 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java @@ -1121,12 +1121,12 @@ public void testAuthorizationOfIndividualBulkItems() { public void testAuthorizationOfIndividualBulkItemsWithDateMath() { final String action = BulkAction.NAME + "[s]"; final BulkItemRequest[] items = { - new BulkItemRequest(1, new IndexRequest("", "doc", "dy1")), + new BulkItemRequest(1, new IndexRequest("", "doc", "dy1")), new BulkItemRequest(2, - new DeleteRequest("", "doc", "dy2")), // resolves to same as above - new BulkItemRequest(3, new IndexRequest("", "doc", "dm1")), + new DeleteRequest("", "doc", "dy2")), // resolves to same as above + new BulkItemRequest(3, new IndexRequest("", "doc", "dm1")), new BulkItemRequest(4, - new DeleteRequest("", "doc", "dm2")), // resolves to same as above + new DeleteRequest("", "doc", "dm2")), // resolves to same as above }; final ShardId shardId = new ShardId("concrete-index", UUID.randomUUID().toString(), 1); final TransportRequest request = new BulkShardRequest(shardId, WriteRequest.RefreshPolicy.IMMEDIATE, items); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java index 83edb189e2935..238fab5a6dc2d 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java @@ -1277,7 +1277,7 @@ public void testUnauthorizedDateMathExpressionIgnoreUnavailableDisallowNoIndices } public void testUnauthorizedDateMathExpressionStrict() { - String expectedIndex = "datetime-" + DateTimeFormat.forPattern("YYYY.MM.dd").print( + String expectedIndex = "datetime-" + DateTimeFormat.forPattern("yyyy.MM.dd").print( new DateTime(DateTimeZone.UTC).monthOfYear().roundFloorCopy()); SearchRequest request = new SearchRequest(""); request.indicesOptions(IndicesOptions.fromOptions(false, randomBoolean(), randomBoolean(), randomBoolean())); @@ -1319,7 +1319,7 @@ public void testMissingDateMathExpressionIgnoreUnavailableDisallowNoIndices() { } public void testMissingDateMathExpressionStrict() { - String expectedIndex = "foobar-" + DateTimeFormat.forPattern("YYYY.MM.dd").print( + String expectedIndex = "foobar-" + DateTimeFormat.forPattern("yyyy.MM.dd").print( new DateTime(DateTimeZone.UTC).monthOfYear().roundFloorCopy()); SearchRequest request = new SearchRequest(""); request.indicesOptions(IndicesOptions.fromOptions(false, randomBoolean(), randomBoolean(), randomBoolean())); diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/security/authz/13_index_datemath.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/security/authz/13_index_datemath.yml index becef57ec4f9a..4eeb62258e75b 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/security/authz/13_index_datemath.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/security/authz/13_index_datemath.yml @@ -58,7 +58,7 @@ teardown: headers: { Authorization: "Basic dGVzdF91c2VyOngtcGFjay10ZXN0LXBhc3N3b3Jk" } # test_user bulk: body: - - '{"index": {"_index": "", "_type": "doc", "_id": "2"}}' + - '{"index": {"_index": "", "_type": "doc", "_id": "2"}}' - '{"name": "doc2"}' - '{"index": {"_index": "", "_type": "doc", "_id": "3"}}' - '{"name": "doc3"}' @@ -94,7 +94,7 @@ teardown: headers: { Authorization: "Basic dGVzdF91c2VyOngtcGFjay10ZXN0LXBhc3N3b3Jk" } # test_user bulk: body: - - '{"index": {"_index": "", "_type": "doc", "_id": "5"}}' + - '{"index": {"_index": "", "_type": "doc", "_id": "5"}}' - '{"name": "doc5"}' - '{"index": {"_index": "", "_type": "doc", "_id": "6"}}' - '{"name": "doc6"}' @@ -120,9 +120,9 @@ teardown: headers: { Authorization: "Basic dGVzdF91c2VyOngtcGFjay10ZXN0LXBhc3N3b3Jk" } # test_user bulk: body: - - '{"index": {"_index": "", "_type": "doc", "_id": "7"}}' + - '{"index": {"_index": "", "_type": "doc", "_id": "7"}}' - '{"name": "doc7"}' - - '{"index": {"_index": "", "_type": "doc", "_id": "8"}}' + - '{"index": {"_index": "", "_type": "doc", "_id": "8"}}' - '{"name": "doc8"}' - match: { errors: true } - match: { items.0.index.status: 403 } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java index 3ea99e5787fe0..ed2a81860c696 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java @@ -645,7 +645,7 @@ static void validAutoCreateIndex(Settings settings, Logger logger) { logger.warn("the [action.auto_create_index] setting is configured to be restrictive [{}]. " + " for the next 6 months daily history indices are allowed to be created, but please make sure" + " that any future history indices after 6 months with the pattern " + - "[.watcher-history-YYYY.MM.dd] are allowed to be created", value); + "[.watcher-history-yyyy.MM.dd] are allowed to be created", value); } // These are all old templates from pre 6.0 era, that need to be deleted diff --git a/x-pack/qa/smoke-test-monitoring-with-watcher/build.gradle b/x-pack/qa/smoke-test-monitoring-with-watcher/build.gradle index 57be337f634f2..d4bf1f836b8b0 100644 --- a/x-pack/qa/smoke-test-monitoring-with-watcher/build.gradle +++ b/x-pack/qa/smoke-test-monitoring-with-watcher/build.gradle @@ -18,10 +18,10 @@ integTestCluster { // exporter settings are configured dynamically in our tests // configure a local exporter, the HTTP exporter is configured via dynamic settings change //setting 'xpack.monitoring.exporters.my_local.type', 'local' - //setting 'xpack.monitoring.exporters.my_local.index.name.time_format', 'YYYY' + //setting 'xpack.monitoring.exporters.my_local.index.name.time_format', 'yyyy' //setting 'xpack.monitoring.exporters.my_http.type', 'http' //setting 'xpack.monitoring.exporters.my_http.host', 'http' - //setting 'xpack.monitoring.exporters.my_http.index.name.time_format', 'YYYY-MM' + //setting 'xpack.monitoring.exporters.my_http.index.name.time_format', 'yyyy-MM' // one of the exporters should configure cluster alerts // setting 'xpack.monitoring.exporters.my_http.cluster_alerts.management.enabled', 'true' } From 0ff919b9a42de76a08d8dd82d7e13598667c5f72 Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Mon, 4 Feb 2019 11:17:21 -0500 Subject: [PATCH 2/2] Revert items per spinscale --- .../grok/src/main/resources/patterns/grok-patterns | 2 +- .../joda/time/format/StrictISODateTimeFormat.java | 14 +++++++------- .../common/time/DateFormattersTests.java | 12 ++++++------ .../core/watcher/history/HistoryStoreField.java | 2 +- .../cleaner/AbstractIndicesCleanerTestCase.java | 4 ++-- .../exporter/MonitoringTemplateUtilsTests.java | 4 ++-- .../monitoring/exporter/http/HttpExporterIT.java | 4 ++-- .../xpack/monitoring/integration/MonitoringIT.java | 2 +- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/libs/grok/src/main/resources/patterns/grok-patterns b/libs/grok/src/main/resources/patterns/grok-patterns index 144fd3b67267a..6351a7710164e 100644 --- a/libs/grok/src/main/resources/patterns/grok-patterns +++ b/libs/grok/src/main/resources/patterns/grok-patterns @@ -62,7 +62,7 @@ MINUTE (?:[0-5][0-9]) # '60' is a leap second in most time standards and thus is valid. SECOND (?:(?:[0-5]?[0-9]|60)(?:[:.,][0-9]+)?) TIME (?!<[0-9])%{HOUR}:%{MINUTE}(?::%{SECOND})(?![0-9]) -# datestamp is yyyy/MM/DD-HH:MM:SS.UUUU (or something like it) +# datestamp is YYYY/MM/DD-HH:MM:SS.UUUU (or something like it) DATE_US %{MONTHNUM}[/-]%{MONTHDAY}[/-]%{YEAR} DATE_EU %{MONTHDAY}[./-]%{MONTHNUM}[./-]%{YEAR} ISO8601_TIMEZONE (?:Z|[+-]%{HOUR}(?::?%{MINUTE})) diff --git a/server/src/main/java/org/joda/time/format/StrictISODateTimeFormat.java b/server/src/main/java/org/joda/time/format/StrictISODateTimeFormat.java index 2d1b83521ad3e..aacb7cf330687 100644 --- a/server/src/main/java/org/joda/time/format/StrictISODateTimeFormat.java +++ b/server/src/main/java/org/joda/time/format/StrictISODateTimeFormat.java @@ -90,7 +90,7 @@ protected StrictISODateTimeFormat() { *

* This method examines the fields provided and returns an ISO-style * formatter that best fits. This can be useful for outputting - * less-common ISO styles, such as YearMonth (yyyy-MM) or MonthDay (--MM-DD). + * less-common ISO styles, such as YearMonth (YYYY-MM) or MonthDay (--MM-DD). *

* The list provided may have overlapping fields, such as dayOfWeek and * dayOfMonth. In this case, the style is chosen based on the following @@ -234,26 +234,26 @@ private static boolean dateByMonth( bld.append(Constants.ye); if (fields.remove(DateTimeFieldType.monthOfYear())) { if (fields.remove(DateTimeFieldType.dayOfMonth())) { - // yyyy-MM-DD/yyyyMMDD + // YYYY-MM-DD/YYYYMMDD appendSeparator(bld, extended); bld.appendMonthOfYear(2); appendSeparator(bld, extended); bld.appendDayOfMonth(2); } else { - // yyyy-MM/yyyy-MM + // YYYY-MM/YYYY-MM bld.appendLiteral('-'); bld.appendMonthOfYear(2); reducedPrec = true; } } else { if (fields.remove(DateTimeFieldType.dayOfMonth())) { - // yyyy--DD/yyyy--DD (non-iso) + // YYYY--DD/YYYY--DD (non-iso) checkNotStrictISO(fields, strictISO); bld.appendLiteral('-'); bld.appendLiteral('-'); bld.appendDayOfMonth(2); } else { - // yyyy/yyyy + // YYYY/YYYY reducedPrec = true; } } @@ -299,11 +299,11 @@ private static boolean dateByOrdinal( if (fields.remove(DateTimeFieldType.year())) { bld.append(Constants.ye); if (fields.remove(DateTimeFieldType.dayOfYear())) { - // yyyy-DDD/yyyyDDD + // YYYY-DDD/YYYYDDD appendSeparator(bld, extended); bld.appendDayOfYear(3); } else { - // yyyy/yyyy + // YYYY/YYYY reducedPrec = true; } diff --git a/server/src/test/java/org/elasticsearch/common/time/DateFormattersTests.java b/server/src/test/java/org/elasticsearch/common/time/DateFormattersTests.java index b6fa347db09ac..e573a2ede6bdb 100644 --- a/server/src/test/java/org/elasticsearch/common/time/DateFormattersTests.java +++ b/server/src/test/java/org/elasticsearch/common/time/DateFormattersTests.java @@ -127,20 +127,20 @@ public void testTimeZones() { public void testEqualsAndHashcode() { assertThat(DateFormatters.forPattern("strict_date_optional_time"), sameInstance(DateFormatters.forPattern("strict_date_optional_time"))); - assertThat(DateFormatters.forPattern("yyyy"), equalTo(DateFormatters.forPattern("yyyy"))); - assertThat(DateFormatters.forPattern("yyyy").hashCode(), - is(DateFormatters.forPattern("yyyy").hashCode())); + assertThat(DateFormatters.forPattern("YYYY"), equalTo(DateFormatters.forPattern("YYYY"))); + assertThat(DateFormatters.forPattern("YYYY").hashCode(), + is(DateFormatters.forPattern("YYYY").hashCode())); // different timezone, thus not equals - assertThat(DateFormatters.forPattern("yyyy").withZone(ZoneId.of("CET")), not(equalTo(DateFormatters.forPattern("yyyy")))); + assertThat(DateFormatters.forPattern("YYYY").withZone(ZoneId.of("CET")), not(equalTo(DateFormatters.forPattern("YYYY")))); // different locale, thus not equals - DateFormatter f1 = DateFormatters.forPattern("yyyy").withLocale(Locale.CANADA); + DateFormatter f1 = DateFormatters.forPattern("YYYY").withLocale(Locale.CANADA); DateFormatter f2 = f1.withLocale(Locale.FRENCH); assertThat(f1, not(equalTo(f2))); // different pattern, thus not equals - assertThat(DateFormatters.forPattern("yyyy"), not(equalTo(DateFormatters.forPattern("yy")))); + assertThat(DateFormatters.forPattern("YYYY"), not(equalTo(DateFormatters.forPattern("YY")))); DateFormatter epochSecondFormatter = DateFormatters.forPattern("epoch_second"); assertThat(epochSecondFormatter, sameInstance(DateFormatters.forPattern("epoch_second"))); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/history/HistoryStoreField.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/history/HistoryStoreField.java index 13204e6688ba3..e655be8beff6b 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/history/HistoryStoreField.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/history/HistoryStoreField.java @@ -14,7 +14,7 @@ public final class HistoryStoreField { public static final String INDEX_PREFIX = ".watcher-history-"; public static final String INDEX_PREFIX_WITH_TEMPLATE = INDEX_PREFIX + WatcherIndexTemplateRegistryField.INDEX_TEMPLATE_VERSION + "-"; - static final DateTimeFormatter indexTimeFormat = DateTimeFormat.forPattern("yyyy.MM.dd"); + static final DateTimeFormatter indexTimeFormat = DateTimeFormat.forPattern("YYYY.MM.dd"); /** * Calculates the correct history index name for a given time diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/AbstractIndicesCleanerTestCase.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/AbstractIndicesCleanerTestCase.java index b93326e25d362..762ab49bba73c 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/AbstractIndicesCleanerTestCase.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/cleaner/AbstractIndicesCleanerTestCase.java @@ -197,7 +197,7 @@ protected void createWatcherHistoryIndex(final DateTime creationDate) { * Creates a watcher history index from the specified version. */ protected void createWatcherHistoryIndex(final DateTime creationDate, final String version) { - final DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy.MM.dd").withZoneUTC(); + final DateTimeFormatter formatter = DateTimeFormat.forPattern("YYYY.MM.dd").withZoneUTC(); final String index = ".watcher-history-" + version + "-" + formatter.print(creationDate.getMillis()); createIndex(index, creationDate); @@ -214,7 +214,7 @@ protected void createTimestampedIndex(DateTime creationDate) { * Creates a monitoring timestamped index using a given template version. */ protected void createTimestampedIndex(DateTime creationDate, String version) { - final DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy.MM.dd").withZoneUTC(); + final DateTimeFormatter formatter = DateTimeFormat.forPattern("YYYY.MM.dd").withZoneUTC(); final String index = ".monitoring-es-" + version + "-" + formatter.print(creationDate.getMillis()); createIndex(index, creationDate); } diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringTemplateUtilsTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringTemplateUtilsTests.java index 82c98b4a5f6fe..5c010439243a0 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringTemplateUtilsTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringTemplateUtilsTests.java @@ -95,7 +95,7 @@ public void testEmptyPipeline() throws IOException { public void testIndexName() { final long timestamp = new DateTime(2017, 8, 3, 13, 47, 58, DateTimeZone.UTC).getMillis(); - DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy.MM.dd").withZoneUTC(); + DateTimeFormatter formatter = DateTimeFormat.forPattern("YYYY.MM.dd").withZoneUTC(); assertThat(indexName(formatter, MonitoredSystem.ES, timestamp), equalTo(".monitoring-es-" + TEMPLATE_VERSION + "-2017.08.03")); assertThat(indexName(formatter, MonitoredSystem.KIBANA, timestamp), @@ -105,7 +105,7 @@ public void testIndexName() { assertThat(indexName(formatter, MonitoredSystem.BEATS, timestamp), equalTo(".monitoring-beats-" + TEMPLATE_VERSION + "-2017.08.03")); - formatter = DateTimeFormat.forPattern("yyyy-dd-MM-HH.mm.ss").withZoneUTC(); + formatter = DateTimeFormat.forPattern("YYYY-dd-MM-HH.mm.ss").withZoneUTC(); assertThat(indexName(formatter, MonitoredSystem.ES, timestamp), equalTo(".monitoring-es-" + TEMPLATE_VERSION + "-2017-03-08-13.47.58")); assertThat(indexName(formatter, MonitoredSystem.KIBANA, timestamp), diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java index 775bd04a3a51f..a6cddcf35d370 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java @@ -352,7 +352,7 @@ public void testDynamicIndexFormatChange() throws Exception { remoteClusterAllowsWatcher, currentLicenseAllowsWatcher, watcherAlreadyExists); MockRequest recordedRequest = assertBulk(webServer); - String indexName = indexName(DateTimeFormat.forPattern("yyyy.MM.dd").withZoneUTC(), doc.getSystem(), doc.getTimestamp()); + String indexName = indexName(DateTimeFormat.forPattern("YYYY.MM.dd").withZoneUTC(), doc.getSystem(), doc.getTimestamp()); byte[] bytes = recordedRequest.getBody().getBytes(StandardCharsets.UTF_8); Map data = XContentHelper.convertToMap(new BytesArray(bytes), false, XContentType.JSON).v2(); @@ -360,7 +360,7 @@ public void testDynamicIndexFormatChange() throws Exception { Map index = (Map) data.get("index"); assertThat(index.get("_index"), equalTo(indexName)); - String newTimeFormat = randomFrom("yy", "yyyy", "yyyy.MM", "yyyy-MM", "MM.yyyy", "MM"); + String newTimeFormat = randomFrom("YY", "YYYY", "YYYY.MM", "YYYY-MM", "MM.YYYY", "MM"); final Settings newSettings = Settings.builder() .put(settings) diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java index 172a93b2c81e3..555f2659113fd 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java @@ -277,7 +277,7 @@ private void assertMonitoringDoc(final Map document, assertThat(((Number) source.get("interval_ms")).longValue(), equalTo(interval.getMillis())); - assertThat(index, equalTo(MonitoringTemplateUtils.indexName(DateTimeFormat.forPattern("yyyy.MM.dd").withZoneUTC(), + assertThat(index, equalTo(MonitoringTemplateUtils.indexName(DateTimeFormat.forPattern("YYYY.MM.dd").withZoneUTC(), expectedSystem, ISODateTimeFormat.dateTime().parseMillis(timestamp))));