Skip to content

Fix DateMathExpressionResolverTests tests #37037 #37059

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

Closed
wants to merge 3 commits into from

Conversation

jsoref
Copy link
Contributor

@jsoref jsoref commented Dec 31, 2018

https://www.juandebravo.com/2015/04/10/java-yyyy-date-format/

In short:
YYYY is "4 digit year for use with week number notation"
yyyy is "4 digit year for use with month day notation"

#37037

@jsoref
Copy link
Contributor Author

jsoref commented Dec 31, 2018

I lost quite a few hours looking into this. My first commit wasn't a complete fix, there were other instances of YYYY w/ date formatters.

Thanks to freenode #java for the pointer

@jsoref
Copy link
Contributor Author

jsoref commented Dec 31, 2018

@javanna

@javanna javanna added the :Core/Infra/Core Core issues without another label label Jan 2, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

@javanna javanna added the >bug label Jan 2, 2019
@javanna
Copy link
Member

javanna commented Jan 2, 2019

test this please

@javanna
Copy link
Member

javanna commented Jan 2, 2019

@rjernst would you have a chance to look into this one and the related test failures?

@javanna javanna requested a review from rjernst January 2, 2019 09:14
@jsoref
Copy link
Contributor Author

jsoref commented Jan 2, 2019

@javanna, can you ask the bot to retest?

@javanna
Copy link
Member

javanna commented Jan 3, 2019

@jsoref could you also check out and unmute RolloverIT#testRolloverWithDateMath please ?

Copy link
Contributor

@droberts195 droberts195 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few notes about the file structure finder files. Please revert the changes to (only) the file structure finder files in this PR. I know I need to do work on this for 6.7 but it's not quite the same as the other changes in this PR and I would rather separate it out.

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
@jsoref
Copy link
Contributor Author

jsoref commented Jan 3, 2019

@droberts195: done

@droberts195
Copy link
Contributor

Thanks @jsoref.

Next time please push a new commit rather than amending an existing one that someone has commented on, because amending the commit that has comments stops others viewing the full context around the comments. But I can see you've removed all the files related to the file structure finder so don't worry about it this time.

I no longer have an objection to this PR being merged once @rjernst and @javanna are happy.

@javanna javanna dismissed droberts195’s stale review January 3, 2019 19:28

concerns addressed

@javanna
Copy link
Member

javanna commented Jan 3, 2019

retest this please

@javanna
Copy link
Member

javanna commented Jan 4, 2019

run gradle build tests 2

@spinscale
Copy link
Contributor

One of the core issues of the DateMathExpressionResolverTests is to use a Context that uses System.currentTimeInMillis(). One should use a context uses a randomized time for proper reproduction.

+    // some date between 1970 and 2040
+    private final long currentTime = randomLongBetween(0, 2240521200000L);
     private final Context context = new Context(
-            ClusterState.builder(new ClusterName("_name")).build(), IndicesOptions.strictExpand()
+        ClusterState.builder(new ClusterName("_name")).build(), IndicesOptions.strictExpand(), currentTime
     );

@jsoref
Copy link
Contributor Author

jsoref commented Jan 8, 2019

@javanna is this me?

@javanna
Copy link
Member

javanna commented Jan 8, 2019

is this me?

@jsoref I am not sure :) You mean if you should make the change that @spinscale suggested?

@jsoref
Copy link
Contributor Author

jsoref commented Jan 8, 2019

Well, both the last build failure (default-distro) and also that change...

I'm really just trying to make a small incremental change. It shouldn't really be blocked on every possible thing in your codebase... It sounds like @spinscale understands the change -- to me it seems better for that to be authored by @spinscale than by me...

@javanna
Copy link
Member

javanna commented Jan 8, 2019

I agree @jsoref it sounds like the suggested change can be made as a follow-up. I think the build bit that was red is not your fault, I need to re-run it, let me find the magic command to run only that part... ;)

@javanna
Copy link
Member

javanna commented Jan 8, 2019

run sample packaging tests

@javanna
Copy link
Member

javanna commented Jan 8, 2019

ops, wrong one :)

@javanna
Copy link
Member

javanna commented Jan 8, 2019

run default distro tests

1 similar comment
@droberts195
Copy link
Contributor

run default distro tests

@droberts195
Copy link
Contributor

FYI the changes to the structure finder that I said I would do in #37059 (review) are in #37306.

@javanna
Copy link
Member

javanna commented Jan 29, 2019

Is this something that we would like to get in? Is it worth addressing merge conflicts or? Please can you comment @rjernst , @spinscale or re-assign?

@droberts195
Copy link
Contributor

Jenkins test this please

@droberts195
Copy link
Contributor

I think it would be good to get this merged into master before 7.0 and 7.x are branched.

On 31st December 2018 a whole load of CI builds failed due to YYYY meaning week year in Java time. If we don't merge this then this year the same tests will fail on both 30th and 31st December (due to the way week years diverge from "normal" calendar years on 0-3 days).

Also, it's setting a bad example to people who copy the formats from the code if we're still using YYYY in formats that are going to be used by the Java time parser.

I merged latest master into the PR branch to try to progress this.

But I think approval to merge should come from someone who is working on the Java time project.

Copy link
Contributor

@spinscale spinscale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are a few changes that look like they happened by search & replace, that should be reverted

@@ -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
`<logstash-{now/d}>` then after the upgrade you need to update this watch to
use the following index name `<logstash-{now/d{YYYY.MM.dd|+01:00}}>`.
use the following index name `<logstash-{now/d{yyyy.MM.dd|+01:00}}>`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are old release notes, that might be outdated in other ways as well, I am not sure if it is worth updating?

@@ -232,8 +232,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"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am confused by reading this. Shouldnt one be in capital letters and one not in order for this to work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Java time cares significantly about Y vs y. Afaict, Joda time only uses Y vs y to exclude 0 and negative numbers (actually, the documentation I can find differs about whether or not 0 is a valid value, but...).

That said, y in joda is the "year" w/o the constraint, which is a closer map to Java y.

@@ -70,7 +70,7 @@
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";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the monitoring side of things is fixed in #35809

@danielmitterdorfer
Copy link
Member

Thank you for your PR but it seems that this has been fixed meanwhile in #38376. I hope that you understand that I therefore close this PR unmerged.

@jsoref jsoref deleted the year-37037 branch March 8, 2019 16:41
@jsoref
Copy link
Contributor Author

jsoref commented Mar 8, 2019

@danielmitterdorfer: I understand in some ways. At the end of the day, I don't care who gets credit for fixing things -- I just want the thing fixed so it doesn't interfere with whatever I'm actually trying to accomplish.

From a process perspective, I'm disappointed in the way it was managed. Ideally if someone wants to adopt a ticket the previous person working on it should be informed so they can stop worrying about it/working on it. There's clearly enough information in GitHub for this to happen -- both PRs were tied to the same issue. I'm glad to be informed, but a month delay in being informed seems a bit long. I hope you understand that perspective.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Core/Infra/Core Core issues without another label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants