You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ho...@apache.org on 2022/09/23 16:51:12 UTC

[solr] branch main updated: SOLR-16232: Fix EnvVar usage in bin/solr (#892)

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

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


The following commit(s) were added to refs/heads/main by this push:
     new 5cf79e9df55 SOLR-16232: Fix EnvVar usage in bin/solr (#892)
5cf79e9df55 is described below

commit 5cf79e9df55177f24f8a6d27ca8b6a13697b1d61
Author: Houston Putman <ho...@apache.org>
AuthorDate: Fri Sep 23 12:51:07 2022 -0400

    SOLR-16232: Fix EnvVar usage in bin/solr (#892)
---
 solr/CHANGES.txt                     |  2 ++
 solr/bin/solr                        | 27 +++++++++++---------------
 solr/packaging/test/test_export.bats | 37 ++++++++++++++++++++++++++++++++++++
 3 files changed, 50 insertions(+), 16 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 2a4541227f1..900587bbc63 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -168,6 +168,8 @@ Bug Fixes
 
 * SOLR-16426: LBHttp2SolrClient (and therefore CloudHttp2SolrClient) now respect requestWriter, responseParser and queryParam changes (Houston Putman)
 
+* SOLR-16232: Fix EnvVar usage in bin/solr (Houston Putman)
+
 Other Changes
 ---------------------
 * SOLR-16351: Upgrade Carrot2 to 4.4.3, upgrade randomizedtesting to 2.8.0. (Dawid Weiss)
diff --git a/solr/bin/solr b/solr/bin/solr
index 83b41e9b58d..d5fb182e05c 100755
--- a/solr/bin/solr
+++ b/solr/bin/solr
@@ -830,7 +830,7 @@ function run_package() {
     fi
   fi
 
-  run_tool package -solrUrl "$runningSolrUrl" $@
+  run_tool package -solrUrl "$runningSolrUrl" "$@"
   #exit $?
 }
 
@@ -876,7 +876,7 @@ function stop_solr() {
 
   STAT=`(ps -o stat='' -p $SOLR_PID || :) | tr -d ' '`
   if [[ "${STAT:-Z}" != "Z" ]]; then
-    if [ -n "{$JSTACK:-}" ]; then
+    if [ -n "${JSTACK:-}" ]; then
       echo -e "Solr process $SOLR_PID is still running; jstacking it now."
       $JSTACK $SOLR_PID
     elif [ "$JATTACH" != "" ]; then
@@ -1433,12 +1433,12 @@ fi
 
 
 if [[ "$SCRIPT_CMD" == "export" ]]; then
-  run_tool export $@
+  run_tool export "$@"
   exit $?
 fi
 
 if [[ "$SCRIPT_CMD" == "package" ]]; then
-  run_package $@
+  run_package "$@"
   exit $?
 fi
 
@@ -1574,7 +1574,7 @@ if [[ "$SCRIPT_CMD" == "auth" ]]; then
         fi
       done
   fi
-  run_tool auth ${AUTH_PARAMS[@]} -solrUrl "$SOLR_URL_SCHEME://$SOLR_TOOL_HOST:${AUTH_PORT:-8983}/solr" -authConfDir "$SOLR_HOME" $VERBOSE
+  run_tool auth "${AUTH_PARAMS[@]}" -solrUrl "$SOLR_URL_SCHEME://$SOLR_TOOL_HOST:${AUTH_PORT:-8983}/solr" -authConfDir "$SOLR_HOME" $VERBOSE
   exit $?
 fi
 
@@ -1987,11 +1987,6 @@ if [[ -n ${SOLR_DATA_HOME:-} ]] && [ ! -e "$SOLR_DATA_HOME" ]; then
   echo -e "\nSolr data home directory $SOLR_DATA_HOME not found!\n"
   exit 1
 fi
-if $verbose ; then
-  q=""
-else
-  q="-q"
-fi
 
 # Establish default GC logging opts if no env var set (otherwise init to sensible default)
 if [ -z ${GC_LOG_OPTS+x} ]; then
@@ -2203,17 +2198,17 @@ function start_solr() {
     echo -e "    SOLR_HOST       = ${SOLR_HOST:-}"
     echo -e "    SOLR_PORT       = $SOLR_PORT"
     echo -e "    STOP_PORT       = $STOP_PORT"
-    echo -e "    JAVA_MEM_OPTS   = ${JAVA_MEM_OPTS[@]}"
-    echo -e "    GC_TUNE         = ${GC_TUNE[@]}"
-    echo -e "    GC_LOG_OPTS     = ${GC_LOG_OPTS[@]}"
+    echo -e "    JAVA_MEM_OPTS   = ${JAVA_MEM_OPTS[*]}"
+    echo -e "    GC_TUNE         = ${GC_TUNE[*]}"
+    echo -e "    GC_LOG_OPTS     = ${GC_LOG_OPTS[*]}"
     echo -e "    SOLR_TIMEZONE   = $SOLR_TIMEZONE"
 
     if [ "$SOLR_MODE" == "solrcloud" ]; then
-      echo -e "    CLOUD_MODE_OPTS = ${CLOUD_MODE_OPTS[@]}"
+      echo -e "    CLOUD_MODE_OPTS = ${CLOUD_MODE_OPTS[*]}"
     fi
 
     if [ -n "${SOLR_OPTS:-}" ]; then
-      echo -e "    SOLR_OPTS       = ${SOLR_OPTS[@]}"
+      echo -e "    SOLR_OPTS       = ${SOLR_OPTS[*]}"
     fi
 
     if [ -n "${SOLR_ADDL_ARGS:-}" ]; then
@@ -2222,7 +2217,7 @@ function start_solr() {
 
     if [ "${ENABLE_REMOTE_JMX_OPTS:-false}" == "true" ]; then
       echo -e "    RMI_PORT        = ${RMI_PORT:-}"
-      echo -e "    REMOTE_JMX_OPTS = ${REMOTE_JMX_OPTS[@]}"
+      echo -e "    REMOTE_JMX_OPTS = ${REMOTE_JMX_OPTS[*]}"
     fi
 
     if [ -n "${SOLR_LOG_LEVEL:-}" ]; then
diff --git a/solr/packaging/test/test_export.bats b/solr/packaging/test/test_export.bats
new file mode 100644
index 00000000000..e6f1d5fbde1
--- /dev/null
+++ b/solr/packaging/test/test_export.bats
@@ -0,0 +1,37 @@
+#!/usr/bin/env bats
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load bats_helper
+
+setup() {
+  common_clean_setup
+}
+
+teardown() {
+  # save a snapshot of SOLR_HOME for failed tests
+  save_home_on_failure
+
+  solr stop -all >/dev/null 2>&1
+}
+
+@test "Check export command" {
+  run solr start -c -Dsolr.modules=sql
+  run solr create_collection -c COLL_NAME
+  run solr export -url "http://localhost:8983/solr/COLL_NAME" -query "*:* -id:test" -out "${BATS_TEST_TMPDIR}/output"
+  refute_output --partial 'Unrecognized option'
+  assert_output --partial 'Export complete'
+}