Skip to content

Conversation

Kubik42
Copy link
Contributor

@Kubik42 Kubik42 commented Aug 26, 2025

Related to #132954 and #132948.

This change fixes a previously flaky test, which occasionally failed because we would generate a set of random numbers to use as values for a field, and randomize their types between long and double. However, the actual mapping used in the test hard coded the field type to long. This resulted in inconsistencies between what we saw in the native value fetcher and the doc values value fetcher.

This PR addresses that by randomly selecting a number type to use for the duration of each test case. The mapping then uses said type when its declared.

To verify the change, I used the same gradle command that previously failed in #132948:

./gradlew ":server:test" --tests "org.elasticsearch.index.mapper.LongFieldMapperTests.testFetchMany" -Dtests.seed=CEAC2F82C11D4036 -Dtests.locale=twq -Dtests.timezone=Europe/Luxembourg -Druntime.java=24

@Kubik42 Kubik42 added >non-issue >test Issues or PRs that are addressing/adding tests Team:StorageEngine :StorageEngine/Mapping The storage related side of mappings labels Aug 26, 2025
@Kubik42 Kubik42 marked this pull request as ready for review August 26, 2025 02:51
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-storage-engine (Team:StorageEngine)

@Override
protected void minimalMapping(XContentBuilder b) throws IOException {
b.field("type", "long");
b.field("type", fieldType.toString());
Copy link
Contributor

Choose a reason for hiding this comment

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

Feels wrong to have a "type": "double" in the LongFieldMapperTests. Shouldn't the double tests be in the DoubleFieldMapperTests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

its weird that a test class that tests long is generating doubles. Now that you pointed it out, its probably for verifying conversions, but it should've been more explicit in code.

@jordan-powers
Copy link
Contributor

Looks like this is actually already fixed in #133423

@Kubik42
Copy link
Contributor Author

Kubik42 commented Aug 26, 2025

Closing in favor of #133423

@Kubik42 Kubik42 closed this Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>non-issue :StorageEngine/Mapping The storage related side of mappings Team:StorageEngine >test Issues or PRs that are addressing/adding tests v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants