Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 0 additions & 6 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ examples:
- any-glob-to-any-file:
- solr/example/**

# Add 'bats-tests' label
bats-tests:
- changed-files:
- any-glob-to-any-file:
- solr/packaging/test/**

# Add 'docker' label for changes to docker
docker:
- changed-files:
Expand Down
39 changes: 0 additions & 39 deletions .github/workflows/bin-solr-test.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/cats-test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# CATS — Cross-platform Automated Testing System: the JUnit-based harness that drives bin/solr and
# bin\solr.cmd. Named after BATS, which it replaces.
# bin\solr.cmd. Named after BATS, which it replaced.

name: Solr CATS Tests

Expand Down
7 changes: 2 additions & 5 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,17 @@ While README.md and CONTRIBUTING.md are mainly written for humans, this file is
- 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 CATS (Cross-platform Automated Testing System), the cross-platform CLI suites: `gradlew -p solr/packaging catsTests --tests "*ZkTest"`
- To run a specific BATS test (deprecated, replaced by CATS): `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

**Read `dev-docs/writing-tests.adoc` before writing any test.** It is the authority on which harness to use — `SolrTestCase` by default, `SolrCloudTestCase` only when a cluster is needed, `SolrCatsTestCase` for `bin/solr` and `bin\solr.cmd`, `AdminUiTestBase` for the browser, a Testcontainers `@ClassRule` for a real external service, and never `SolrTestCaseJ4`, a new `.bats` file, or `docker run` from a test — and on the lifecycle, randomization and waiting conventions, with a worked example per kind.
**Read `dev-docs/writing-tests.adoc` before writing any test.** It is the authority on which harness to use — `SolrTestCase` by default, `SolrCloudTestCase` only when a cluster is needed, `SolrCatsTestCase` for `bin/solr` and `bin\solr.cmd`, `AdminUiTestBase` for the browser, a Testcontainers `@ClassRule` for a real external service, and never `SolrTestCaseJ4` or `docker run` from a test — and on the lifecycle, randomization and waiting conventions, with a worked example per kind.

When adding a test to a suite that already exists, match the design choices of the file you are editing.

- 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
- Shell tests for `bin/solr`/`bin\solr.cmd` are CATS suites (`SolrCatsTestCase`); BATS was removed, don't add `.bats` files.

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.

Do we need the BATS were removed text? I guess for now, and maybe in a year we remove it...


## Documentation

Expand Down
12 changes: 12 additions & 0 deletions changelog/unreleased/SOLR-18645-remove-bats.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc

title: >
The BATS suites in `solr/packaging/test` are removed, along with the `integrationTestsPicocli` and
`downloadBats` Gradle tasks. CATS covers the same ground; `integrationTests` now runs `catsTests`.
type: removed
authors:
- name: Jan Høydahl
url: https://home.apache.org/phonebook.html?uid=janhoy
links:
- name: SOLR-18645
url: https://issues.apache.org/jira/browse/SOLR-18645
2 changes: 1 addition & 1 deletion dev-docs/asf-jenkins.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ We run a number of jobs on Jenkins, each validating an overlapping set of concer
* `Solr-Artifacts-*` - daily jobs that run `./gradlew assemble` to ensure that build artifacts (except docker images) can be created successfully
* `Solr-Lint-*` - daily jobs that run static analysis (i.e. `precommit` and `check -x test`) on a branch
* `Solr-Test-*` - "hourly" jobs that run all (non-integration) tests (i.e. `./gradlew test`)
* `Solr-TestIntegration-*` - daily jobs that run project integration tests (i.e. `./gradlew integrationTests`)
* `Solr-TestIntegration-*` - daily jobs that run project integration tests (i.e. `./gradlew integrationTests`, an alias for the CATS suites' `catsTests`)
* `Solr-Docker-Nightly-*` - daily jobs that `./gradlew testDocker dockerPush` to validate docker image packaging. Snapshot images are pushed to hub.docker.com
* `Solr-reference-guide-*` - daily jobs that build the Solr reference guide via `./gradlew checkSite` and push the resulting artifact to the staging/preview site `nightlies.apache.org`
* `Solr-Smoketest-*` - daily jobs that produce a snapshot release (via the `assembleRelease` task) and run the release smoketester
Expand Down
3 changes: 2 additions & 1 deletion dev-docs/cats.adoc

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.

I guess with AI especially, we are going to see our dev-docs start expanding quickly... (I only make this comment because the "scalar openapi explorer" pr also adds this).. We may in the future need some stort of plan around this!

Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

CATS (Cross-platform Automated Testing System) is how Solr tests `bin/solr` and `bin\solr.cmd`. A test is a Java class that runs real `solr` commands against an unpacked distribution, through `bash` on Unix and `cmd.exe` on Windows. The same test covers both platforms, so script, quoting and packaging bugs show up on the OS where they actually happen.

CATS replaced the BATS suites that used to live in `solr/packaging/test/` (SOLR-18642); they were removed in SOLR-18645.

* Suites: `solr/packaging/src/test/org/apache/solr/shell/`
* Base class: `SolrCatsTestCase` (in `solr/test-framework`, package `org.apache.solr.shell`)
* Harness internals: package `org.apache.solr.cats`, same module

CATS replaces the BATS suites in `solr/packaging/test/`. Don't add new `.bats` files.

== Running

Expand Down
11 changes: 2 additions & 9 deletions dev-docs/writing-tests.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ The rule: *write the cheapest kind of test that can actually catch the bug.*
| as `SolrTestCase`
| Deprecated. Not in new tests.

| BATS, `solr/packaging/test/*.bats`
| The original bash `bin/solr` tests. `./gradlew integrationTests`.
| seconds to minutes, sequential
| Deprecated in favour of CATS, which runs the same coverage on both shells. Bash-only; never ran on Windows.

| `solr/docker/tests/cases/*`
| Bash cases that `docker run` the Solr image built from this tree: entrypoint, `docker-entrypoint-initdb.d` scripts, `/var/solr` volume handling and permissions, core precreation, non-root and random UIDs, log4j config. `./gradlew -p solr/docker testDocker`, helpers in `tests/shared.sh`.
| image build + containers
Expand All @@ -60,7 +55,6 @@ The rule: *write the cheapest kind of test that can actually catch the bug.*
* In `bin/solr`, `bin/solr.cmd`, `solr.in.sh`/`solr.in.cmd`, CLI parsing, output or exit codes — `SolrCatsTestCase`. Also the only place a packaging problem reproduces: a jar missing from the classpath, a Jetty setting, a file in the wrong place, or a Windows-only script bug. The `SolrTestCase` hierarchy builds no installation, so none of those are visible to it.
* Needs a real external service, not a mock — pick from the above as usual, then add a Testcontainers `@ClassRule`; see below.
* In the Admin UI's JavaScript or templates — `AdminUiTestBase`. Test the APIs it calls separately; keep the browser test to what the browser renders.
* Tempted to add a `.bats` file — don't. Write it as a `SolrCatsTestCase`. Touch the `.bats` files only to keep them working until they are ported.
* In the Docker image — its entrypoint, init scripts, volume or permission handling, the `SOLR_*` variables it honours — a case under `solr/docker/tests/cases/`, not a CATS suite.

== Randomized testing
Expand Down Expand Up @@ -144,7 +138,7 @@ A sleep you cannot replace is worth a comment saying what it is waiting for, bec
`solr/core/src/test/org/apache/solr/cloud/CollectionStateZnodeTest.java` — the real minimal shape, with `@After deleteAllCollections()` and both `waitForState` forms.

`SolrCatsTestCase`::
`solr/packaging/src/test/org/apache/solr/shell/ZkTest.java` — canonical BATS port: `classCli.run(...)` for a class-lifetime node, fluent `run(...).assertContains(...)`, `${SOLR_PORT}` expansion, portable stand-ins for `touch` and `curl`.
`solr/packaging/src/test/org/apache/solr/shell/ZkTest.java` — canonical example: `classCli.run(...)` for a class-lifetime node, fluent `run(...).assertContains(...)`, `${SOLR_PORT}` expansion, portable stand-ins for `touch` and `curl`.
+
`solr/packaging/src/test/org/apache/solr/shell/PostTest.java` — same, plus `assertContainsForCli(commonsCliText, picocliText)` for wording that differs between the two CLI implementations.
+
Expand All @@ -160,7 +154,6 @@ The generic core is `org.apache.solr.cats` in `solr/test-framework`, with the So
`./gradlew helpTests` is the reference for running tests — seeds, filtering, beasting, verbose mode, profiling, coverage. Only the module-specific test tasks are here:

* `./gradlew -p solr/packaging catsTests` builds the distribution first, then runs CATS — on Windows, the same suites under `cmd.exe`. See `solr/packaging/README.md` for the task variants.
* `./gradlew integrationTests` runs the BATS suites, `integrationTestsPicocli` the picocli variant. `downloadBats` fetches bats-core and its helpers for you; `--tests <file>.bats` selects one file; tests get a random port, pinnable with `-Pbats.port`; `# bats test_tags=nightly` tests need `-Psolr.bats.nightly=true`.
* `./gradlew -p solr/docker testDocker` builds the image from your tree and runs the bash cases against it; `-Psolr.docker.tests.include`/`-Psolr.docker.tests.exclude` select them.
* `./gradlew :solr:webapp:test -Ptests.selenium=true` runs the Admin UI browser tests; needs a local Chrome.
* Neither `solr/packaging` nor `solr/docker` test tasks are part of `check` — they need an unpacked distribution or a built image. The harness' own unit tests are — run them with `./gradlew -p solr/test-framework test --tests "org.apache.solr.cats.*"`. The browser tests are in `check` but stay skipped until their test group is enabled.
Expand All @@ -170,7 +163,7 @@ When one fails, start with the artifacts rather than the stack trace: `SolrCatsT
== See also

* `solr/test-framework/README.md` — what the framework provides and how to depend on it.
* `solr/packaging/README.md` — the distribution, CATS and the BATS suites it is replacing.
* `solr/packaging/README.md` — the distribution and CATS.
* xref:cats.adoc[cats.adoc] — writing a CATS test for Solr: running, a first test, the DSL and debugging failures.
* link:admin-ui-tests.md[admin-ui-tests.md] — how the browser suite works and what it skips.
* `./gradlew helpTests` (`dev-docs/gradle-help/tests.txt`) — the guide to running tests. `./gradlew -p solr/core testOpts` lists every test property with its default and current value.
Expand Down
8 changes: 0 additions & 8 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,6 @@ asciidoctor-mathjax = "0.0.9"
asciidoctor-tabs = "1.0.0-beta.6"
azagniotov-langdetect = "12.5.2"
barfuin-jacocolog = "4.0.2"
# @keep bats-assert version used in packaging
bats-assert = "2.0.0"
# @keep bats-core version used in packaging
bats-core = "1.8.2"
# @keep bats-file version used in packaging
bats-file = "0.3.0"
# @keep bats-support version used in packaging
bats-support = "0.2.0"
bc-jose4j = "0.9.6"
benmanes-caffeine = "3.2.4"
benmanes-versions = "0.61.0"
Expand Down
2 changes: 1 addition & 1 deletion solr/bin/solr
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ if [ $$ -ne $(ps -o pid='' -p $$ || echo 0) ] ; then
exit 1
fi

# This helps with debugging when running bats tests however the whole script is not compliant yet
# This helps with debugging when running shell tests however the whole script is not compliant yet

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.

interesting that "the whole script is not compliant yet", that seems like a great place to spend some tokens to get to done..

# set -u
# set -o pipefail

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
*
* <p>Focused on verifying how DocumentCategorizerUpdateProcessorFactory is set up to run.
*
* <p>See test_opennlp.bats for a complete system test of DocumentCategorizerUpdateProcessorFactory.
* <p>See {@code org.apache.solr.shell.OpenNlpTest} in solr/packaging for a complete system test of

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.

I wonder if the package should have been org.apache.solr.cats.OpenNlpTest? I was a bit surprised and then figured it out... I know it's a "shell", but really, in my head it's a "CATS" test... not a "shell" test....

* DocumentCategorizerUpdateProcessorFactory.
*/
public class TestConfiguringDocumentCategorizerUpdateProcessorFactory
extends UpdateProcessorTestBase {
Expand Down
4 changes: 3 additions & 1 deletion solr/packaging/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ cd solr/packaging/build/dev-slim && bin/solr start -f

## Tests

CATS suites in `src/test/org/apache/solr/shell/`, the deprecated BATS suites in `test/*.bats`. Neither is in `check`: both need an unpacked distribution and start real nodes, so ask for them by name — `catsTests` and `integrationTests`, plus the `catsTestsPicocli`/`catsTestsCommonsCli` variants `gradlew -p solr/packaging tasks` lists. CATS classes are isolated by `SOLR_HOME` and port block and run in parallel; `-Pcats.tests.jvms=N` sets the fork count. Output, per-test transcripts and failure snapshots land under `build/cats-test-output*` and `build/test-output*`, wiped at the start of each run.
CATS suites in `src/test/org/apache/solr/shell/`. They are not in `check`: they need an unpacked distribution and start real nodes, so ask for them by name — `catsTests` (aliased as `integrationTests`), plus the `catsTestsPicocli`/`catsTestsCommonsCli` variants `gradlew -p solr/packaging tasks` lists. CATS classes are isolated by `SOLR_HOME` and port block and run in parallel; `-Pcats.tests.jvms=N` sets the fork count. Output, per-test transcripts and failure snapshots land under `build/cats-test-output*`, wiped at the start of each run.

CI runs CATS on pull requests touching `solr/bin`, this module or the CLI (`.github/workflows/cats-test.yml`).

Until SOLR-18645 this module also held the BATS suites in `test/*.bats`; they were ported to CATS and removed.

## See also

- [`dev-docs/writing-tests.adoc`](../../dev-docs/writing-tests.adoc) — which kind of test to write, how to run each, what to read when one fails.
Expand Down
Loading