Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
6016131
Gate OpenNLP BATS test behind OPENNLP_TESTS env var
janhoy May 30, 2026
62ac939
Restructure test_status.bats to share one Solr invocation
janhoy May 30, 2026
e5722f4
Replace expensive -e films startup in test_healthcheck.bats
janhoy May 30, 2026
064e347
Convert test_packages.bats to JUnit and delete BATS file
janhoy May 30, 2026
3bf997e
Convert test_compression.bats to JUnit and delete BATS file
janhoy May 30, 2026
c5f15a9
Remove unnecessary sleep calls in test_zk.bats
janhoy May 30, 2026
127ba60
BATS: cap solr stop wait in test_start_solr.bats to avoid 3-minute hang
janhoy May 30, 2026
8b13e5b
BATS: merge test_example_noprompt into test_example, share one cloud …
janhoy May 30, 2026
6de8b12
BATS: replace fixed sleep 6 with wait_for polling in keystore reload …
janhoy May 30, 2026
9aadafd
BATS: rename OPENNLP_TESTS skip guard to SOLR_BATS_OPENNLP_TESTS
janhoy May 30, 2026
e94e174
Precommit
janhoy May 30, 2026
29f3cca
Fix test_ssl.bats
janhoy May 30, 2026
abea3e1
Remove needless comment about BATS integration test
janhoy May 31, 2026
1cfc633
Merge branch 'main' into feature/slim-bats-tests
janhoy Jun 4, 2026
bc974e0
Revert GZip tests
janhoy Jun 4, 2026
2372a4c
Merge remote-tracking branch 'origin/feature/slim-bats-tests' into fe…
janhoy Jun 4, 2026
ccc6265
Rename SOLR_BATS_OPENNLP_TESTS -> SOLR_BATS_TESTS_NIGHTLY
janhoy Jun 4, 2026
25ac736
Use BATS tagging and a gradle property solr.bats.nightly
janhoy Jun 4, 2026
8202889
Update README
janhoy Jun 4, 2026
490467f
Merge branch 'main' into feature/slim-bats-tests
janhoy Jun 4, 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
57 changes: 57 additions & 0 deletions solr/core/src/test/org/apache/solr/cli/PackageToolTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,63 @@ public static void testForResponseElement(
success);
}

/** Validates that collection existence is checked before package resolution. */
@Test
public void testDeployValidationMessages() throws Exception {
String solrUrl = cluster.getJettySolrRunner(0).getBaseUrl().toString();

withBasicAuth(CollectionAdminRequest.createCollection("validation-test", "conf1", 1, 1))
.processAndWait(cluster.getSolrClient(), 10);

CLITestHelper.TestingRuntime captureRuntime = new CLITestHelper.TestingRuntime(true);
PackageTool tool = new PackageTool(captureRuntime);

// Collection exists but package does not — collection validation should pass,
// package lookup should fail.
tool.runTool(
SolrCLI.processCommandLineArgs(
tool,
new String[] {
"--solr-url",
solrUrl,
"deploy",
"NONEXISTENT_PKG",
"--collections",
"validation-test",
"--credentials",
SecurityJson.USER_PASS
}));
String deployOut = captureRuntime.getOutput();
assertFalse(
"Should not complain about invalid collection", deployOut.contains("Invalid collection"));
assertTrue(
"Should report missing package",
deployOut.contains("Package instance doesn't exist: NONEXISTENT_PKG:null"));

captureRuntime.clearOutput();

// Undeploy of a package that was never deployed should give a clear message.
tool.runTool(
SolrCLI.processCommandLineArgs(
tool,
new String[] {
"--solr-url",
solrUrl,
"undeploy",
"NONEXISTENT_PKG",
"--collections",
"validation-test",
"--credentials",
SecurityJson.USER_PASS
}));
String undeployOut = captureRuntime.getOutput();
assertFalse(
"Should not complain about invalid collection", undeployOut.contains("Invalid collection"));
assertTrue(
"Should report package not deployed",
undeployOut.contains("Package NONEXISTENT_PKG not deployed on collection validation-test"));
}

private void run(PackageTool tool, String[] args) throws Exception {
int res = tool.runTool(SolrCLI.processCommandLineArgs(tool, args));
assertEquals("Non-zero status returned for: " + Arrays.toString(args), 0, res);
Expand Down
11 changes: 11 additions & 0 deletions solr/packaging/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ task integrationTests(type: BatsTask) {
}
}

if (!Boolean.parseBoolean((String) project.findProperty('solr.bats.nightly'))) {
filterTags = '!nightly'
}

inputs.dir(distDir)
inputs.dir('test') // Track .bats test files and helper as inputs
outputs.dir(integrationTestOutput)
Expand Down Expand Up @@ -320,6 +324,10 @@ class BatsTask extends Exec {
@Input
var testFiles = []

@Input
@Optional
String filterTags = null

@Option(option = "tests", description = "Sets test cases to be included")
public void setTestNamePatterns(List<String> tests) {
// TODO: bats --filter <regex>
Expand All @@ -335,6 +343,9 @@ class BatsTask extends Exec {
if (logger.isInfoEnabled()) {
batsArgs << '--verbose-run'
}
if (filterTags) {
batsArgs += ['--filter-tags', filterTags]
}
batsArgs += ['-T', '--print-output-on-failure', '--report-formatter', 'junit', '--output', "$project.buildDir/test-output"]
// Note: tests to run must be listed after all other arguments
batsArgs += testFiles.empty ? [testDir] : testFiles
Expand Down
18 changes: 18 additions & 0 deletions solr/packaging/test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,24 @@ Some tests will start clusters or create collections,

It is recommended that you install and run `shellcheck` to verify your test scripts and catch common mistakes before committing your changes.

## Nightly Tests

Some BATS tests are slow or require network access (e.g. downloading models) and are
excluded from regular runs by default. These tests use BATS native tagging via
`# bats test_tags=nightly` and are filtered out with `--filter-tags !nightly`.

To include nightly tests, pass the Gradle property `solr.bats.nightly`:

./gradlew integrationTests -Psolr.bats.nightly=true

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.

@dsmiley wrote: Sounds like we should have a general concept of "nightly" BATS.

Did some research and wired in BATS concept of test tagging. So now we can tag slow tests as done for test_opennlp.bats and they will only run when gradle is invoked with -Psolr.bats.nightly=true.

Thus we can configure Jenkins with this prop...

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.

I have configured all integration test jobs in Jenkins with this Gradle property


When writing a new test that should only run in nightly builds, add the BATS tag comment
directly before the `@test` declaration:

# bats test_tags=nightly
@test "my slow test" {
...
}

## Limitations

1. Currently this test suite is only available for \*nix environments. Although, newer
Expand Down
25 changes: 18 additions & 7 deletions solr/packaging/test/test_example.bats
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,36 @@

load bats_helper

setup() {
setup_file() {
common_clean_setup
solr start -e cloud --no-prompt --jvm-opts "-Dcustom.prop=helloworld"
solr assert --started http://localhost:${SOLR_PORT} --cloud http://localhost:${SOLR_PORT} --timeout 60000
solr assert --started http://localhost:${SOLR2_PORT} --cloud http://localhost:${SOLR2_PORT} --timeout 60000
}

teardown_file() {
common_setup
solr stop --all >/dev/null 2>&1
}

setup() {
common_setup
}

teardown() {
# save a snapshot of SOLR_HOME for failed tests
save_home_on_failure
}

solr stop --all >/dev/null 2>&1
@test "start -e cloud works with --no-prompt" {
solr assert --started http://localhost:${SOLR_PORT} --cloud http://localhost:${SOLR_PORT} --timeout 10000
solr assert --started http://localhost:${SOLR2_PORT} --cloud http://localhost:${SOLR2_PORT} --timeout 10000
}

@test "start -e cloud works with --jvm-opts" {
solr start -e cloud --no-prompt --jvm-opts "-Dcustom.prop=helloworld"
solr assert --started http://localhost:${SOLR_PORT} --cloud http://localhost:${SOLR_PORT} --timeout 60000
solr assert --started http://localhost:${SOLR2_PORT} --cloud http://localhost:${SOLR2_PORT} --timeout 60000

run curl "http://localhost:${SOLR_PORT}/solr/admin/info/properties"
assert_output --partial 'helloworld'

run curl "http://localhost:${SOLR2_PORT}/solr/admin/info/properties"
assert_output --partial 'helloworld'
}
35 changes: 0 additions & 35 deletions solr/packaging/test/test_example_noprompt.bats

This file was deleted.

20 changes: 8 additions & 12 deletions solr/packaging/test/test_healthcheck.bats
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,18 @@ teardown() {
}

@test "healthcheck on cloud solr" {
solr start -e films
run solr healthcheck -c films
solr start
solr create -c healthcheck_test -d _default
# Local
run solr healthcheck -c healthcheck_test
refute_output --partial 'error'

}

@test "healthcheck on remote cloud solr" {
solr start -e films
run solr healthcheck -c films --solr-connection http://localhost:${SOLR_PORT}/solr
# Remote
run solr healthcheck -c healthcheck_test --solr-connection http://localhost:${SOLR_PORT}/solr

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 merged the local and remote test in the same solr invocation

refute_output --partial 'error'

}

@test "healthcheck errors on standalone solr" {
solr start --user-managed -e films
run solr healthcheck -c films
solr start --user-managed
run solr healthcheck -c healthcheck_test
assert_output --partial 'Healthcheck tool only works in Solr Cloud mode'

}
2 changes: 1 addition & 1 deletion solr/packaging/test/test_opennlp.bats
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ teardown() {
# long test as an "integration" test is something we decide is okay?
# I also have dreams of incorporating this as code snippets in a Tutorial via the ascii doc tags
# like we use for the SolrJ code snippets. That way we know the snippets continue to work!
# bats test_tags=nightly
@test "Check lifecycle of sentiment classification" {

echo "Downloading onnx model and vocab..."

mkdir -p ${SOLR_TIP}/models/sentiment/
Expand Down
81 changes: 0 additions & 81 deletions solr/packaging/test/test_packages.bats

This file was deleted.

16 changes: 8 additions & 8 deletions solr/packaging/test/test_ssl.bats
Original file line number Diff line number Diff line change
Expand Up @@ -572,26 +572,26 @@ teardown() {
# Replace server1 keystore with client's
cp cert2.keystore.p12 server1.keystore.p12
)
# Give some time for the server reload
sleep 6
# Wait for Jetty keystore-reload scan to pick up the new certificate
wait_for 30 1 solr api --solr-url "https://localhost:${SOLR_PORT}/solr/admin/info/system"

run solr healthcheck --solr-url https://localhost:${SOLR_PORT}
run solr healthcheck -c test --solr-url https://localhost:${SOLR_PORT}

# Server 2 still uses the cert1, so this request should fail
run ! solr api --solr-url "https://localhost:${SOLR2_PORT}/solr/test/select?q=query2"

run ! solr healthcheck --solr-url https://localhost:${SOLR2_PORT}
run ! solr healthcheck -c test --solr-url https://localhost:${SOLR2_PORT}

(
cd "$ssl_dir"
# Replace server2 keystore with client's
cp cert2.keystore.p12 server2.keystore.p12
)
# Give some time for the server reload
sleep 6
# Wait for Jetty keystore-reload scan to pick up the new certificate
wait_for 30 1 solr api --solr-url "https://localhost:${SOLR2_PORT}/solr/admin/info/system"

run solr healthcheck --solr-url https://localhost:${SOLR_PORT}
run solr healthcheck --solr-url https://localhost:${SOLR2_PORT}
run solr healthcheck -c test --solr-url https://localhost:${SOLR_PORT}
run solr healthcheck -c test --solr-url https://localhost:${SOLR2_PORT}

run solr api --solr-url "https://localhost:${SOLR_PORT}/solr/test/select?q=query3"
assert_output --partial '"numFound":0'
Expand Down
2 changes: 1 addition & 1 deletion solr/packaging/test/test_start_solr.bats
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ teardown() {
# save a snapshot of SOLR_HOME for failed tests
save_home_on_failure

solr stop --all >/dev/null 2>&1
SOLR_STOP_WAIT=30 solr stop --all >/dev/null 2>&1
}

@test "SOLR-11740 check 'solr stop' connection" {
Expand Down
Loading
Loading