-
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
Migrate Solr tests from SolrJettyTestBase to using SolrJettyTestRule #3947
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. |
|
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 |
|
Just discovered |
Migrate to Path, and wraps the few places we have a string value with Path.of. I suspect they may be refactored away in the future as well.
dsmiley
left a comment
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.
Thanks again for undertaking this!
Adding a couple more comments but I suppose this is in pretty good shape!
|
|
||
| // NOTE: we don't actually care about using SolrCloud, but we want to use SolrClient and I can't | ||
| // bring myself to deal with the nonsense that is SolrJettyTestBase. | ||
| // NOTE: we don't actually care about using SolrCloud, but we want to use SolrClient. |
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.
LOL. Maybe this becomes a TODO now that we have a nice rule encapsulating Solr lifecycle for Jetty
CC @gerlowskija
solr/test-framework/src/java/org/apache/solr/util/SolrClientTestRule.java
Outdated
Show resolved
Hide resolved
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
Copilot reviewed 82 out of 82 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (configSet.endsWith(confSuffix)) { | ||
| configSet = configSet.substring(0, configSet.length() - confSuffix.length()); | ||
| } | ||
| this.configSet = configSet; |
Copilot
AI
Dec 30, 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 assignment this.configSet = configSet; has been moved inside the conditional block. If the configSet doesn't end with the confSuffix, this field will not be set, which could cause the configSet to remain uninitialized or keep its previous value.
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.
maybe. I changed it so if you pass in a null you get a null.
|
|
||
| @ClassRule | ||
| public static final SolrClientTestRule solrClientTestRule = | ||
| public static final SolrClientTestRule solrTestRule = |
Copilot
AI
Dec 30, 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.
Inconsistent naming: This file uses solrClientTestRule for the rule name, while most other migrated files use solrTestRule. This inconsistency makes the codebase harder to maintain.
| protected void before() { | ||
| System.setProperty("solr.directoryFactory", "solr.NRTCachingDirectoryFactory"); | ||
| solrClientTestRule.startSolr(LuceneTestCase.createTempDir()); | ||
| solrTestRule.startSolr(LuceneTestCase.createTempDir()); |
Copilot
AI
Dec 30, 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 solrClientTestRule.startSolr() call is using the wrong rule name - it should be solrTestRule.startSolr() to match the field name on line 37.
…3947) Embrace the use of @ClassRule setup to manage the Solr lifecycle using SolrClientTestRule in our tests. This PR is to finish the migration to using SolrJettyTestRule, which extends SolrClientTestRule across our tests. There is also plenty of small cleanups of the tests throughout. Lint cleanups and places where we had extra setup steps that did not need to happen for the goal of a individual test to be accomplished.
|
DistributedDebugComponentTest seems to now be failing 100% of the time, regardless of seed |
| } | ||
|
|
||
| @AfterClass | ||
| public static void destroyThings() throws Exception { |
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.
I wonder if this logic needs to be restored to fix the policeman build?
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....