Skip to content

Fix flaky testPutGlobalV2TemplateWhichProvidesContextWithContextDisabled#20640

Merged
andrross merged 1 commit intoopensearch-project:mainfrom
andrross:fix-flaky-mitst
Feb 17, 2026
Merged

Fix flaky testPutGlobalV2TemplateWhichProvidesContextWithContextDisabled#20640
andrross merged 1 commit intoopensearch-project:mainfrom
andrross:fix-flaky-mitst

Conversation

@andrross
Copy link
Copy Markdown
Member

Somehow the feature flag was getting enabled while this test expects it to be disabled. This change ensures the flag will be disabled for this test case.

Related Issues

Resolves #19058

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.

Somehow the feature flag was getting enabled while this test expects it
to be disabled. This change ensures the flag will be disabled for this
test case.

Signed-off-by: Andrew Ross <andrross@amazon.com>
@andrross andrross requested a review from a team as a code owner February 17, 2026 00:13
@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 17, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 17, 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 6760346 and de0867a.

📒 Files selected for processing (1)
  • server/src/test/java/org/opensearch/cluster/metadata/MetadataIndexTemplateServiceTests.java
🧰 Additional context used
🧬 Code graph analysis (1)
server/src/test/java/org/opensearch/cluster/metadata/MetadataIndexTemplateServiceTests.java (1)
server/src/main/java/org/opensearch/common/util/FeatureFlags.java (2)
  • FeatureFlags (29-337)
  • TestUtils (270-336)
⏰ 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 (25, windows-latest)
  • GitHub Check: assemble (21, ubuntu-latest)
  • GitHub Check: assemble (25, ubuntu-24.04-arm)
  • GitHub Check: assemble (25, ubuntu-latest)
  • GitHub Check: assemble (21, ubuntu-24.04-arm)
  • GitHub Check: assemble (21, windows-latest)
  • GitHub Check: detect-breaking-change
  • GitHub Check: precommit (25, macos-15)
  • GitHub Check: precommit (25, ubuntu-24.04-arm)
  • GitHub Check: precommit (21, ubuntu-24.04-arm)
  • GitHub Check: precommit (25, windows-latest)
  • GitHub Check: precommit (21, windows-2025, true)
  • GitHub Check: precommit (21, macos-15)
  • GitHub Check: precommit (21, macos-15-intel)
  • GitHub Check: precommit (21, windows-latest)
  • GitHub Check: precommit (25, ubuntu-latest)
  • GitHub Check: precommit (25, macos-15-intel)
  • GitHub Check: precommit (21, ubuntu-latest)
  • GitHub Check: Analyze (java)
🔇 Additional comments (2)
server/src/test/java/org/opensearch/cluster/metadata/MetadataIndexTemplateServiceTests.java (2)

50-50: LGTM!

Import added for FeatureFlags to support the feature flag control mechanism used in the test.


800-840: LGTM! Clean fix for the flaky test.

The root cause of the flakiness was correctly identified - the APPLICATION_BASED_CONFIGURATION_TEMPLATES feature flag could become enabled via system properties or other initialization paths even though featureFlagSettings() sets the default to false. Wrapping the test in FeatureFlags.TestUtils.with() with the FlagWriteLock mechanism ensures:

  1. The flag is explicitly set to false before the test runs
  2. The lock prevents other initialization mechanisms from overwriting this value during test execution
  3. The previous value is restored after the test completes

This approach is consistent with how other tests in this class use @LockFeatureFlag annotation to enable the flag when needed.


📝 Walkthrough

Walkthrough

The PR adds a feature flag guard around a test in MetadataIndexTemplateServiceTests, disabling the APPLICATION_BASED_CONFIGURATION_TEMPLATES feature flag to ensure controlled test execution within a FF-disabled context while preserving existing validation behavior.

Changes

Cohort / File(s) Summary
Test Feature Flag Guard
server/src/test/java/org/opensearch/cluster/metadata/MetadataIndexTemplateServiceTests.java
Wraps test execution within a feature flag context that disables APPLICATION_BASED_CONFIGURATION_TEMPLATES, ensuring consistent test behavior independent of feature flag state.
Build Configuration
build.gradle
Updates to manifest file with net changes of +39/-35 lines.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested labels

>test-failure, flaky-test

🚥 Pre-merge checks | ✅ 4 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (4 files):

⚔️ distribution/src/bin/opensearch-env (content)
⚔️ distribution/src/bin/opensearch-env.bat (content)
⚔️ qa/fips-compliance/build.gradle (content)
⚔️ server/src/test/java/org/opensearch/cluster/metadata/MetadataIndexTemplateServiceTests.java (content)

These conflicts must be resolved before merging into main.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the fix: addressing the flaky test by ensuring the feature flag is disabled for the specific test case.
Description check ✅ Passed The description addresses the core issue (feature flag being enabled when disabled is expected), references the linked issue #19058, and includes the required checklist confirmation for testing.
Linked Issues check ✅ Passed The PR directly addresses the flaky test issue #19058 by ensuring the APPLICATION_BASED_CONFIGURATION_TEMPLATES feature flag is disabled during test execution, which resolves the root cause of intermittent test failures.
Out of Scope Changes check ✅ Passed All changes are narrowly scoped to the failing test method—wrapping it with feature flag disabling logic without modifying unrelated test logic or production code.

✏️ 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
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch fix-flaky-mitst
  • Post resolved changes as copyable diffs 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.

@github-actions
Copy link
Copy Markdown
Contributor

❌ Gradle check result for de0867a: 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
Copy Markdown
Contributor

✅ Gradle check result for de0867a: SUCCESS

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.32%. Comparing base (db0a16d) to head (de0867a).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main   #20640      +/-   ##
============================================
+ Coverage     73.19%   73.32%   +0.12%     
- Complexity    71924    72055     +131     
============================================
  Files          5781     5781              
  Lines        329292   329393     +101     
  Branches      47514    47525      +11     
============================================
+ Hits         241026   241516     +490     
+ Misses        68925    68532     -393     
- Partials      19341    19345       +4     

☔ 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 0bbea60 into opensearch-project:main Feb 17, 2026
42 of 44 checks passed
@andrross andrross deleted the fix-flaky-mitst branch February 17, 2026 16:53
harshavamsi pushed a commit to harshavamsi/OpenSearch that referenced this pull request Feb 17, 2026
…led (opensearch-project#20640)

Somehow the feature flag was getting enabled while this test expects it
to be disabled. This change ensures the flag will be disabled for this
test case.

Signed-off-by: Andrew Ross <andrross@amazon.com>

Update streaming flag to use search request context

Signed-off-by: Harsha Vamsi Kalluri <harshavamsi096@gmail.com>

Changelog

Signed-off-by: Harsha Vamsi Kalluri <harshavamsi096@gmail.com>
tanyabti pushed a commit to tanyabti/OpenSearch that referenced this pull request Feb 24, 2026
…led (opensearch-project#20640)

Somehow the feature flag was getting enabled while this test expects it
to be disabled. This change ensures the flag will be disabled for this
test case.

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

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 MetadataIndexTemplateServiceTests

2 participants