ctdb-tests: Reindent setup_ctdb() function
authorMartin Schwenke <martin@meltin.net>
Mon, 5 Mar 2018 03:50:59 +0000 (14:50 +1100)
committerMartin Schwenke <martins@samba.org>
Fri, 9 Mar 2018 06:08:25 +0000 (07:08 +0100)
This could have been done earlier but previous movement of lines out
to new functions has made the job easier.

Best viewed with show/diff -w.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/simple/scripts/local_daemons.bash

index b9da59ba01fc3f5de91e14f8ee49b5bb7b5d1251..1c8b012dfdc5e6741ba0f32e2b75b43bad28f9ef 100644 (file)
@@ -134,51 +134,51 @@ setup_public_addresses ()
 
 setup_ctdb ()
 {
-    # When running certain tests we add and remove eventscripts, so we
-    # need to be able to modify the events.d/ directory.  Therefore,
-    # we use a temporary events.d/ directory under $TEST_VAR_DIR.  We
-    # copy the actual test eventscript(s) in there from the original
-    # events.d/ directory that sits alongside $TEST_SCRIPT_DIR.
-    local top=$(dirname "$TEST_SCRIPTS_DIR")
-    local events_d="${top}/events.d"
-    mkdir -p "${TEST_VAR_DIR}/events.d"
-    cp -p "${events_d}/"* "${TEST_VAR_DIR}/events.d/"
-
-    setup_nodes >"$CTDB_NODES" || return 1
-
-    # If there are (strictly) greater than 2 nodes then we'll
-    # randomly choose a node to have no public addresses
-    local pnn_no_ips=-1
-    if [ $TEST_LOCAL_DAEMONS -gt 2 ] ; then
-           pnn_no_ips=$((RANDOM % TEST_LOCAL_DAEMONS))
-    fi
-
-    local public_addresses_all="${SIMPLE_TESTS_VAR_DIR}/public_addresses"
-    setup_public_addresses $pnn_no_ips >"$public_addresses_all"
+       # When running certain tests we add and remove eventscripts, so we
+       # need to be able to modify the events.d/ directory.  Therefore,
+       # we use a temporary events.d/ directory under $TEST_VAR_DIR.  We
+       # copy the actual test eventscript(s) in there from the original
+       # events.d/ directory that sits alongside $TEST_SCRIPT_DIR.
+       local top=$(dirname "$TEST_SCRIPTS_DIR")
+       local events_d="${top}/events.d"
+       mkdir -p "${TEST_VAR_DIR}/events.d"
+       cp -p "${events_d}/"* "${TEST_VAR_DIR}/events.d/"
+
+       setup_nodes >"$CTDB_NODES" || return 1
+
+       # If there are (strictly) greater than 2 nodes then we'll
+       # randomly choose a node to have no public addresses
+       local pnn_no_ips=-1
+       if [ $TEST_LOCAL_DAEMONS -gt 2 ] ; then
+               pnn_no_ips=$((RANDOM % TEST_LOCAL_DAEMONS))
+       fi
 
-    local pnn
-    for pnn in $(seq 0 $(($TEST_LOCAL_DAEMONS - 1))) ; do
-       local node_dir=$(node_dir "$pnn")
-       mkdir -p "$node_dir"
+       local public_addresses_all="${SIMPLE_TESTS_VAR_DIR}/public_addresses"
+       setup_public_addresses $pnn_no_ips >"$public_addresses_all"
 
-       local public_addresses="${node_dir}/public_addresses"
+       local pnn
+       for pnn in $(seq 0 $(($TEST_LOCAL_DAEMONS - 1))) ; do
+               local node_dir=$(node_dir "$pnn")
+               mkdir -p "$node_dir"
 
-       if  [ $pnn_no_ips -eq $pnn ] ; then
-           echo "Node ${pnn} will have no public IPs."
-           : >"$public_addresses"
-       else
-           cp "$public_addresses_all" "$public_addresses"
-       fi
+               local public_addresses="${node_dir}/public_addresses"
 
-       local node_ip=$(sed -n -e "$(($pnn + 1))p" "$CTDB_NODES")
+               if  [ $pnn_no_ips -eq $pnn ] ; then
+                       echo "Node ${pnn} will have no public IPs."
+                       : >"$public_addresses"
+               else
+                       cp "$public_addresses_all" "$public_addresses"
+               fi
 
-       local conf=$(node_conf "$pnn")
-       local socket=$(node_socket "$pnn")
+               local node_ip=$(sed -n -e "$(($pnn + 1))p" "$CTDB_NODES")
+
+               local conf=$(node_conf "$pnn")
+               local socket=$(node_socket "$pnn")
 
-       local db_dir="${node_dir}/db"
-       mkdir -p "${db_dir}/persistent"
+               local db_dir="${node_dir}/db"
+               mkdir -p "${db_dir}/persistent"
 
-       cat >"$conf" <<EOF
+               cat >"$conf" <<EOF
 CTDB_RECOVERY_LOCK="${SIMPLE_TESTS_VAR_DIR}/rec.lock"
 CTDB_NODES="$CTDB_NODES"
 CTDB_NODE_ADDRESS="${node_ip}"
@@ -193,10 +193,10 @@ CTDB_SOCKET="${socket}"
 CTDB_NOSETSCHED=yes
 EOF
 
-       # Append any configuration variables set in environment to
-       # configuration file so they affect CTDB after each restart.
-       config_from_environment >>"$conf"
-    done
+               # Append any configuration variables set in environment to
+               # configuration file so they affect CTDB after each restart.
+               config_from_environment >>"$conf"
+       done
 }
 
 start_ctdb_1 ()