Skip to content

Fix IndexServiceTests sort field test cases#18352

Merged
andrross merged 1 commit intoopensearch-project:mainfrom
andrross:fix-index-service-sortfield-tests
May 22, 2025
Merged

Fix IndexServiceTests sort field test cases#18352
andrross merged 1 commit intoopensearch-project:mainfrom
andrross:fix-index-service-sortfield-tests

Conversation

@andrross
Copy link
Copy Markdown
Member

As far as I can tell these test cases have never been working as intended. They appear to have been created as a copy-paste error from testIllegalFsyncInterval. They passed because the createIndex call was failing due to setting the translog sync interval to an invalid value, which is what the try-catch was expecting. After removing the invalid setting the tests did not work properly for multiple reasons. I believe I have fixed the tests back to the original intent.

The reason for digging into this test was to remove the deprecated createIndex calls from OpenSearchSingleNodeTestCase which take the now removed type parameter. I will follow up with a separate PR to do that work, as this was a significant enough change to stand on its own.

Related Issues

Related to #10045

Check List

  • Functionality includes testing.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

As far as I can tell these test cases have never been working as
intended. They appear to have been created as a copy-paste error from
`testIllegalFsyncInterval`. They passed because the createIndex call was
failing due to setting the translog sync interval to an invalid value,
which is what the try-catch was expecting. After removing the invalid
setting the tests did not work properly for multiple reasons. I believe
I have fixed the tests back to the original intent.

The reason for digging into this test was to remove the deprecated
`createIndex` calls from OpenSearchSingleNodeTestCase which take the now
removed type parameter. I will follow up with a separate PR to do that
work, as this was a significant enough change to stand on its own.

Signed-off-by: Andrew Ross <andrross@amazon.com>
@andrross
Copy link
Copy Markdown
Member Author

For anyone interesting, the problems I encountered were:

  • Setting SETTING_INDEX_VERSION_CREATED does not work unless forbidPrivateIndexSettings() is overridden to return true
  • The mappings passed to createIndex("test", settings, createTestMapping("integer")) were not the right format, but they were actually being ignored because they were being passed in the parameter slot for the now-removed type parameter which is not used
  • The assertTrue(index.getIndexSortSupplier().get().getSort()[0].getType() == SortField.Type.INT); assertion needs to compare getNumericType() on SortedNumericSortField, not getType() on the parent class.

@github-actions
Copy link
Copy Markdown
Contributor

✅ Gradle check result for 1e94a00: SUCCESS

@codecov
Copy link
Copy Markdown

codecov bot commented May 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 72.60%. Comparing base (631bed4) to head (1e94a00).
Report is 4 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main   #18352      +/-   ##
============================================
+ Coverage     72.53%   72.60%   +0.07%     
- Complexity    67396    67449      +53     
============================================
  Files          5492     5492              
  Lines        311127   311127              
  Branches      45224    45224              
============================================
+ Hits         225680   225907     +227     
+ Misses        67063    66818     -245     
- Partials      18384    18402      +18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rishabhmaurya
Copy link
Copy Markdown
Contributor

these are good catch @andrross

@rishabhmaurya
Copy link
Copy Markdown
Contributor

Setting SETTING_INDEX_VERSION_CREATED does not work unless forbidPrivateIndexSettings() is overridden to return true

I'm wondering if they are working as expected at other places like -

Settings settings = Settings.builder().put(IndexMetadata.SETTING_INDEX_VERSION_CREATED.getKey(), createdVersion).build();

@andrross
Copy link
Copy Markdown
Member Author

Setting SETTING_INDEX_VERSION_CREATED does not work unless forbidPrivateIndexSettings() is overridden to return true

I'm wondering if they are working as expected at other places like -

Settings settings = Settings.builder().put(IndexMetadata.SETTING_INDEX_VERSION_CREATED.getKey(), createdVersion).build();

@rishabhmaurya I don't think that's a problem because the create index call will fail if you try to set a private setting without overriding the behavior. In this case the create index call was failing due to an invalid translog sync interval setting so it never got to the part where it would validate private settings.

@andrross andrross merged commit 33e8155 into opensearch-project:main May 22, 2025
53 of 54 checks passed
@andrross andrross deleted the fix-index-service-sortfield-tests branch May 22, 2025 18:07
tandonks pushed a commit to tandonks/OpenSearch that referenced this pull request Jun 1, 2025
As far as I can tell these test cases have never been working as
intended. They appear to have been created as a copy-paste error from
`testIllegalFsyncInterval`. They passed because the createIndex call was
failing due to setting the translog sync interval to an invalid value,
which is what the try-catch was expecting. After removing the invalid
setting the tests did not work properly for multiple reasons. I believe
I have fixed the tests back to the original intent.

The reason for digging into this test was to remove the deprecated
`createIndex` calls from OpenSearchSingleNodeTestCase which take the now
removed type parameter. I will follow up with a separate PR to do that
work, as this was a significant enough change to stand on its own.

Signed-off-by: Andrew Ross <andrross@amazon.com>
Gagan6164 pushed a commit to Gagan6164/OpenSearch that referenced this pull request Jun 8, 2025
As far as I can tell these test cases have never been working as
intended. They appear to have been created as a copy-paste error from
`testIllegalFsyncInterval`. They passed because the createIndex call was
failing due to setting the translog sync interval to an invalid value,
which is what the try-catch was expecting. After removing the invalid
setting the tests did not work properly for multiple reasons. I believe
I have fixed the tests back to the original intent.

The reason for digging into this test was to remove the deprecated
`createIndex` calls from OpenSearchSingleNodeTestCase which take the now
removed type parameter. I will follow up with a separate PR to do that
work, as this was a significant enough change to stand on its own.

Signed-off-by: Andrew Ross <andrross@amazon.com>
Gagan6164 pushed a commit to Gagan6164/OpenSearch that referenced this pull request Jun 8, 2025
As far as I can tell these test cases have never been working as
intended. They appear to have been created as a copy-paste error from
`testIllegalFsyncInterval`. They passed because the createIndex call was
failing due to setting the translog sync interval to an invalid value,
which is what the try-catch was expecting. After removing the invalid
setting the tests did not work properly for multiple reasons. I believe
I have fixed the tests back to the original intent.

The reason for digging into this test was to remove the deprecated
`createIndex` calls from OpenSearchSingleNodeTestCase which take the now
removed type parameter. I will follow up with a separate PR to do that
work, as this was a significant enough change to stand on its own.

Signed-off-by: Andrew Ross <andrross@amazon.com>
neuenfeldttj pushed a commit to neuenfeldttj/OpenSearch that referenced this pull request Jun 26, 2025
As far as I can tell these test cases have never been working as
intended. They appear to have been created as a copy-paste error from
`testIllegalFsyncInterval`. They passed because the createIndex call was
failing due to setting the translog sync interval to an invalid value,
which is what the try-catch was expecting. After removing the invalid
setting the tests did not work properly for multiple reasons. I believe
I have fixed the tests back to the original intent.

The reason for digging into this test was to remove the deprecated
`createIndex` calls from OpenSearchSingleNodeTestCase which take the now
removed type parameter. I will follow up with a separate PR to do that
work, as this was a significant enough change to stand on its own.

Signed-off-by: Andrew Ross <andrross@amazon.com>Signed-off-by: TJ Neuenfeldt <tjneu@amazon.com>
neuenfeldttj pushed a commit to neuenfeldttj/OpenSearch that referenced this pull request Jun 26, 2025
As far as I can tell these test cases have never been working as
intended. They appear to have been created as a copy-paste error from
`testIllegalFsyncInterval`. They passed because the createIndex call was
failing due to setting the translog sync interval to an invalid value,
which is what the try-catch was expecting. After removing the invalid
setting the tests did not work properly for multiple reasons. I believe
I have fixed the tests back to the original intent.

The reason for digging into this test was to remove the deprecated
`createIndex` calls from OpenSearchSingleNodeTestCase which take the now
removed type parameter. I will follow up with a separate PR to do that
work, as this was a significant enough change to stand on its own.

Signed-off-by: Andrew Ross <andrross@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants