You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by mm...@apache.org on 2019/07/23 15:15:39 UTC

[accumulo-testing] branch master updated: Fixes from shellcheck. Closes #69 (#102)

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

mmiller pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/accumulo-testing.git


The following commit(s) were added to refs/heads/master by this push:
     new 63af461  Fixes from shellcheck. Closes #69 (#102)
63af461 is described below

commit 63af461cfe4b93ce3dc9ac4ca0a635e881c1eb8f
Author: Mike Miller <mm...@apache.org>
AuthorDate: Tue Jul 23 11:15:33 2019 -0400

    Fixes from shellcheck. Closes #69 (#102)
---
 bin/agitator    | 40 +++++++++++++++-------------------------
 bin/cingest     |  3 +--
 bin/gcs         |  1 -
 bin/mapred      |  2 +-
 bin/performance |  6 +++---
 5 files changed, 20 insertions(+), 32 deletions(-)

diff --git a/bin/agitator b/bin/agitator
index c881d0f..8d15f94 100755
--- a/bin/agitator
+++ b/bin/agitator
@@ -44,28 +44,21 @@ function start_agitator() {
   datanode_cmd="nohup ${libexec}/datanode-agitator.pl $AGTR_DATANODE_KILL_SLEEP_TIME $AGTR_DATANODE_RESTART_SLEEP_TIME $HADOOP_HOME $AGTR_DATANODE_MIN_KILL $AGTR_DATANODE_MAX_KILL"
   [[ -n $AGITATOR_USER ]] || AGITATOR_USER=$(whoami)
 
-  if [[ $AGITATOR_USER == root ]];  then
-    echo "Running master-agitator and tserver-agitator as $AGTR_ACCUMULO_USER using su. Running datanode-agitator as $AGTR_HDFS_USER using su."
-    su -c "$master_cmd >${master_log}.out 2>${master_log}.err" & -m - "$AGTR_ACCUMULO_USER"
-    su -c "$tserver_cmd >${tserver_log}.out 2>${tserver_log}.err" & -m - "$AGTR_ACCUMULO_USER"
-    su -c "$datanode_cmd >${datanode_log}.out 2>${datanode_log}.err" & -m - "$AGTR_HDFS_USER"
+  if [[ $AGITATOR_USER == "$AGTR_ACCUMULO_USER" ]]; then
+    echo "Running master-agitator and tserver-agitator as $AGITATOR_USER"
+    $master_cmd > "${master_log}.out" 2> "${master_log}.err" &
+    $tserver_cmd > "${tserver_log}.out" 2> "${tserver_log}.err" &
   else
-    if [[ $AGITATOR_USER == "$AGTR_ACCUMULO_USER" ]]; then
-      echo "Running master-agitator and tserver-agitator as $AGITATOR_USER"
-      $master_cmd > "${master_log}.out" 2> "${master_log}.err" &
-      $tserver_cmd > "${tserver_log}.out" 2> "${tserver_log}.err" &
-    else
-      echo "Running master-agitator and tserver-agitator as $AGTR_ACCUMULO_USER using sudo."
-      sudo -u "$AGTR_ACCUMULO_USER" $master_cmd > "${master_log}.out" 2> "${master_log}.err" &
-      sudo -u "$AGTR_ACCUMULO_USER" $tserver_cmd > "${tserver_log}.out" 2> "${tserver_log}.err" &
-    fi
-    if [[ $AGITATOR_USER == "$AGTR_HDFS_USER" ]]; then
-      echo "Running datanode-agitator as $AGITATOR_USER"
-      $datanode_cmd > "${datanode_log}.out" 2> "${datanode_log}.err" &
-    else
-      echo "Running datanode-agitator as $AGTR_HDFS_USER using sudo."
-      sudo -u "$AGTR_HDFS_USER" $datanode_cmd > "${datanode_log}.out" 2> "${datanode_log}.err" &
-    fi
+    echo "Running master-agitator and tserver-agitator as $AGTR_ACCUMULO_USER using sudo."
+    sudo -u "$AGTR_ACCUMULO_USER" "$master_cmd" > "${master_log}.out" 2> "${master_log}.err" &
+    sudo -u "$AGTR_ACCUMULO_USER" "$tserver_cmd" > "${tserver_log}.out" 2> "${tserver_log}.err" &
+  fi
+  if [[ $AGITATOR_USER == "$AGTR_HDFS_USER" ]]; then
+    echo "Running datanode-agitator as $AGITATOR_USER"
+    $datanode_cmd > "${datanode_log}.out" 2> "${datanode_log}.err" &
+  else
+    echo "Running datanode-agitator as $AGTR_HDFS_USER using sudo."
+    sudo -u "$AGTR_HDFS_USER" "$datanode_cmd" > "${datanode_log}.out" 2> "${datanode_log}.err" &
   fi
 
   if ${AGTR_HDFS:-false} ; then
@@ -76,10 +69,7 @@ function start_agitator() {
 
 function stop_agitator() {
   [[ -n $AGITATOR_USER ]] || AGITATOR_USER=$(whoami)
-  if [[ $AGITATOR_USER == root ]]; then
-    echo "Stopping all processes matching 'agitator.pl' as root"
-    pkill -f agitator.pl 2>/dev/null
-  elif [[ $AGITATOR_USER == "$AGTR_ACCUMULO_USER" ]];  then
+  if [[ $AGITATOR_USER == "$AGTR_ACCUMULO_USER" ]];  then
     echo "Stopping all processes matching 'datanode-agitator.pl' as $AGTR_HDFS_USER"
     sudo -u "$AGTR_HDFS_USER" pkill -f datanode-agitator.pl 2>/dev/null
     echo "Stopping all processes matching 'hdfs-agitator.pl' as $AGTR_HDFS_USER"
diff --git a/bin/cingest b/bin/cingest
index 84aa615..ee4dbdf 100755
--- a/bin/cingest
+++ b/bin/cingest
@@ -16,7 +16,6 @@
 # limitations under the License.
 
 bin_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
-at_home=$( cd "$( dirname "$bin_dir" )" && pwd )
 source "${bin_dir}/build"
 
 function print_usage() {
@@ -84,7 +83,7 @@ export CLASSPATH="$TEST_JAR_PATH:$HADOOP_API_JAR:$HADOOP_RUNTIME_JAR:$CLASSPATH"
 
 case "$1" in
   verify|moru|bulk)
-    if [ ! -z $HADOOP_HOME ]; then
+    if [ -n "$HADOOP_HOME" ]; then
       export HADOOP_USE_CLIENT_CLASSLOADER=true
       "$HADOOP_HOME"/bin/yarn jar "$TEST_JAR_PATH" "$ci_main" "${@:2}" "$TEST_PROPS" "$ACCUMULO_CLIENT_PROPS"
     else
diff --git a/bin/gcs b/bin/gcs
index 8014546..5930d9e 100755
--- a/bin/gcs
+++ b/bin/gcs
@@ -16,7 +16,6 @@
 # limitations under the License.
 
 bin_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
-at_home=$( cd "$( dirname "$bin_dir" )" && pwd )
 source "${bin_dir}/build"
 
 function print_usage() {
diff --git a/bin/mapred b/bin/mapred
index fb6c82d..269c729 100755
--- a/bin/mapred
+++ b/bin/mapred
@@ -53,7 +53,7 @@ esac
 
 export CLASSPATH="$TEST_JAR_PATH:$HADOOP_API_JAR:$HADOOP_RUNTIME_JAR:$CLASSPATH"
 
-if [ ! -z $HADOOP_HOME ]; then
+if [ -n "$HADOOP_HOME" ]; then
   export HADOOP_USE_CLIENT_CLASSLOADER=true
   "$HADOOP_HOME"/bin/yarn jar "$TEST_JAR_PATH" "$mr_main" "$TEST_PROPS" "$ACCUMULO_CLIENT_PROPS" "${@:2}" 
 else
diff --git a/bin/performance b/bin/performance
index efcc68a..b6ed57c 100755
--- a/bin/performance
+++ b/bin/performance
@@ -39,7 +39,7 @@ function build_shade_jar() {
   if [ ! -f "$at_shaded_jar" ]; then
     echo "Building $at_shaded_jar"
     cd "$at_home" || exit 1
-    mvn clean package -P create-shade-jar -D skipTests -D accumulo.version=$(get_version "ACCUMULO") -D hadoop.version=$(get_version "HADOOP") -D zookeeper.version=$(get_version "ZOOKEEPER")
+    mvn clean package -P create-shade-jar -D skipTests -D accumulo.version="$(get_version 'ACCUMULO')" -D hadoop.version="$(get_version 'HADOOP')" -D zookeeper.version="$(get_version 'ZOOKEEPER')"
   fi
 }
 
@@ -58,7 +58,7 @@ if [ ! -f "$at_home/conf/cluster-control.sh" ]; then
   exit 1
 fi
 
-. $at_home/conf/cluster-control.sh
+source "$at_home"/conf/cluster-control.sh
 build_shade_jar
 CP="$at_home/target/accumulo-testing-shaded.jar:$(get_hadoop_client)"
 perf_pkg="org.apache.accumulo.testing.performance.impl"
@@ -71,7 +71,7 @@ case "$1" in
     fi
     mkdir -p "$2"
     start_cluster
-    CLASSPATH="$CP" java -Dlog4j.configuration="file:$log4j_config" ${perf_pkg}.ListTests | while read test_class; do
+    CLASSPATH="$CP" java -Dlog4j.configuration="file:$log4j_config" ${perf_pkg}.ListTests | while read -r test_class; do
       if [[ -z $3 || $test_class == *$3* ]]; then
         echo "Running test $test_class"
         pt_tmp=$(mktemp -d -t accumulo_pt_XXXXXXX)