Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecation info for joda-java migration #41956

Merged
merged 54 commits into from May 29, 2019
Merged
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
8f99fc7
initial work
pgomulka May 7, 2019
dbc725c
init version
pgomulka May 8, 2019
937fe06
draft working version
pgomulka May 8, 2019
92dd79f
cleanup
pgomulka May 9, 2019
0ab2a6e
commented code remove
pgomulka May 9, 2019
353af6a
joda deprecation keys
pgomulka May 9, 2019
21255e1
generic deprecation key
pgomulka May 9, 2019
6e85a05
empty lines
pgomulka May 9, 2019
8ca0fee
message fix, prefix8 suggestion
pgomulka May 9, 2019
c94bbe7
fixing test for warnings in headers
pgomulka May 10, 2019
5e7bdb3
do not report deprecation when format starts with 8
pgomulka May 11, 2019
ba913f5
unused improt
pgomulka May 14, 2019
7bc3ea7
remove ignore annotation
pgomulka May 14, 2019
837dea3
field extraction
pgomulka May 20, 2019
23f11f4
changes to support defined format names
pgomulka May 21, 2019
a758afb
change imports
pgomulka May 21, 2019
c282f14
compile fix
pgomulka May 22, 2019
1c1e5bd
disable warning comment change
pgomulka May 22, 2019
160a697
Joda is using format names
pgomulka May 22, 2019
f6776a4
snake case
pgomulka May 22, 2019
9edcc0a
missing snake case name
pgomulka May 22, 2019
f57e855
all names in a set
pgomulka May 22, 2019
03bce11
code style
pgomulka May 22, 2019
e582d38
typo
pgomulka May 22, 2019
8860748
fix failing RangeQueryBuilderTest
pgomulka May 23, 2019
73a19ad
fixing docs tests failing due to joda-java warning
pgomulka May 23, 2019
7461c0f
cleanup
pgomulka May 23, 2019
beaf55b
failing tests
pgomulka May 23, 2019
6f9c402
cleanup and javadoc
pgomulka May 23, 2019
ecc304e
Merge branch '6.8' into feature/deprecation_info_joda
pgomulka May 23, 2019
adf2c49
disable warning check
pgomulka May 23, 2019
3afeae8
warning failing tests
pgomulka May 23, 2019
d61eb70
boostrap file revert
pgomulka May 24, 2019
a23e6e8
old assertion on warning message change
pgomulka May 24, 2019
a64c61b
testing combined patterns and removing duplicates
pgomulka May 24, 2019
c853b72
test failures
pgomulka May 24, 2019
56bc22d
space after ; when combined pattern suggestion
pgomulka May 24, 2019
c4632c8
failing tests
pgomulka May 24, 2019
55a233f
unused import
pgomulka May 24, 2019
9e77047
Update x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpac…
pgomulka May 25, 2019
9b98a79
remove intellij instructions
pgomulka May 25, 2019
aa36731
pipelines support
pgomulka May 26, 2019
3e3c106
failing tests
pgomulka May 26, 2019
f7ee788
checkstyle
pgomulka May 27, 2019
eeaf96c
deprecation issue message change
pgomulka May 27, 2019
0dd1ae1
disable joda deprecation checks by default
pgomulka May 27, 2019
0afb36d
remove failing test cases
pgomulka May 27, 2019
40509ec
use constant instead of string for usePrefix8
pgomulka May 28, 2019
7d3de05
fix tests with warning assertions
pgomulka May 28, 2019
8b82383
remove warning assertion
pgomulka May 28, 2019
85fd30e
IT test failing fix
pgomulka May 28, 2019
fe2f17d
Update x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpac…
pgomulka May 29, 2019
edd0aa1
unused comment and message change
pgomulka May 29, 2019
84608c2
revert resetDeprecationLogger method access
pgomulka May 29, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -36,6 +36,10 @@
import static org.hamcrest.core.IsEqual.equalTo;

public class DateFormatTests extends ESTestCase {
@Override
protected boolean enableJodaDeprecationWarningsCheck() {
return true;
}

public void testParseJoda() {
Function<String, DateTime> jodaFunction = DateFormat.Java.getFunction("MMM dd HH:mm:ss Z",
Expand All @@ -44,6 +48,8 @@ public void testParseJoda() {
.atZone(ZoneId.of("GMT-8"))
.format(DateTimeFormatter.ofPattern("MM dd HH:mm:ss", Locale.ENGLISH)),
equalTo("11 24 01:29:01"));
assertWarnings("'Z' time zone offset/id fails when parsing 'Z' for Zulu timezone. Consider using 'X'. " +
"Prefix your date format with '8' to use the new specifier.");
}

public void testParseJodaDefaultYear() {
Expand Down
Expand Up @@ -34,6 +34,10 @@
import static org.hamcrest.Matchers.is;

public class DateIndexNameProcessorTests extends ESTestCase {
@Override
protected boolean enableJodaDeprecationWarningsCheck() {
return true;
}

public void testJodaPattern() throws Exception {
Function<String, DateTime> function = DateFormat.Java.getFunction("yyyy-MM-dd'T'HH:mm:ss.SSSZ", DateTimeZone.UTC, Locale.ROOT);
Expand All @@ -43,6 +47,11 @@ public void testJodaPattern() throws Exception {
Collections.singletonMap("_field", "2016-04-25T12:24:20.101Z"));
processor.execute(document);
assertThat(document.getSourceAndMetadata().get("_index"), equalTo("<events-{20160425||/y{yyyyMMdd|UTC}}>"));
assertWarnings("'y' year should be replaced with 'u'. Use 'y' for year-of-era.; " +
"'Z' time zone offset/id fails when parsing 'Z' for Zulu timezone. Consider using 'X'. " +
"Prefix your date format with '8' to use the new specifier.",
"'y' year should be replaced with 'u'. Use 'y' for year-of-era. " +
"Prefix your date format with '8' to use the new specifier.");
}

public void testTAI64N()throws Exception {
Expand All @@ -53,6 +62,8 @@ public void testTAI64N()throws Exception {
Collections.singletonMap("_field", (randomBoolean() ? "@" : "") + "4000000050d506482dbdf024"));
dateProcessor.execute(document);
assertThat(document.getSourceAndMetadata().get("_index"), equalTo("<events-{20121222||/m{yyyyMMdd|UTC}}>"));
assertWarnings("'y' year should be replaced with 'u'. Use 'y' for year-of-era. " +
"Prefix your date format with '8' to use the new specifier.");
}

public void testUnixMs()throws Exception {
Expand All @@ -68,6 +79,8 @@ public void testUnixMs()throws Exception {
Collections.singletonMap("_field", 1000500L));
dateProcessor.execute(document);
assertThat(document.getSourceAndMetadata().get("_index"), equalTo("<events-{19700101||/m{yyyyMMdd|UTC}}>"));
assertWarnings("'y' year should be replaced with 'u'. Use 'y' for year-of-era. " +
"Prefix your date format with '8' to use the new specifier.");
}

public void testUnix()throws Exception {
Expand All @@ -78,6 +91,8 @@ public void testUnix()throws Exception {
Collections.singletonMap("_field", "1000.5"));
dateProcessor.execute(document);
assertThat(document.getSourceAndMetadata().get("_index"), equalTo("<events-{19700101||/m{yyyyMMdd|UTC}}>"));
assertWarnings("'y' year should be replaced with 'u'. Use 'y' for year-of-era. " +
"Prefix your date format with '8' to use the new specifier.");
}

public void testTemplatedFields() throws Exception {
Expand All @@ -98,6 +113,14 @@ public void testTemplatedFields() throws Exception {
assertThat(document.getSourceAndMetadata().get("_index"),
equalTo("<"+indexNamePrefix+"{"+DateTimeFormat.forPattern(indexNameFormat)
.print(dateTimeFunction.apply(date))+"||/"+dateRounding+"{"+indexNameFormat+"|UTC}}>"));
if (indexNameFormat.equals("yyyy-MM-dd'T'HH:mm:ss.SSSZ")) {
assertWarnings("'y' year should be replaced with 'u'. Use 'y' for year-of-era.; " +
"'Z' time zone offset/id fails when parsing 'Z' for Zulu timezone. Consider using 'X'. " +
"Prefix your date format with '8' to use the new specifier.");
} else {
assertWarnings("'y' year should be replaced with 'u'. Use 'y' for year-of-era. " +
"Prefix your date format with '8' to use the new specifier.");
}
}

public void testJodaTimeDeprecation() throws Exception {
Expand All @@ -112,10 +135,11 @@ public void testJodaTimeDeprecation() throws Exception {
Collections.singletonMap("_field", date));
dateProcessor.execute(document);

assertWarnings("Use of 'Y' (year-of-era) will change to 'y' in the next major version of Elasticsearch." +
" Prefix your date format with '8' to use the new specifier.");
assertThat(document.getSourceAndMetadata().get("_index"),
is("<foo-{2019-01-31T12:34:56.789+0000||/M{" + indexNameFormat + "|UTC}}>"));
assertWarnings("'Y' year-of-era should be replaced with 'y'. Use 'Y' for week-based-year.; " +
"'Z' time zone offset/id fails when parsing 'Z' for Zulu timezone. Consider using 'X'. " +
"Prefix your date format with '8' to use the new specifier.");
}

private DateIndexNameProcessor createProcessor(String field, List<Function<String, DateTime>> dateFormats,
Expand Down
Expand Up @@ -39,6 +39,10 @@
import static org.hamcrest.CoreMatchers.equalTo;

public class DateProcessorTests extends ESTestCase {
@Override
protected boolean enableJodaDeprecationWarningsCheck() {
return true;
}

private TemplateScript.Factory templatize(Locale locale) {
return new TestTemplateService.MockTemplateScript.Factory(locale.getLanguage());
Expand All @@ -58,6 +62,8 @@ public void testJodaPattern() {
IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), document);
dateProcessor.execute(ingestDocument);
assertThat(ingestDocument.getFieldValue("date_as_date", String.class), equalTo("2010-06-12T11:05:15.000+02:00"));
assertWarnings("'y' year should be replaced with 'u'. Use 'y' for year-of-era. " +
"Prefix your date format with '8' to use the new specifier.");
}

public void testJodaPatternMultipleFormats() {
Expand Down Expand Up @@ -96,6 +102,8 @@ public void testJodaPatternMultipleFormats() {
} catch(IllegalArgumentException e) {
assertThat(e.getMessage(), containsString("unable to parse date [2010]"));
}
assertWarnings("'y' year should be replaced with 'u'. Use 'y' for year-of-era. " +
"Prefix your date format with '8' to use the new specifier.");
}

public void testInvalidJodaPattern() {
Expand Down Expand Up @@ -124,6 +132,8 @@ public void testJodaPatternLocale() {
IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), document);
dateProcessor.execute(ingestDocument);
assertThat(ingestDocument.getFieldValue("date_as_date", String.class), equalTo("2010-06-12T00:00:00.000+02:00"));
assertWarnings("'y' year should be replaced with 'u'. Use 'y' for year-of-era. " +
"Prefix your date format with '8' to use the new specifier.");
}

public void testJodaPatternDefaultYear() {
Expand Down
Expand Up @@ -47,7 +47,7 @@

- do:
warnings:
- "Use of 'Y' (year-of-era) will change to 'y' in the next major version of Elasticsearch. Prefix your date format with '8' to use the new specifier."
- "'Y' year-of-era should be replaced with 'y'. Use 'Y' for week-based-year. Prefix your date format with '8' to use the new specifier."
index:
index: test
type: test
Expand Down