commit d671658dab35571778572836a62485b95f5f7fc2 Author: teor (Tim Wilson-Brown) teor2345@gmail.com Date: Thu Jul 28 15:24:19 2016 +1000
Give test-network.sh a configurable delay before starting or stopping
--start-time is the delay before verifying --bootstrap-time is the delay while verifying before giving up --stop-time is the delay after verifying
In general, negative values stop immediately, leaving the network running. (See the README for details.)
Implements feature #19764. --- README | 31 +++++++++++++++++------ tools/test-network.sh | 69 ++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 80 insertions(+), 20 deletions(-)
diff --git a/README b/README index a2f9f7c..a8024fa 100644 --- a/README +++ b/README @@ -34,7 +34,12 @@ itself. You can modify its configuration using command-line arguments, or use the chutney environmental variables documented below:
- --delay CHUTNEY_BOOTSTRAP_TIME +Timing Options: + --start-time CHUTNEY_START_TIME + --bootstrap-time CHUTNEY_BOOTSTRAP_TIME + --stop-time CHUTNEY_STOP_TIME + +Traffic Options: --data CHUTNEY_DATA_BYTES --connections CHUTNEY_CONNECTIONS --hs-multi-client CHUTNEY_HS_MULTI_CLIENT @@ -81,15 +86,25 @@ HS Connection Tests: # Default behavior is one client connects to each HS ./chutney stop networks/hs-025
-Waiting for the network to bootstrap: +Waiting for the network:
- Commands like "chutney verify" start immediately, and keep trying for - CHUTNEY_BOOTSTRAP_TIME seconds. If they haven't been successful after that - time, they fail. + The tools/test-network.sh script waits CHUTNEY_START_TIME seconds + (default: 15) before calling chutney verify, because that's the minimum + amount of time it takes to bootstrap a consensus containing relays. + (It takes 5 seconds for the authorities to create the first consensus, + then 10 seconds for relays to bootstrap, submit their descriptors, and be + included in the next consensus.) If CHUTNEY_START_TIME is negative, the + script leaves the network running, and exits immediately (without verifying).
- The tools/test-network.sh script waits 15 seconds before calling chutney - verify, because that's the minimum amount of time it takes to bootstrap a - consensus containing relays. + Commands like "chutney verify" start immediately, and keep trying for + CHUTNEY_BOOTSTRAP_TIME seconds (default: 60). If it hasn't been + successful after that time, it fails. If CHUTNEY_BOOTSTRAP_TIME is negative, + the script leaves the network running, and exits after CHUTNEY_START_TIME + (without verifying). + + The tools/test-network.sh script waits CHUTNEY_STOP_TIME seconds + after verifying, then exits (default: immediately). If CHUTNEY_STOP_TIME is + negative, the script leaves the network running, and exits after verifying.
Changing the network address:
diff --git a/tools/test-network.sh b/tools/test-network.sh index 1d4816e..f2069d6 100755 --- a/tools/test-network.sh +++ b/tools/test-network.sh @@ -32,10 +32,26 @@ do export NETWORK_FLAVOUR="$2" shift ;; - --delay|--sleep|--bootstrap-time|--time) + # The amount of time chutney will wait before starting to verify + # If negative, chutney exits straight after launching the network + --start-time) + export CHUTNEY_START_TIME="$2" + shift + ;; + # The amount of time chutney will try to verify, before failing + # If negative, chutney exits without verifying + --delay|--sleep|--bootstrap-time|--time|--verify-time) + # This isn't the best name for this variable, but we kept it the same + # for backwards compatibility export CHUTNEY_BOOTSTRAP_TIME="$2" shift ;; + # The amount of time chutney will wait after successfully verifying + # If negative, chutney exits without stopping + --stop-time) + export CHUTNEY_STOP_TIME="$2" + shift + ;; # Environmental variables used by chutney verify performance tests # Send this many bytes per client connection (10 KBytes) --data|--data-bytes|--data-byte|--bytes|--byte) @@ -161,15 +177,44 @@ fi cd "$CHUTNEY_PATH" ./tools/bootstrap-network.sh $NETWORK_FLAVOUR || exit 2
-# chutney verify starts immediately, and keeps on trying for 60 seconds -CHUTNEY_BOOTSTRAP_TIME=${CHUTNEY_BOOTSTRAP_TIME:-60} -# but even the fastest tor networks take 5 seconds for their first consensus +# chutney starts verifying after 15 seconds, keeps on trying for 60 seconds, +# and then stops immediately (by default) +# Even the fastest chutney networks take 5 seconds for their first consensus # and then 10 seconds after that for relays to bootstrap and upload descriptors -echo "Waiting 15 seconds for a consensus containing relays to be generated..." -sleep 15 -./chutney verify $CHUTNEY_NETWORK -VERIFY_EXIT_STATUS=$? -# work around a bug/feature in make -j2 (or more) -# where make hangs if any child processes are still alive -./chutney stop $CHUTNEY_NETWORK -exit $VERIFY_EXIT_STATUS +CHUTNEY_START_TIME=${CHUTNEY_START_TIME:-15} +CHUTNEY_BOOTSTRAP_TIME=${CHUTNEY_BOOTSTRAP_TIME:-60} +CHUTNEY_STOP_TIME=${CHUTNEY_STOP_TIME:-0} + +if [ "$CHUTNEY_START_TIME" -ge 0 ]; then + echo "Waiting ${CHUTNEY_START_TIME} seconds for a consensus containing relays to be generated..." + sleep "$CHUTNEY_START_TIME" +else + echo "Chutney network launched and running. To stop the network, use:" + echo "$PWD/chutney stop $CHUTNEY_NETWORK" + exit 0 +fi + +if [ "$CHUTNEY_BOOTSTRAP_TIME" -ge 0 ]; then + # Chutney will try to verify for $CHUTNEY_BOOTSTRAP_TIME seconds + ./chutney verify $CHUTNEY_NETWORK + VERIFY_EXIT_STATUS=$? +else + echo "Chutney network ready and running. To stop the network, use:" + echo "$PWD/chutney stop $CHUTNEY_NETWORK" + exit 0 +fi + +if [ "$CHUTNEY_STOP_TIME" -ge 0 ]; then + if [ "$CHUTNEY_STOP_TIME" -gt 0 ]; then + echo "Waiting ${CHUTNEY_STOP_TIME} seconds before stopping the network..." + fi + sleep "$CHUTNEY_STOP_TIME" + # work around a bug/feature in make -j2 (or more) + # where make hangs if any child processes are still alive + ./chutney stop $CHUTNEY_NETWORK + exit $VERIFY_EXIT_STATUS +else + echo "Chutney network verified and running. To stop the network, use:" + echo "$PWD/chutney stop $CHUTNEY_NETWORK" + exit 0 +fi
tor-commits@lists.torproject.org