Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7c3a908
SOLR-18112: SolrDispatchFilter is now a Servlet
dsmiley Feb 9, 2026
029f551
Initial plan
Copilot Mar 17, 2026
edf0db8
Revert excludePatterns changes from SOLR-18112 commit
Copilot Mar 17, 2026
a46a8e4
Merge branch 'main' of https://github.com/dsmiley/solr into copilot/r…
Copilot Mar 17, 2026
fb93f17
Merge pull request #20 from dsmiley/copilot/revert-exclude-patterns
dsmiley Mar 17, 2026
82edbd0
Merge branch 'main' into SOLR-18112-SolrDispatchFilterServlet
dsmiley Mar 17, 2026
36e6b49
Moved constants to better places.
dsmiley Mar 17, 2026
1f9d504
Moved Action enum to HttpSolrCall
dsmiley Mar 17, 2026
6ae22ba
Micro simplification
dsmiley Mar 18, 2026
4159f9b
Rename to SolrServlet
dsmiley Mar 20, 2026
0636283
Merge branch 'main' into SOLR-18112-SolrDispatchFilterServlet
dsmiley Mar 20, 2026
ae89f42
Handle '/' to '/index.html'
dsmiley Mar 20, 2026
2bef3b7
Remove needless references to SolrServlet
dsmiley Mar 20, 2026
d5fb892
fix test. I hate mocking
dsmiley Mar 20, 2026
d719425
Convert LoadAdminUIServletTest to BATS
dsmiley Mar 20, 2026
bf4e91e
Remove PathExclusionFilter
dsmiley Mar 20, 2026
a0055dc
changelog
dsmiley Mar 21, 2026
0fb217a
Use "default" name, thus can remove an implied mapping.
dsmiley Mar 21, 2026
0aeb394
Merge remote-tracking branch 'apache/main' into RemovePathExclusionFi…
dsmiley Mar 27, 2026
77029ff
feedback: standard BATS --partial
dsmiley Mar 29, 2026
f3f75e8
AGENTS: testing advise
dsmiley Mar 29, 2026
b2c81a8
Use "SolrServlet" instead of "default". Add /* mapping
dsmiley Mar 30, 2026
fef4118
build.gradle: remove libs.eclipse.jetty.session
dsmiley Apr 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions AGENTS.md
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@epugh I added some info based on your standards for BATS tests.

CC @janhoy as well as there's some other stuff I've added from experience lately

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ While README.md and CONTRIBUTING.md are mainly written for humans, this file is

## Build and Development Workflow

- When done or preparing to commit changes to java source files, be sure to run `gradlew tidy` to format the code
- When done or preparing to commit changes to java source files, be sure to run `gradlew tidy` to format the code. Don't bother beforehand.
- Always run `gradlew check -x test` before declaring a feature done

## Code Quality and Best Practices
Expand All @@ -38,15 +38,25 @@ While README.md and CONTRIBUTING.md are mainly written for humans, this file is
- Be careful to not add non-essential logging! If you add slf4j log calls, make sure to wrap debug/trace level calls in `logger.isXxxEnabled()` clause
- Validate user input. For file paths, always call `myCoreContainer.assertPathAllowed(myPath)` before using

## Testing
## Running Tests

- See `dev-docs/gradle-help/tests.txt` for hints on running tests
- To run a specific test: `gradlew :solr:core:test --tests "org.apache.solr.search.TestCaffeineCache"`
- To run a specific BATS test: `gradlew iTest --tests test_adminconsole_urls.bats`
- The randomization seed is important. To repeat a failing tests, pass the same seed given in the failure by adding to Gradle: `-Ptests.seed=HEXADECIMALHERE`.
- Test output goes to `solr/<module>/build/test-results/test/outputs/OUTPUT-<fully.qualified.TestName>.txt` (stdout/stderr log) and `solr/<module>/build/test-results/test/TEST-<fully.qualified.TestName>.xml` (JUnit XML with pass/fail/error details)
- To scan test output for a specific issue across already-run tests: `grep -rl "pattern" solr/*/build/test-results/test/outputs/`

## Writing Tests

- When adding a test to an existing suite/file, keep the same style / design choices
- When adding a *new* Java test suite/file:
- Subclass SolrTestCase, or if SolrCloud is needed then SolrCloudTestCase
- If SolrTestCase and need to embed Solr, use either EmbeddedSolrServerTestRule (doesn't use HTTP) or SolrJettyTestRule if HTTP/Jetty is relevant to what is being tested.
- Avoid SolrTestCaseJ4 for new tests

- See `dev-docs/gradle-help/tests.txt` for hints on running tests
- Subclass SolrTestCase, or if SolrCloud is needed then SolrCloudTestCase
- If SolrTestCase and need to embed Solr, use either EmbeddedSolrServerTestRule (doesn't use HTTP) or SolrJettyTestRule if HTTP/Jetty is relevant to what is being tested.
- Avoid SolrTestCaseJ4 for new tests
- For BATS shell integration tests in `solr/packaging/test/`:
- Always use `run <command>` followed by `assert_output --partial "..."` or `refute_output --partial "..."` instead of capturing output into local variables and using `[[ ]]` comparisons
- Avoid patterns like `local var=$(cmd | grep ...); [[ "$var" == *"..."* ]]` — use `run cmd` + `assert_output`/`refute_output` instead

## Documentation

Expand Down
8 changes: 5 additions & 3 deletions changelog/unreleased/SOLR-18041.yml
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The filter came and went inside a release. So instead I'm communicating the observed sum of the two.

Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc
title: SOLR 18041 - Path exclusions for the admin UI are now defined in a separate servlet filter
type: other # added, changed, fixed, deprecated, removed, dependency_update, security, other
title: Path exclusions for the admin UI no longer need bespoke Solr code.
type: other
authors:
- name: Gus Heck
- name: David Smiley
links:
- name: SOLR-18041
url: https://issues.apache.org/jira/browse/SOLR-18041
- name: SOLR-18168
url: https://issues.apache.org/jira/browse/SOLR-18168

This file was deleted.

106 changes: 0 additions & 106 deletions solr/core/src/test/org/apache/solr/servlet/LoadAdminUiServletTest.java

This file was deleted.

5 changes: 4 additions & 1 deletion solr/packaging/build.gradle
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The Gradle up-to-date tracking wasn't working so I fixed it. CC @epugh as I suspect you run these tests more than any of us.

Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ task integrationTests(type: BatsTask) {
}

inputs.dir(distDir)
inputs.dir('test') // Track .bats test files and helper as inputs
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for this, there are times when I get weirdness, and maybe this fixes that!

outputs.dir(integrationTestOutput)

doFirst {
Expand Down Expand Up @@ -311,7 +312,9 @@ task integrationTests(type: BatsTask) {
}

class BatsTask extends Exec {
@InputDirectory
// Note: testDir is marked @Internal because it's a String configuration property, not a trackable input.
// The task using BatsTask should explicitly declare inputs.dir(testDir) in its configuration.
@Internal
String testDir = 'test'

@Input
Expand Down
28 changes: 27 additions & 1 deletion solr/packaging/test/test_adminconsole_urls.bats
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

more testing here to make up for the removal elsewhere. I was sure to check a random CSS file too as it's served via different routing path.

Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,37 @@ teardown() {
solr stop --all >/dev/null 2>&1
}


@test "assert able to launch solr admin console" {
run solr start

run curl -s -o /dev/null -w "%{http_code}" http://localhost:${SOLR_PORT}/solr/
assert_output "200"

run curl -s -I http://localhost:${SOLR_PORT}/solr/
assert_output --partial "text/html"

# Check if the HTTP response code is 200 (OK)
run curl -s http://localhost:${SOLR_PORT}/solr/
assert_output --partial "<html"

run curl -s -o /dev/null -w "%{http_code}" http://localhost:${SOLR_PORT}/solr/css/angular/chosen.css
assert_output "200"

run curl -s -I http://localhost:${SOLR_PORT}/solr/css/angular/chosen.css
assert_output --partial "text/css"

run curl -s http://localhost:${SOLR_PORT}/solr/css/angular/chosen.css
assert_output --partial "{"
}

@test "assert CSP header contains custom connect src URLs" {
# Set custom CSP connect-src URLs via system property
local csp_urls="http://example1.com/token,https://example2.com/path/uri1,http://example3.com/oauth2/uri2"

run solr start -Dsolr.ui.headers.csp.connect-src.urls="${csp_urls}"

run curl -s -I http://localhost:${SOLR_PORT}/solr/
assert_output --partial "http://example1.com/token"
assert_output --partial "https://example2.com/path/uri1"
assert_output --partial "http://example3.com/oauth2/uri2"
}
1 change: 0 additions & 1 deletion solr/solrj/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ dependencies {
testRuntimeOnly(libs.eclipse.jetty.alpnjavaserver, {
exclude group: "org.eclipse.jetty.alpn", module: "alpn-api"
})
testImplementation libs.eclipse.jetty.session

testImplementation(libs.mockito.core, {
exclude group: "net.bytebuddy", module: "byte-buddy-agent"
Expand Down
Loading
Loading