From: Martin Schwenke Date: Mon, 5 Mar 2018 03:50:59 +0000 (+1100) Subject: ctdb-tests: Reindent setup_ctdb() function X-Git-Tag: talloc-2.1.12~207 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=caf6b1c684f3df4b4fc67a3cf08ea66025b21bd3;p=thirdparty%2Fsamba.git ctdb-tests: Reindent setup_ctdb() function 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 Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/tests/simple/scripts/local_daemons.bash b/ctdb/tests/simple/scripts/local_daemons.bash index b9da59ba01f..1c8b012dfdc 100644 --- a/ctdb/tests/simple/scripts/local_daemons.bash +++ b/ctdb/tests/simple/scripts/local_daemons.bash @@ -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" <"$conf" <>"$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 ()