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

Add error indexes to all datetime formatter tests #108944

Merged
merged 7 commits into from
May 28, 2024

Conversation

thecoop
Copy link
Member

@thecoop thecoop commented May 23, 2024

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

@thecoop thecoop added >test Issues or PRs that are addressing/adding tests :Core/Infra/Core Core issues without another label labels May 23, 2024
@thecoop thecoop requested a review from a team May 23, 2024 10:25
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@elasticsearchmachine elasticsearchmachine added Team:Core/Infra Meta label for core/infra team v8.15.0 labels May 23, 2024
// 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");
Copy link
Member

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()

Copy link
Member Author

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

Copy link
Member

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.

@thecoop
Copy link
Member Author

thecoop commented May 24, 2024

@elasticmachine update branch

Copy link
Member

@rjernst rjernst left a 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");
Copy link
Member

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?

@thecoop thecoop merged commit f2c2fc0 into elastic:main May 28, 2024
15 checks passed
@thecoop thecoop deleted the datetime-error-index-tests branch May 28, 2024 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Core Core issues without another label Team:Core/Infra Meta label for core/infra team >test Issues or PRs that are addressing/adding tests v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants