Skip to content

Commit

Permalink
Tool integrated, bats tests to demonstrate both ways...
Browse files Browse the repository at this point in the history
  • Loading branch information
epugh committed Jul 14, 2023
1 parent 82565be commit 4b1b254
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion solr/bin/solr
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ function print_usage() {
if [ -z "${CMD:-}" ]; then
echo ""
echo "Usage: solr COMMAND OPTIONS"
echo " where COMMAND is one of: start, stop, restart, status, healthcheck, create, create_core, create_collection, delete, version, zk, auth, assert, config, export, api, package"
echo " where COMMAND is one of: start, stop, restart, status, healthcheck, create, create_core, create_collection, delete, version, zk, auth, assert, config, export, api, package, postlogs"
echo ""
echo " Standalone server example (start Solr running in the background on port 8984):"
echo ""
Expand Down
4 changes: 3 additions & 1 deletion solr/bin/solr.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ IF "%1"=="create" goto run_solrcli
IF "%1"=="create_core" goto run_solrcli
IF "%1"=="create_collection" goto run_solrcli
IF "%1"=="delete" goto run_solrcli
IF "%1"=="postlogs" goto run_solrcli
IF "%1"=="zk" (
set SCRIPT_CMD=zk
SHIFT
Expand Down Expand Up @@ -281,12 +282,13 @@ IF "%SCRIPT_CMD%"=="delete" goto run_solrcli
IF "%SCRIPT_CMD%"=="zk" goto zk_usage
IF "%SCRIPT_CMD%"=="auth" goto auth_usage
IF "%SCRIPT_CMD%"=="status" goto run_solrcli
IF "%SCRIPT_CMD%"=="postlogs" goto run_solrcli
goto done

:script_usage
@echo.
@echo Usage: solr COMMAND OPTIONS
@echo where COMMAND is one of: start, stop, restart, status, healthcheck, create, create_core, create_collection, delete, version, zk, auth, assert, config, export, api, package
@echo where COMMAND is one of: start, stop, restart, status, healthcheck, create, create_core, create_collection, delete, version, zk, auth, assert, config, export, api, package, postlogs
@echo.
@echo Standalone server example (start Solr running in the background on port 8984):
@echo.
Expand Down
1 change: 1 addition & 0 deletions solr/core/src/java/org/apache/solr/cli/SolrCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ private static Tool newTool(String toolType) throws Exception {
else if ("export".equals(toolType)) return new ExportTool();
else if ("package".equals(toolType)) return new PackageTool();
else if ("post".equals(toolType)) return new PostTool();
else if ("postlogs".equals(toolType)) return new PostLogsTool();

// If you add a built-in tool to this class, add it here to avoid
// classpath scanning
Expand Down
14 changes: 13 additions & 1 deletion solr/packaging/test/test_postlogs.bats
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ teardown() {
delete_all_collections
}

@test "post solr log into solr" {
@test "post solr log into solr via script" {
run solr create_collection -c COLL_NAME
assert_output --partial "Created collection 'COLL_NAME'"

Expand All @@ -49,3 +49,15 @@ teardown() {
run curl 'http://localhost:8983/solr/COLL_NAME/select?q=*:*'
refute_output --partial '"numFound":0'
}

@test "post solr log into solr via cli" {
run solr create_collection -c COLL_NAME
assert_output --partial "Created collection 'COLL_NAME'"

run solr postlogs -url http://localhost:8983/solr/COLL_NAME -rootdir ${SOLR_LOGS_DIR}/solr.log
assert_output --partial 'Sending last batch'
assert_output --partial 'Committed'

run curl 'http://localhost:8983/solr/COLL_NAME/select?q=*:*'
refute_output --partial '"numFound":0'
}

0 comments on commit 4b1b254

Please sign in to comment.