-
Notifications
You must be signed in to change notification settings - Fork 768
SOLR-17945: fix flaky test CloudHttp2SolrClientTest#testHttpCspPerf #3742
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
Conversation
- create staic constant for sys prop (will cause test compile errors if removed in future) - cleanup sys prop in @afterclass in ClusterStateProviderTest - set sys prop to very high number in testHttpCspPerf to prevent spurious CLUSTERSTATUS requests
…tting the sys prop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a flaky test CloudHttp2SolrClientTest#testHttpCspPerf
by refactoring the system property used to control the Cluster State Provider's cache timeout and properly managing its lifecycle in tests.
- Extracts the hardcoded system property string into a constant for better maintainability
- Adds proper cleanup of system properties in test classes to prevent test pollution
- Sets an extremely high cache timeout in the performance test to prevent background cache refreshes from interfering
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
BaseHttpClusterStateProvider.java | Defines constant for cache timeout system property and uses it instead of hardcoded string |
ClusterStateProviderTest.java | Uses the new constant and adds proper cleanup of system property after tests |
CloudHttp2SolrClientTest.java | Uses the new constant and wraps test with try-finally to ensure system property cleanup |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
solr/solrj/src/test/org/apache/solr/client/solrj/impl/ClusterStateProviderTest.java
Outdated
Show resolved
Hide resolved
solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java
Outdated
Show resolved
Hide resolved
…tateProviderTest.java Co-authored-by: Copilot <[email protected]>
…p2SolrClientTest.java Co-authored-by: Copilot <[email protected]>
} | ||
} | ||
} finally { | ||
System.clearProperty(SYS_PROP_CACHE_TIMEOUT_SECONDS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't bother clearing system properties in tests. We've got some nice test infrastructure that makes doing so needless, and here causing you to do a needless try-finally.
This fixes the
CloudHttp2SolrClientTest#testHttpCspPerf
by increasing the Cluster State Provider's cache timeout.