diff --git a/changelog/unreleased/SOLR-18566-picocli-bats-fixed.yml b/changelog/unreleased/SOLR-18566-picocli-bats-fixed.yml new file mode 100644 index 000000000000..218f8cf5abbe --- /dev/null +++ b/changelog/unreleased/SOLR-18566-picocli-bats-fixed.yml @@ -0,0 +1,10 @@ +title: > + All BATs Integration Tests now run against the picocli CLI +type: fixed +authors: + - name: Jalaz Kumar + nick: jaykay12 +links: + - name: SOLR-18566 + url: https://issues.apache.org/jira/browse/SOLR-18566 + \ No newline at end of file diff --git a/solr/core/src/java/org/apache/solr/cli/AuthTool.java b/solr/core/src/java/org/apache/solr/cli/AuthTool.java index b63a0d545ddf..4b905585e5d1 100644 --- a/solr/core/src/java/org/apache/solr/cli/AuthTool.java +++ b/solr/core/src/java/org/apache/solr/cli/AuthTool.java @@ -177,6 +177,8 @@ record AuthParams( names = {"--solr-include-file"}, paramLabel = "FILE", required = true, + // Supplied by bin/solr from SOLR_INCLUDE; hidden since a user-supplied duplicate is rejected. + hidden = true, description = "The Solr include file which contains overridable environment variables for configuring Solr configurations. Defaults to solr.in.sh or solr.in.cmd.") private String solrIncludeFile; diff --git a/solr/packaging/build.gradle b/solr/packaging/build.gradle index dedb2783018c..23cfa089997e 100644 --- a/solr/packaging/build.gradle +++ b/solr/packaging/build.gradle @@ -347,29 +347,9 @@ task integrationTests(type: BatsTask) { configureBatsTask(it, 'test-output', false) } -// The same suites run against the experimental picocli CLI. Deliberately a curated list rather -// than the whole suite, so the run stays short. A change that ports another tool to picocli -// should add that tool's .bats file here. task integrationTestsPicocli(type: BatsTask) { description = 'Runs the BATS suites for the migrated commands against the experimental picocli CLI.' configureBatsTask(it, 'test-output-picocli', true) - // A suite belongs here only when every command it invokes has been migrated, not merely the - // command under test. test_auth.bats, for example, uses `solr assert` to wait for startup, so - // it cannot join until the assert command is migrated. test_help.bats asserts the exact wording - // of the commons-cli help output, which the picocli implementation words differently. - testFiles = [ - 'test/test_version.bats', - 'test/test_status.bats', - 'test/test_create.bats', - 'test/test_delete_collection.bats', - 'test/test_zk.bats', - 'test/test_auth.bats', - 'test/test_modules.bats', - 'test/test_security_manager.bats', - 'test/test_healthcheck.bats', - 'test/test_postlogs.bats', - 'test/test_extraction.bats', - ] } abstract class BatsTask extends Exec { diff --git a/solr/packaging/test/bats_helper.bash b/solr/packaging/test/bats_helper.bash index d684724a2e5e..5e3054d73e6b 100644 --- a/solr/packaging/test/bats_helper.bash +++ b/solr/packaging/test/bats_helper.bash @@ -115,3 +115,13 @@ wait_for() { return 1 # Timeout reached } + +# Utility function for asserting between the commons-cli wording ($1), or, when running against the picocli CLI, the picocli wording ($2) +# TODO: Remove this once commons-cli cleanup happens +assert_output_for_cli() { + if [ -n "${SOLR_PICOCLI:-}" ]; then + assert_output --partial "$2" + else + assert_output --partial "$1" + fi +} diff --git a/solr/packaging/test/test_basic_auth.bats b/solr/packaging/test/test_basic_auth.bats index ab4932a7f5a1..b85a168833b9 100644 --- a/solr/packaging/test/test_basic_auth.bats +++ b/solr/packaging/test/test_basic_auth.bats @@ -25,7 +25,7 @@ setup() { # The auth command exports some system variables that are injected as basic auth username and password, # however that defeats our test so fake that out via --solr-include-file param specifing a bogus path. - solr auth enable --type basicAuth --credentials name:password --solr-include-file /force/credentials/to/be/supplied + SOLR_INCLUDE=/force/credentials/to/be/supplied solr auth enable --type basicAuth --credentials name:password solr assert --credentials name:password --cloud http://localhost:${SOLR_PORT} --timeout 5000 } @@ -74,7 +74,7 @@ run solr create -c COLL_NAME assert_output --partial '1 files indexed.' # Test postlogs - run solr postlogs -u name:password --solr-url http://localhost:${SOLR_PORT} --name COLL_NAME -rootdir ${SOLR_LOGS_DIR}/solr.log + run solr postlogs -u name:password --solr-url http://localhost:${SOLR_PORT} --name COLL_NAME --rootdir ${SOLR_LOGS_DIR}/solr.log assert_output --partial 'Committed' # Test export diff --git a/solr/packaging/test/test_help.bats b/solr/packaging/test/test_help.bats index 54bab9fe85bc..fe426d752c52 100644 --- a/solr/packaging/test/test_help.bats +++ b/solr/packaging/test/test_help.bats @@ -23,24 +23,24 @@ setup() { @test "solr help flag prints help" { run -1 solr --help - assert_output --partial 'Usage: solr COMMAND OPTIONS' + assert_output_for_cli 'Usage: solr COMMAND OPTIONS' 'usage: bin/solr' refute_output --partial 'ERROR' } @test "solr with no flags prints help" { run -1 solr - assert_output --partial 'Usage: solr COMMAND OPTIONS' + assert_output_for_cli 'Usage: solr COMMAND OPTIONS' 'usage: bin/solr' refute_output --partial 'ERROR' } @test "start help flag prints help" { run solr start --help - assert_output --partial 'Usage: solr start' + assert_output_for_cli 'Usage: solr start' 'usage: bin/solr start' refute_output --partial 'ERROR' } @test "start h flag prints help" { run solr start -h - assert_output --partial 'Usage: solr start' + assert_output_for_cli 'Usage: solr start' 'usage: bin/solr start' refute_output --partial 'ERROR: Hostname is required when using the -h option!' } @@ -48,13 +48,14 @@ setup() { @test "stop help flag prints help" { run solr stop --help - assert_output --partial 'Usage: solr stop' + assert_output_for_cli 'Usage: solr stop' 'usage: bin/solr stop' refute_output --partial 'ERROR' } @test "restart help flag prints help" { + [ -z "${SOLR_PICOCLI:-}" ] || skip "restart is not migrated to picocli yet" run solr restart --help - assert_output --partial 'Usage: solr restart' + assert_output_for_cli 'Usage: solr restart' 'usage: bin/solr restart' refute_output --partial 'ERROR' } @@ -85,13 +86,13 @@ setup() { @test "zk help flag prints help" { run solr zk --help assert_output --partial 'usage:' - assert_output --partial 'bin/solr zk ls' + assert_output_for_cli 'bin/solr zk ls' 'usage: bin/solr zk' refute_output --partial 'ERROR' } @test "auth help flag prints help" { run solr auth --help - assert_output --partial 'bin/solr auth enable' + assert_output_for_cli 'bin/solr auth enable' 'usage: bin/solr auth' refute_output --partial 'ERROR' } diff --git a/solr/packaging/test/test_post.bats b/solr/packaging/test/test_post.bats index 3c90e7d14513..7306044da60b 100644 --- a/solr/packaging/test/test_post.bats +++ b/solr/packaging/test/test_post.bats @@ -39,7 +39,7 @@ teardown() { @test "Check help command" { run solr post - assert_output --partial 'Missing required option: c' + assert_output_for_cli "Missing required option: c" "Missing required option: '--name=name'" run solr post -h assert_output --partial 'usage: bin/solr post' diff --git a/solr/packaging/test/test_stream.bats b/solr/packaging/test/test_stream.bats index b1a9a27c7cca..fd0a5201169a 100644 --- a/solr/packaging/test/test_stream.bats +++ b/solr/packaging/test/test_stream.bats @@ -19,8 +19,8 @@ load bats_helper setup_file() { common_clean_setup - solr start -e techproducts - solr auth enable --type basicAuth --credentials name:password --solr-include-file /force/credentials/to/be/supplied + solr start -e techproducts --solr-home "${SOLR_HOME}" + SOLR_INCLUDE=/force/credentials/to/be/supplied solr auth enable --type basicAuth --credentials name:password } teardown_file() { diff --git a/solr/solr-ref-guide/modules/deployment-guide/pages/cli/solr-auth.adoc b/solr/solr-ref-guide/modules/deployment-guide/pages/cli/solr-auth.adoc index 31a64352cf57..7a7ceb3484ee 100644 --- a/solr/solr-ref-guide/modules/deployment-guide/pages/cli/solr-auth.adoc +++ b/solr/solr-ref-guide/modules/deployment-guide/pages/cli/solr-auth.adoc @@ -34,8 +34,8 @@ See xref:cli/index.adoc[] to enable this implementation and for its known limita .... bin/solr auth [-hv] --auth-conf-dir=DIR [--block-unknown=true|false] - [--prompt=true|false] [-s=] --solr-include-file=FILE - [--solr-url=] [--type=TYPE] [-u=] + [--prompt=true|false] [-s=] [--solr-url=] + [--type=TYPE] [-u=] [--update-include-file-only=true|false] [-z=] enable|disable .... @@ -66,9 +66,6 @@ Updates or enables/disables authentication. Must be run on the Solr server itsel *-s*, *--solr-connection*=__:: Zookeeper or HTTP(s) connection string; unnecessary if SOLR_CONNECTION is defined in solr.in.sh; otherwise, defaults to localhost:9983. -*--solr-include-file*=_FILE_:: - *(required)* The Solr include file which contains overridable environment variables for configuring Solr configurations. Defaults to solr.in.sh or solr.in.cmd. - *--solr-url*=__:: Base Solr URL, which can be used to determine the zk-host if --zk-host is not known