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

[tor-commits] [chutney/master] tools: Add a diagnostics mode to test-network.sh



commit 37c88afccec4817e99ab285ae729b2dcf5c3ae11
Author: teor <teor@xxxxxxxxxxxxxx>
Date:   Mon Feb 17 17:11:45 2020 +1000

    tools: Add a diagnostics mode to test-network.sh
    
    Like --warnings and --only-warnings, tools/test-network.sh now supports
    --diagnostics and --only-diagnostics, which run tools/diagnostics.sh.
    
    Part of 32792.
---
 README                     |  2 ++
 tools/test-network-impl.sh |  7 +++++++
 tools/test-network.sh      | 31 +++++++++++++++++++++++++++++--
 3 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/README b/README
index 0475b2f..9712232 100644
--- a/README
+++ b/README
@@ -79,6 +79,8 @@ Warning Options:
                      CHUTNEY_WARNINGS_SUMMARY=false
   --no-warnings      CHUTNEY_WARNINGS_SKIP=true
   --only-warnings    CHUTNEY_WARNINGS_ONLY=true
+  --diagnostics      CHUTNEY_DIAGNOSTICS=true
+  --only-diagnostics CHUTNEY_DIAGNOSTICS_ONLY=true
 
 Expert Options:
   --debug            CHUTNEY_DEBUG=true
diff --git a/tools/test-network-impl.sh b/tools/test-network-impl.sh
index 73b942b..8a8413d 100755
--- a/tools/test-network-impl.sh
+++ b/tools/test-network-impl.sh
@@ -5,6 +5,7 @@ if ! "$CHUTNEY_PATH/tools/bootstrap-network.sh" "$NETWORK_FLAVOUR"; then
 	$ECHO "SKIP: $NETWORK_FLAVOR not supported."
 	exit 77
     fi
+    "$DIAGNOSTICS"
     CHUTNEY_WARNINGS_IGNORE_EXPECTED=false CHUTNEY_WARNINGS_SUMMARY=false \
         "$WARNING_COMMAND"
     "$WARNINGS"
@@ -35,6 +36,7 @@ if [ "$CHUTNEY_START_TIME" -ge 0 ]; then
 else
     $ECHO "Chutney network launched and running. To stop the network, use:"
     $ECHO "$CHUTNEY stop $CHUTNEY_NETWORK"
+    "$DIAGNOSTICS"
     "$WARNINGS"
     exit 0
 fi
@@ -47,6 +49,7 @@ if [ "$CHUTNEY_BOOTSTRAP_TIME" -ge 0 ]; then
     while [ "$n_rounds" -lt "$CHUTNEY_ROUNDS" ]; do
         n_rounds=$((n_rounds+1))
         if ! "$CHUTNEY" verify "$CHUTNEY_NETWORK"; then
+            "$DIAGNOSTICS"
             CHUTNEY_WARNINGS_IGNORE_EXPECTED=false \
                 CHUTNEY_WARNINGS_SUMMARY=false \
                 "$WARNING_COMMAND"
@@ -59,6 +62,7 @@ if [ "$CHUTNEY_BOOTSTRAP_TIME" -ge 0 ]; then
 else
     $ECHO "Chutney network ready and running. To stop the network, use:"
     $ECHO "$CHUTNEY stop $CHUTNEY_NETWORK"
+    "$DIAGNOSTICS"
     "$WARNINGS"
     exit 0
 fi
@@ -71,6 +75,7 @@ if [ "$CHUTNEY_STOP_TIME" -ge 0 ]; then
     # 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
+        "$DIAGNOSTICS"
         CHUTNEY_WARNINGS_IGNORE_EXPECTED=false CHUTNEY_WARNINGS_SUMMARY=false \
             "$WARNING_COMMAND"
         "$WARNINGS"
@@ -82,9 +87,11 @@ if [ "$CHUTNEY_STOP_TIME" -ge 0 ]; then
 else
     $ECHO "Chutney network verified and running. To stop the network, use:"
     $ECHO "$CHUTNEY stop $CHUTNEY_NETWORK"
+    "$DIAGNOSTICS"
     "$WARNINGS"
     exit 0
 fi
 
+"$DIAGNOSTICS"
 "$WARNINGS"
 exit 0
diff --git a/tools/test-network.sh b/tools/test-network.sh
index 213dab4..d2507b4 100755
--- a/tools/test-network.sh
+++ b/tools/test-network.sh
@@ -155,6 +155,14 @@ do
         --no-warnings)
             export CHUTNEY_WARNINGS_SKIP=true
             ;;
+        # output diagnostics after chutney runs
+        --diagnostics)
+            export CHUTNEY_DIAGNOSTICS=true
+            ;;
+        # this doesn't run chutney, and only logs diagnostics
+        --only-diagnostics)
+            export CHUTNEY_DIAGNOSTICS_ONLY=true
+            ;;
         # Expert options
         # Code Coverage Binary
         --coverage)
@@ -192,9 +200,18 @@ do
     shift
 done
 
+if [ "$CHUTNEY_WARNINGS_ONLY" = true ] || \
+   [ "$CHUTNEY_DIAGNOSTICS_ONLY" = true ]; then
+    NETWORK_DRY_RUN=true
+fi
+
+if [ "$CHUTNEY_DIAGNOSTICS_ONLY" = true ]; then
+    export CHUTNEY_DIAGNOSTICS=true
+fi
+
 # If the DNS server doesn't work, tor exits may reject all exit traffic, and
 # chutney may fail
-if [ "$CHUTNEY_WARNINGS_ONLY" != true ]; then
+if [ "$NETWORK_DRY_RUN" != true ]; then
     $ECHO "$myname: using CHUTNEY_DNS_CONF '$CHUTNEY_DNS_CONF'"
 fi
 
@@ -332,6 +349,13 @@ $ECHO "$myname: Using \$CHUTNEY_TOR: '$CHUTNEY_TOR' and \$CHUTNEY_TOR_GENCERT: '
 export NETWORK_FLAVOUR=${NETWORK_FLAVOUR:-"bridges+hs-v23"}
 export CHUTNEY_NETWORK="$CHUTNEY_PATH/networks/$NETWORK_FLAVOUR"
 
+export DIAGNOSTIC_COMMAND="$CHUTNEY_PATH/tools/diagnostics.sh"
+if [ "$CHUTNEY_DIAGNOSTICS" = true ]; then
+    export DIAGNOSTICS="$DIAGNOSTIC_COMMAND"
+else
+    export DIAGNOSTICS=true
+fi
+
 export WARNING_COMMAND="$CHUTNEY_PATH/tools/warnings.sh"
 if [ "$CHUTNEY_WARNINGS_SKIP" = true ]; then
     export WARNINGS=true
@@ -340,7 +364,10 @@ else
 fi
 
 # And finish up if we're doing a dry run
-if [ "$NETWORK_DRY_RUN" = true ] || [ "$CHUTNEY_WARNINGS_ONLY" = true ]; then
+if [ "$NETWORK_DRY_RUN" = true ]; then
+    if [ "$CHUTNEY_DIAGNOSTICS_ONLY" = true ]; then
+        "$DIAGNOSTICS"
+    fi
     if [ "$CHUTNEY_WARNINGS_ONLY" = true ]; then
         "$WARNINGS"
     fi



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