-
Notifications
You must be signed in to change notification settings - Fork 791
Migrate Solr tests from SolrJettyTestBase to using SolrJettyTestRule #3947
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
base: main
Are you sure you want to change the base?
Conversation
…rTestCaseJ4 I used the prompt that I previously checked in, and pretty much just let it go to town. I had to help it a bit on the BasicHttpSolrClientTest. tests_not_migrated.md represents the ones that didn't go on the first pass.
…ious batch They all look pretty straightforward however.
|
Some lessons learned:
|
|
Big changes like this should be a multi-step journey. Anticipate that and ask the AI where to start and just stay focused there. For example look at SolrJettyTestBase and focus on removing that. Perhaps even that might be too much for one PR, so narrow further on RestTestBae, for example. |
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 is an experimental effort to use AI to migrate Solr tests from the deprecated SolrJettyTestBase to using SolrJettyTestRule. The primary goal is to reduce technical debt by modernizing test infrastructure, with the focus on refining the AI prompt (prompt_to_use.md) rather than reviewing individual test file changes.
Key changes:
- Migration of numerous test classes from extending
SolrJettyTestBasetoSolrTestCaseJ4with@ClassRule SolrJettyTestRule - Updates to base test classes (
SolrExampleTestsBase,HttpSolrClientTestBase) to support the new pattern - Replacement of legacy methods (
getBaseUrl(),getSolrClient(), etc.) with rule-based equivalents - Documentation of migration progress and patterns in markdown files
Reviewed changes
Copilot reviewed 40 out of 40 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| prompt_to_use.md | AI prompt defining migration requirements and patterns |
| tests_not_migrated.md | Documentation of migration status and remaining work |
| MIGRATION_*.md | AI-generated status and progress tracking files |
| solr/test-framework/.../BasicHttpSolrClientTest.java | Migrated to use SolrJettyTestRule with extensive method call replacements |
| solr/test-framework/.../ConcurrentUpdate*.java | Multiple test classes migrated to new pattern |
| solr/solrj/.../HttpSolrClientTestBase.java | Base class updated with DEFAULT_COLLECTION constant and rule support |
| solr/solrj/.../SolrExampleTestsBase.java | Base class refactored with deprecated backward-compatibility methods |
| solr/solrj/.../*Test.java | Various test classes migrated following standard pattern |
| solr/core/.../ResponseHeaderTest.java | Migrated with improved resource management using try-with-resources |
| solr/core/.../TestTolerantSearch.java | Complex multi-collection test migrated with custom setup |
| solr/core/.../DistributedDebugComponentTest.java | Multi-collection test migrated |
| solr/modules/sql/.../TestSQLHandlerNonCloud.java | Migrated with minimal config setup |
| solr/test-framework/.../SolrTestCaseJ4.java | Added documentation to copyMinConf method |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
solr/solrj/src/test/org/apache/solr/client/solrj/SolrSchemalessExampleTest.java
Show resolved
Hide resolved
solr/core/src/test/org/apache/solr/handler/component/DistributedDebugComponentTest.java
Show resolved
Hide resolved
solr/modules/sql/src/test/org/apache/solr/handler/sql/TestSQLHandlerNonCloud.java
Show resolved
Hide resolved
| // Backward compatibility methods for existing subclasses | ||
| @Deprecated | ||
| protected static void createAndStartJetty(Path solrHome) throws Exception { | ||
| solrJettyTestRule.startSolr(solrHome, new Properties(), JettyConfig.builder().build()); | ||
| } |
Copilot
AI
Dec 23, 2025
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.
The deprecated method createAndStartJetty is being added to SolrExampleTestsBase but marked as deprecated. This suggests subclasses may still be calling it. Consider removing this method entirely and updating all subclasses to use the new pattern with solrJettyTestRule.startSolr() instead of maintaining backward compatibility with a deprecated API.
| // Backward compatibility methods for existing subclasses | |
| @Deprecated | |
| protected static void createAndStartJetty(Path solrHome) throws Exception { | |
| solrJettyTestRule.startSolr(solrHome, new Properties(), JettyConfig.builder().build()); | |
| } |
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.
This is the one that I am still mulling on if it's worth doing!
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.
Why use the 3-arg overload instead of just one to provide only solrHome?
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.
Good eye! I found 5 other files wtih the same pattern. Cleaned them up. And now removing the deprecated helper emthod.
solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestsBase.java
Show resolved
Hide resolved
| collection1 = null; | ||
| collection2 = null; |
Copilot
AI
Dec 23, 2025
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.
The clients collection1 and collection2 in TestTolerantSearch are set to null in AfterClass without being closed. This creates a potential resource leak. Either close these clients before nulling them, or verify that the SolrJettyTestRule handles cleanup of all client instances.
| collection1 = null; | |
| collection2 = null; | |
| if (collection1 != null) { | |
| collection1.close(); | |
| collection1 = null; | |
| } | |
| if (collection2 != null) { | |
| collection2.close(); | |
| collection2 = null; | |
| } |
solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientTestBase.java
Outdated
Show resolved
Hide resolved
solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTestsBase.java
Show resolved
Hide resolved
|
Tracking my prompt here: |
Swapping from default configset to techproducts meant that I could just load system version!
…ClientTestBase.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…h/solr into migrate_away_from_solrjettytestbase
|
At this point, I'm down to working on migrating how we create collections to follow the pattern that |
This is a bit of an experiment. I wanted to see if I could reduce the amount of effort to get our tests updated. Over time we've been accumulating tech debt in our tests, and addressing that manually appears pretty difficult!
In this PR I've checked in my prompt
prompt_to_use.mdthat I used in VS Code. My thought is that the most important aspect of this PR is crafting a really great prompt. Instead of reviewing and commenting on the changes made per individual test file, what I really want is review of the overall change, and feed that review BACK into my prompt. Then I will re-run the improved prompt and that hopefully will output the final set of changes. Maybe in this PR, maybe in another fresh PR with improved prompt.As an example of feeding back input, after running everything I noticed in one test it hardcoded a
127.0.0.1url, and so I addedPlease do not create hard coded urls like 127.0.0.1 in the tests.to prevent that in the future.There are three files that start with
MIGRATION_*.mdand they are somewhat messy AI generated status files. I wanted it to maintaintests_not_migrated.mdas the but it kind of forgot that file....