This is an automated email from the ASF dual-hosted git repository.

malliaridis pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/branch_9x by this push:
     new 78920854a95 SOLR-17467: Fix Windows start script on 9x and optimize 
deprecation messages (#2789)
78920854a95 is described below

commit 78920854a9530109086df0d4ba67fc05162735f6
Author: Christos Malliaridis <[email protected]>
AuthorDate: Wed Oct 23 21:07:07 2024 +0200

    SOLR-17467: Fix Windows start script on 9x and optimize deprecation 
messages (#2789)
    
    * Fix start issues on Windows for user-managed and cloud mode
    * Update deprecation warnings for default mode
    * Update tests to reflect new messages and behavior
---
 solr/bin/solr                            | 21 +++++++++++++++++----
 solr/bin/solr.cmd                        | 20 ++++++++++++++++----
 solr/packaging/test/test_start_solr.bats | 23 ++++++++++++++++++++---
 3 files changed, 53 insertions(+), 11 deletions(-)

diff --git a/solr/bin/solr b/solr/bin/solr
index e6d436c48e4..6439f180cc8 100755
--- a/solr/bin/solr
+++ b/solr/bin/solr
@@ -775,8 +775,16 @@ if [ $# -gt 0 ]; then
         -c|--cloud|-cloud)
             SOLR_MODE="solrcloud"
             PASS_TO_RUN_EXAMPLE+=("-c")
+
+            echo -e "Solr will start in SolrCloud mode by default in version 
10, and you will no longer need to pass in -c or --cloud flag.\n"
             shift
         ;;
+        --user-managed)
+          # Allow the user to use the user-managed flag to suppress the 
warning about th change
+          # of the default mode in v10.
+          SOLR_MODE="user-managed"
+          shift
+        ;;
         -d|--dir|-dir|--server-dir)
             if [[ -z "$2" || "${2:0:1}" == "-" ]]; then
               print_usage "$SCRIPT_CMD" "Server directory is required when 
using the $1 option!"
@@ -1181,11 +1189,18 @@ if [[ -n "${ZK_HOST:-}" ]]; then
   SOLR_MODE="solrcloud"
 fi
 
+if [[ -z ${SOLR_MODE:-} ]]; then
+  # User has not provided any option for the mode (--cloud/--user-managed), 
therefore
+  # stay on user-managed mode in 9.x to avoid behavior changing / breaking 
changes
+  SOLR_MODE="user-managed"
+  # and notify that staying the default option (not providing --user-managed) 
will affect
+  # future execution
+  echo -e "Solr will start in SolrCloud mode by default in version 10, and you 
will have to provide --user-managed if you want to stay on the user-managed 
(aka. standalone) mode.\n"
+fi
+
 if [ "${SOLR_MODE:-}" == 'solrcloud' ]; then
   : "${ZK_CLIENT_TIMEOUT:=30000}"
   CLOUD_MODE_OPTS=("-DzkClientTimeout=$ZK_CLIENT_TIMEOUT")
-
-  echo -e "\nSolr will start in SolrCloud mode by default in version 10, even 
if no -c or --cloud flag is specified.\n"
   
   if [ -n "${ZK_HOST:-}" ]; then
     CLOUD_MODE_OPTS+=("-DzkHost=$ZK_HOST")
@@ -1218,8 +1233,6 @@ else
     echo -e "\nSolr home directory $SOLR_HOME must contain a solr.xml file!\n"
     exit 1
   fi
-  
-  echo -e "\nSolr will start in SolrCloud mode by default in version 10.  You 
will need to pass in --user-managed flag to run in User Managed (aka 
Standalone) mode.\n"
 fi
 
 # Exit if old syntax found
diff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmd
index e43141d9dcf..0455d7c0a7d 100755
--- a/solr/bin/solr.cmd
+++ b/solr/bin/solr.cmd
@@ -443,6 +443,7 @@ IF "%1"=="--quiet" goto set_warn
 IF "%1"=="-c" goto set_cloud_mode
 IF "%1"=="-cloud" goto set_cloud_mode
 IF "%1"=="--cloud" goto set_cloud_mode
+IF "%1"=="--user-managed" goto set_user_managed_mode
 IF "%1"=="-d" goto set_server_dir
 IF "%1"=="--dir" goto set_server_dir
 IF "%1"=="--server-dir" goto set_server_dir
@@ -507,6 +508,13 @@ goto parse_args
 
 :set_cloud_mode
 set SOLR_MODE=solrcloud
+REM Notify user in 9.x about the default mode change if cloud flag is used.
+@echo Solr will start in SolrCloud mode by default in version 10, and you will 
no longer need to pass in -c or --cloud flag.
+SHIFT
+goto parse_args
+
+:set_user_managed_mode
+set SOLR_MODE=user-managed
 SHIFT
 goto parse_args
 
@@ -950,11 +958,16 @@ if !JAVA_MAJOR_VERSION! LSS 9  (
 )
 
 IF NOT "%ZK_HOST%"=="" set SOLR_MODE=solrcloud
-IF "%SOLR_MODE%"=="" set SOLR_MODE=solrcloud
+IF "%SOLR_MODE%"=="" (
+  REM User has not provided any option for the mode (--cloud/--user-managed), 
therefore
+  REM stay on user-managed mode in 9.x to avoid behavior changing / breaking 
changes
+  set SOLR_MODE="user-managed"
+  REM and notify that staying the default option (not providing 
--user-managed) will affect
+  REM future execution
+  echo Solr will start in SolrCloud mode by default in version 10, and you 
will have to provide --user-managed if you want to stay on the user-managed 
(aka. standalone) mode.
+)
 
 IF "%SOLR_MODE%"=="solrcloud" (
-  @echo Solr will start in SolrCloud mode by default in version 10, and you 
will no longer need to pass in -c or --cloud flag.
-  @echo.
   IF "%ZK_CLIENT_TIMEOUT%"=="" set "ZK_CLIENT_TIMEOUT=30000"
 
   set "CLOUD_MODE_OPTS=-DzkClientTimeout=!ZK_CLIENT_TIMEOUT!"
@@ -989,7 +1002,6 @@ IF "%SOLR_MODE%"=="solrcloud" (
   IF EXIST "%SOLR_HOME%\collection1\core.properties" set 
"CLOUD_MODE_OPTS=!CLOUD_MODE_OPTS! -Dbootstrap_confdir=./solr/collection1/conf 
-Dcollection.configName=myconf -DnumShards=1"
 ) ELSE (
   set CLOUD_MODE_OPTS=
-  @echo Solr will start in SolrCloud mode by default in version 10.  You will 
need to pass in --user-managed flag to run in User Managed (aka Standalone) 
mode.
   IF NOT EXIST "%SOLR_HOME%\solr.xml" (
     IF "%SOLR_SOLRXML_REQUIRED%"=="true" (
       set "SCRIPT_ERROR=Solr home directory %SOLR_HOME% must contain solr.xml!"
diff --git a/solr/packaging/test/test_start_solr.bats 
b/solr/packaging/test/test_start_solr.bats
index 838046dd216..6c82dc117cf 100644
--- a/solr/packaging/test/test_start_solr.bats
+++ b/solr/packaging/test/test_start_solr.bats
@@ -50,10 +50,27 @@ teardown() {
 
 }
 
-@test "start provides warning about SolrCloud mode" {
+@test "start warns about SolrCloud mode if no mode specified" {
   run solr start
-  solr assert --started http://localhost:${SOLR_PORT} --timeout 5000
-  assert_output --partial 'Solr will start in SolrCloud mode by default in 
version 10.  You will need to pass in --user-managed flag to run in User 
Managed (aka Standalone) mode.'
+  # Default behavior should be user-managed mode in Solr 9
+  solr assert --not-cloud http://localhost:${SOLR_PORT} --timeout 5000
+  assert_output --partial 'Solr will start in SolrCloud mode by default in 
version 10'
+  assert_output --partial 'you will have to provide --user-managed'
+  solr stop
+}
+
+@test "start warns about SolrCloud mode if --cloud used" {
+  run solr start --cloud
+  solr assert --cloud http://localhost:${SOLR_PORT} --timeout 5000
+  assert_output --partial 'Solr will start in SolrCloud mode by default in 
version 10'
+  assert_output --partial 'you will no longer need to pass in -c or --cloud 
flag'
+  solr stop
+}
+
+@test "start doesn't warn about SolrCloud mode if --user-managed used" {
+  run solr start --user-managed
+  solr assert --not-cloud http://localhost:${SOLR_PORT} --timeout 5000
+  refute_output --partial 'Solr will start in SolrCloud mode by default in 
version 10'
   solr stop
 }
 

Reply via email to