Skip to content

Reduce number of indices created in ClusterSettingsIT#20681

Merged
andrross merged 1 commit intoopensearch-project:mainfrom
andrross:fix-flaky-ClusterSettingsIT
Feb 19, 2026
Merged

Reduce number of indices created in ClusterSettingsIT#20681
andrross merged 1 commit intoopensearch-project:mainfrom
andrross:fix-flaky-ClusterSettingsIT

Conversation

@andrross
Copy link
Member

When the number indices created in this test was sufficiently high, tests would frequently hit this failure at some point when creating a file:

Caused by: java.nio.file.FileSystemException: /var/jenkins/workspace/gradle-check/search/server/build/testrun/internalClusterTest/temp/org.opensearch.cluster.settings.ClusterSettingsIT_129BF1D803EFDA59-001/tempDir-002/node_s0/nodes/0/_state/_a1_Asserting_0.doc: Too many open files
  at org.apache.lucene.tests.mockfile.HandleLimitFS.onOpen(HandleLimitFS.java:67)
  at org.apache.lucene.tests.mockfile.HandleTrackingFS.callOpenHook(HandleTrackingFS.java:82)
  at org.apache.lucene.tests.mockfile.HandleTrackingFS.newOutputStream(HandleTrackingFS.java:163)
  at java.****/java.nio.file.Files.newOutputStream(Files.java:215)

This commit changes the random range from [10, 50] to be a fixed value of 3. This still gets the same coverage without unnecessarily increasing test runtime and introducing flakiness around file handle limits.

Resolves #20652

This flakiness was introduced by #20140

image

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.

When the number indices created in this test was sufficiently high,
tests would frequently hit this failure at some point when creating a
file:

```
Caused by: java.nio.file.FileSystemException: /var/jenkins/workspace/gradle-check/search/server/build/testrun/internalClusterTest/temp/org.opensearch.cluster.settings.ClusterSettingsIT_129BF1D803EFDA59-001/tempDir-002/node_s0/nodes/0/_state/_a1_Asserting_0.doc: Too many open files
  at org.apache.lucene.tests.mockfile.HandleLimitFS.onOpen(HandleLimitFS.java:67)
  at org.apache.lucene.tests.mockfile.HandleTrackingFS.callOpenHook(HandleTrackingFS.java:82)
  at org.apache.lucene.tests.mockfile.HandleTrackingFS.newOutputStream(HandleTrackingFS.java:163)
  at java.****/java.nio.file.Files.newOutputStream(Files.java:215)
```

This commit changes the random range from [10, 50] to be a fixed value
of 3. This still gets the same coverage without unnecessarily increasing
test runtime and introducing flakiness around file handle limits.

Signed-off-by: Andrew Ross <andrross@amazon.com>
@andrross andrross requested a review from a team as a code owner February 19, 2026 18:27
@github-actions github-actions bot added >test-failure Test failure from CI, local build, etc. autocut flaky-test Random test failure that succeeds on second run labels Feb 19, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 19, 2026

No actionable comments were generated in the recent review. 🎉

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9c62834 and 173f764.

📒 Files selected for processing (1)
  • server/src/internalClusterTest/java/org/opensearch/cluster/settings/ClusterSettingsIT.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
  • GitHub Check: gradle-check
  • GitHub Check: assemble (21, windows-latest)
  • GitHub Check: assemble (25, ubuntu-24.04-arm)
  • GitHub Check: precommit (25, windows-latest)
  • GitHub Check: precommit (25, macos-15-intel)
  • GitHub Check: precommit (25, ubuntu-latest)
  • GitHub Check: assemble (21, ubuntu-latest)
  • GitHub Check: precommit (21, windows-latest)
  • GitHub Check: assemble (25, windows-latest)
  • GitHub Check: assemble (21, ubuntu-24.04-arm)
  • GitHub Check: precommit (25, macos-15)
  • GitHub Check: precommit (21, ubuntu-latest)
  • GitHub Check: precommit (21, ubuntu-24.04-arm)
  • GitHub Check: assemble (25, ubuntu-latest)
  • GitHub Check: precommit (25, ubuntu-24.04-arm)
  • GitHub Check: precommit (21, windows-2025, true)
  • GitHub Check: precommit (21, macos-15)
  • GitHub Check: precommit (21, macos-15-intel)
  • GitHub Check: Analyze (java)
  • GitHub Check: detect-breaking-change
🔇 Additional comments (1)
server/src/internalClusterTest/java/org/opensearch/cluster/settings/ClusterSettingsIT.java (1)

573-573: Deterministic loop count looks good.

Line 573 reduces test flakiness without changing the verification flow; this is a sensible, stable adjustment.


📝 Walkthrough

Walkthrough

The change makes a flaky test deterministic by replacing a random loop iteration count (10-50 times) with a fixed count of 3 in testWithMultipleIndexCreationAndVerifySettingRegisteredOnce. The test logic and verification flow remain unchanged.

Changes

Cohort / File(s) Summary
Test Determinism
server/src/internalClusterTest/java/org/opensearch/cluster/settings/ClusterSettingsIT.java
Replaced random loop iteration (10-50) with fixed count (3) in testWithMultipleIndexCreationAndVerifySettingRegisteredOnce to eliminate test flakiness and ensure consistent behavior across runs.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested labels

>test-failure, flaky-test

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: reducing the number of indices created in the ClusterSettingsIT test.
Description check ✅ Passed The PR description is comprehensive, explaining the problem (file handle exhaustion), the solution (reducing indices from [10,50] to fixed 3), and includes issue references and testing confirmation.
Linked Issues check ✅ Passed The PR directly addresses issue #20652 by fixing the flaky ClusterSettingsIT test through deterministic index creation reduction, eliminating the file handle exhaustion errors.
Out of Scope Changes check ✅ Passed The change is narrowly scoped to fixing flakiness in testWithMultipleIndexCreationAndVerifySettingRegisteredOnce by adjusting loop iteration count, with no unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@jainankitk jainankitk left a comment

Choose a reason for hiding this comment

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

Looks fine to me. The purpose of this test does not require random number causing unnecessary flakiness

@github-actions
Copy link
Contributor

❌ Gradle check result for 173f764: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@github-actions
Copy link
Contributor

✅ Gradle check result for 173f764: SUCCESS

@codecov
Copy link

codecov bot commented Feb 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.26%. Comparing base (6b557db) to head (173f764).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main   #20681      +/-   ##
============================================
- Coverage     73.32%   73.26%   -0.06%     
+ Complexity    72064    71973      -91     
============================================
  Files          5781     5781              
  Lines        329395   329402       +7     
  Branches      47525    47526       +1     
============================================
- Hits         241536   241352     -184     
- Misses        68507    68676     +169     
- Partials      19352    19374      +22     

☔ 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.

@andrross andrross merged commit 107aa53 into opensearch-project:main Feb 19, 2026
41 of 55 checks passed
@andrross andrross deleted the fix-flaky-ClusterSettingsIT branch February 19, 2026 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autocut flaky-test Random test failure that succeeds on second run skip-changelog >test-failure Test failure from CI, local build, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[AUTOCUT] Gradle Check Flaky Test Report for ClusterSettingsIT

3 participants

Comments