← Back to Pull requests

SOLR-18642 Replace BATS with CATS #5323

Closed
unknown closed this pull request without merging on Nov 20, 2026 11:29 UTC
View on GitHub
unknown unknown commented on Nov 12, 2026 01:49 UTC
Author

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

The JIRA covers what CATS is. This is how it is built and how to review it.

<img width="980" height="500" alt="cats-overview" src="https://github.com/user-attachments/assets/8bc4133d-94a0-411c-bf36-13cdae88f641" />

Layout

| | |
| --- | --- |
| solr/test-framework/src/java/org/apache/solr/shell/ | the harness: 20 files, ~4.3k lines |
| solr/packaging/src/test/org/apache/solr/shell/ | 30 suites, ~4.4k lines, replacing the 29 .bats files |
| solr/packaging/build.gradle, .github/workflows/cats-test.yml | the catsTests tasks, and a bash + cmd.exe CI matrix |

SolrShellTestCase is the base class, session/CliSession runs commands and owns the rails, env/ resolves directories and ports.

How it works

  • Per-class isolation is what buys the parallelism: each class gets its own SOLR_HOME, SOLR_PID_DIR, logs directory and four ports (stop at P-1000, ZooKeeper at P+1000), claimed from a counter file under a FileChannel.lock() and kept below every platform's ephemeral port floor.

  • Nodes are found by process scan, not pid files — a solr.process.scan.marker sysprop that SolrProcessManager filters on, which behaves identically on both platforms and survives a SOLR_HOME wipe.

  • The harness resolves ${NAME} before any shell sees it (bash expands $NAME, cmd.exe wants %NAME%), failing on an unknown name instead of substituting empty. Non-portable constructs — shell operators, $(, backticks, /dev/null, ~45 Unix-only tools — fail at the call site naming the fluent method that replaces them; @EnabledOnShell lifts the rails per test.

  • run() asserts success, runFail() a non-zero status, tryRun() nothing; making success the default found 13 sites that had been ignoring a non-zero exit. curl, jq, openssl and docker became Java and Testcontainers, so no test needs an external tool or the network.

  • A failure reads as a shell session: every command with its exit code and output, one FAILED: line, a SOLR_HOME snapshot, and pre/post-flight port checks that pin a leak on the class that caused it.
  • Running and reviewing

    ./gradlew -p solr/packaging catsTests                     # suites; no Docker, no network
    ./gradlew -p solr/packaging catsTests --tests "*ZkTest"   # one class
    ./gradlew -p solr/packaging catsTestsAll                  # + rolling upgrade, builds an image
    

    catsTestsPicocli/catsTestsCommonsCli pin the CLI implementation, -Pcats.tests.jvms=N sets the fork count, and the same commands run under cmd.exe. Output and per-test transcript.log land under solr/packaging/build/cats-test-output/.

    Reading order: CliSession and SolrShellTestCase, then HarnessEnv/PortBlocks for the isolation model, then ZkTest.java beside test_zk.bats. The BATS suites still pass, so the two can be compared directly.

    [!TIP]

    If you're on a Mac and want to test the Windows side, I've got you covered, your LLM can remote control a Win VM and do whatever you wish, see gist link.

    🤖 Developed almost entirely by Claude Code. I have not yet reviewed all of it myself.

    Diff: 402 lines (+301 / -101) across 5 files Reviewer: janhoy Review duration: 12100m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.45) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 402 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.359
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #5323"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 44.7% (MEDIUM) · Higher = larger blast radius
    44.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.4% · Safe to merge
    19.4%
    Repository