Skip to content

Comments

SOLR-15788: Remove the use of legacyExampleCollection1SolrHome() in test setup #4147

Open
epugh wants to merge 8 commits intoapache:mainfrom
epugh:SOLR-15788_another_take
Open

SOLR-15788: Remove the use of legacyExampleCollection1SolrHome() in test setup #4147
epugh wants to merge 8 commits intoapache:mainfrom
epugh:SOLR-15788_another_take

Conversation

@epugh
Copy link
Contributor

@epugh epugh commented Feb 19, 2026

https://issues.apache.org/jira/browse/SOLR-15788

Description

Remove the use of legacyExampleCollection1SolrHome() in test setup in favour of our solrTestRule methods.

Solution

Back in 2021 I opened #410 and it was one of my first attempts to make sense of how crazy the Solr code base was! It never landed because it just didn't seem better.

Fastforward 5 years almost, and we have better ways of doing things. Turns our SolrTestRule's give us helpful builder methods that made it easy to remove this old legacy setup method. And simplified some tests too!

Tests

Existing tests pass.

…eprecated calls

legacyExampleCollection1SolrHome() being called but didn't offer anything that just using solrTestRule.newCollection methods didn't provide!
Remove the use of custom setup code in favour of our solrTestRule methods.
@epugh
Copy link
Contributor Author

epugh commented Feb 19, 2026

@dsmiley we are sprinkling around EnvUtils.setProperty( ALLOW_PATHS_SYSPROP, ExternalPaths.SERVER_HOME.toAbsolutePath().toString()); a lot, I wonder if this should be set in a base class like SolrTestCase? Or we live with it...

@@ -119,26 +131,17 @@ public Set<String> getContentTypes() {
}

public void testContentTypeHtmlBecomesTextPlain() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This method demonstrates what we have to start doing to get rid of h.getCore...

(ContentStreamBase.FileStream) rsp.getValues().get("content");
// System attempts to guess content type, but will only return XML, JSON, CSV, never HTML
assertEquals("application/xml", content.getContentType());
try (SolrCore core = solrTestRule.getCoreContainer().getCore("collection1")) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

whyis this called "collection1"? that's ugly. SHouldn't it be called "core1"?

Copy link
Contributor

Choose a reason for hiding this comment

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

quite a while ago, we standardized on "collection1" no matter what Solr's mode is. I like it.

Copy link
Contributor

@dsmiley dsmiley left a comment

Choose a reason for hiding this comment

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

Thanks for working on this!

IMO, no test should need to set EnvUtils.setProperty(ALLOW_PATHS_SYSPROP ) since our tests shouldn't be constrained by a production concern. Our test infrastructure, on the other hand, may very well need to configure allow-paths in some way (or disable it).

(ContentStreamBase.FileStream) rsp.getValues().get("content");
// System attempts to guess content type, but will only return XML, JSON, CSV, never HTML
assertEquals("application/xml", content.getContentType());
try (SolrCore core = solrTestRule.getCoreContainer().getCore("collection1")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

quite a while ago, we standardized on "collection1" no matter what Solr's mode is. I like it.

@epugh
Copy link
Contributor Author

epugh commented Feb 20, 2026

Okay, I think I've dealt with all the feedback. Thanks @dsmiley for fixing that test.. I will aim to merge this on Monday, leaving it open a few days more.

Nice clean up!

Copy link
Contributor

@dsmiley dsmiley left a comment

Choose a reason for hiding this comment

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

approving... but maybe we want to remove the need for ALLOW_PATHS_SYSPROP in tests first.

@epugh
Copy link
Contributor Author

epugh commented Feb 20, 2026

ALLOW_PATHS_SYSPROP

They are in lots of other places as well across our test code... How about you create a JIRA and I'll make a dedicated PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants