-
Notifications
You must be signed in to change notification settings - Fork 24.6k
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
Add error indexes to all datetime formatter tests #108944
Conversation
Pinging @elastic/es-core-infra (Team:Core/Infra) |
server/src/main/java/org/elasticsearch/common/time/DateFormatters.java
Outdated
Show resolved
Hide resolved
// sometimes use the java.time date formatters | ||
// we can't use randomBoolean here, the random context isn't set properly | ||
// so read it directly from the test seed in an unfortunately hacky way | ||
String testSeed = System.getProperty("tests.seed", "0"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The seed should already be available in this test context? Just use randomBoolean()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately not, that throws in RandomizedContext.context
saying there's no context info for the thread
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I think this is due to limitations in JUnit 4. Because the Runner is passed an already initialized suite Class, so this static init runs before the Runner can actually setup the context.
@elasticmachine update branch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
String testSeed = System.getProperty("tests.seed", "0"); | ||
boolean firstBit = (Integer.parseInt(testSeed.substring(testSeed.length() - 1), 16) & 1) == 1; | ||
if (firstBit) { | ||
System.setProperty("es.datetime.java_time_parsers", "true"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: it would be good to cover all 3 cases, true, false and not present?
Make sure we check the error index in all dateformatter parse exception tests. As part of this, we need to add a hook enabling us to test both ISO and java.time parser implementations in tests