[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [chutney/master] Extract the body of test-network.sh into a new script.



commit a2bd9bce2f733493fd3e9578f9ee8fc1176b57d0
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Tue Mar 12 08:39:38 2019 -0400

    Extract the body of test-network.sh into a new script.
---
 tools/test-network-impl.sh | 79 +++++++++++++++++++++++++++++++++++++++++++
 tools/test-network.sh      | 84 +++-------------------------------------------
 2 files changed, 83 insertions(+), 80 deletions(-)

diff --git a/tools/test-network-impl.sh b/tools/test-network-impl.sh
new file mode 100755
index 0000000..2de1bfa
--- /dev/null
+++ b/tools/test-network-impl.sh
@@ -0,0 +1,79 @@
+#!/bin/sh
+
+if ! "$CHUTNEY_PATH/tools/bootstrap-network.sh" "$NETWORK_FLAVOUR"; then
+    CHUTNEY_WARNINGS_IGNORE_EXPECTED=false CHUTNEY_WARNINGS_SUMMARY=false \
+        "$WARNING_COMMAND"
+    "$WARNINGS"
+    $ECHO "bootstrap-network.sh failed"
+    exit 1
+fi
+
+# chutney starts verifying after 20 seconds, keeps on trying for 60 seconds,
+# and then stops immediately (by default)
+# Even the fastest chutney networks take 5-10 seconds for their first consensus
+# and then 10 seconds after that for relays to bootstrap and upload descriptors
+export CHUTNEY_START_TIME=${CHUTNEY_START_TIME:-40}
+export CHUTNEY_BOOTSTRAP_TIME=${CHUTNEY_BOOTSTRAP_TIME:-60}
+export CHUTNEY_STOP_TIME=${CHUTNEY_STOP_TIME:-0}
+
+CHUTNEY="$CHUTNEY_PATH/chutney"
+
+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 "$CHUTNEY stop $CHUTNEY_NETWORK"
+    "$WARNINGS"
+    exit 0
+fi
+
+if [ "$CHUTNEY_BOOTSTRAP_TIME" -ge 0 ]; then
+    # Chutney will try to verify for $CHUTNEY_BOOTSTRAP_TIME seconds each round
+    n_rounds=0
+    # Run CHUTNEY_ROUNDS verification rounds
+    $ECHO "Running $CHUTNEY_ROUNDS verify rounds..."
+    while [ "$n_rounds" -lt "$CHUTNEY_ROUNDS" ]; do
+        n_rounds=$((n_rounds+1))
+        if ! "$CHUTNEY" verify "$CHUTNEY_NETWORK"; then
+            CHUTNEY_WARNINGS_IGNORE_EXPECTED=false \
+                CHUTNEY_WARNINGS_SUMMARY=false \
+                "$WARNING_COMMAND"
+            "$WARNINGS"
+            $ECHO "chutney verify $n_rounds/$CHUTNEY_ROUNDS failed"
+            exit 1
+        fi
+        $ECHO "Completed $n_rounds/$CHUTNEY_ROUNDS verify rounds."
+    done
+else
+    $ECHO "Chutney network ready and running. To stop the network, use:"
+    $ECHO "$CHUTNEY stop $CHUTNEY_NETWORK"
+    "$WARNINGS"
+    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
+    if ! "$CHUTNEY" stop "$CHUTNEY_NETWORK"; then
+        CHUTNEY_WARNINGS_IGNORE_EXPECTED=false CHUTNEY_WARNINGS_SUMMARY=false \
+            "$WARNING_COMMAND"
+        "$WARNINGS"
+        $ECHO "chutney stop failed"
+        exit 1
+    fi
+    # Give tor time to exit gracefully
+    sleep 3
+else
+    $ECHO "Chutney network verified and running. To stop the network, use:"
+    $ECHO "$CHUTNEY stop $CHUTNEY_NETWORK"
+    "$WARNINGS"
+    exit 0
+fi
+
+"$WARNINGS"
+exit 0
diff --git a/tools/test-network.sh b/tools/test-network.sh
index ec58e20..b430694 100755
--- a/tools/test-network.sh
+++ b/tools/test-network.sh
@@ -315,11 +315,11 @@ $ECHO "$myname: Using \$CHUTNEY_TOR: '$CHUTNEY_TOR' and \$CHUTNEY_TOR_GENCERT: '
 export NETWORK_FLAVOUR=${NETWORK_FLAVOUR:-"bridges+hs-v2"}
 export CHUTNEY_NETWORK="$CHUTNEY_PATH/networks/$NETWORK_FLAVOUR"
 
-WARNING_COMMAND="$CHUTNEY_PATH/tools/warnings.sh"
+export WARNING_COMMAND="$CHUTNEY_PATH/tools/warnings.sh"
 if [ "$CHUTNEY_WARNINGS_SKIP" = true ]; then
-    WARNINGS=true
+    export WARNINGS=true
 else
-    WARNINGS="$WARNING_COMMAND"
+    export WARNINGS="$WARNING_COMMAND"
 fi
 
 # And finish up if we're doing a dry run
@@ -333,80 +333,4 @@ if [ "$NETWORK_DRY_RUN" = true ] || [ "$CHUTNEY_WARNINGS_ONLY" = true ]; then
     exit 0
 fi
 
-if ! "$CHUTNEY_PATH/tools/bootstrap-network.sh" "$NETWORK_FLAVOUR"; then
-    CHUTNEY_WARNINGS_IGNORE_EXPECTED=false CHUTNEY_WARNINGS_SUMMARY=false \
-        "$WARNING_COMMAND"
-    "$WARNINGS"
-    $ECHO "bootstrap-network.sh failed"
-    exit 1
-fi
-
-# chutney starts verifying after 20 seconds, keeps on trying for 60 seconds,
-# and then stops immediately (by default)
-# Even the fastest chutney networks take 5-10 seconds for their first consensus
-# and then 10 seconds after that for relays to bootstrap and upload descriptors
-export CHUTNEY_START_TIME=${CHUTNEY_START_TIME:-40}
-export CHUTNEY_BOOTSTRAP_TIME=${CHUTNEY_BOOTSTRAP_TIME:-60}
-export CHUTNEY_STOP_TIME=${CHUTNEY_STOP_TIME:-0}
-
-CHUTNEY="$CHUTNEY_PATH/chutney"
-
-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 "$CHUTNEY stop $CHUTNEY_NETWORK"
-    "$WARNINGS"
-    exit 0
-fi
-
-if [ "$CHUTNEY_BOOTSTRAP_TIME" -ge 0 ]; then
-    # Chutney will try to verify for $CHUTNEY_BOOTSTRAP_TIME seconds each round
-    n_rounds=0
-    # Run CHUTNEY_ROUNDS verification rounds
-    $ECHO "Running $CHUTNEY_ROUNDS verify rounds..."
-    while [ "$n_rounds" -lt "$CHUTNEY_ROUNDS" ]; do
-        n_rounds=$((n_rounds+1))
-        if ! "$CHUTNEY" verify "$CHUTNEY_NETWORK"; then
-            CHUTNEY_WARNINGS_IGNORE_EXPECTED=false \
-                CHUTNEY_WARNINGS_SUMMARY=false \
-                "$WARNING_COMMAND"
-            "$WARNINGS"
-            $ECHO "chutney verify $n_rounds/$CHUTNEY_ROUNDS failed"
-            exit 1
-        fi
-        $ECHO "Completed $n_rounds/$CHUTNEY_ROUNDS verify rounds."
-    done
-else
-    $ECHO "Chutney network ready and running. To stop the network, use:"
-    $ECHO "$CHUTNEY stop $CHUTNEY_NETWORK"
-    "$WARNINGS"
-    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
-    if ! "$CHUTNEY" stop "$CHUTNEY_NETWORK"; then
-        CHUTNEY_WARNINGS_IGNORE_EXPECTED=false CHUTNEY_WARNINGS_SUMMARY=false \
-            "$WARNING_COMMAND"
-        "$WARNINGS"
-        $ECHO "chutney stop failed"
-        exit 1
-    fi
-    # Give tor time to exit gracefully
-    sleep 3
-else
-    $ECHO "Chutney network verified and running. To stop the network, use:"
-    $ECHO "$CHUTNEY stop $CHUTNEY_NETWORK"
-    "$WARNINGS"
-    exit 0
-fi
-
-"$WARNINGS"
-exit 0
+exec "$CHUTNEY_PATH/tools/test-network-impl.sh"



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits