Browse Source

Make tor clean up connections before stopping a chutney network

This increases integration test coverage, and improves the reliability of
any statistics being gathered on chutney networks.

Implements feature #21901.
teor 7 years ago
parent
commit
4334644994
3 changed files with 14 additions and 1 deletions
  1. 10 0
      lib/chutney/TorNet.py
  2. 2 0
      tools/test-network.sh
  3. 2 1
      torrc_templates/common.i

+ 10 - 0
lib/chutney/TorNet.py

@@ -982,17 +982,27 @@ class Network(object):
                 if c.isRunning():
                     c.stop(sig=sig)
             print("Waiting for nodes to finish.")
+            wrote_dot = False
             for n in range(15):
                 time.sleep(1)
                 if all(not c.isRunning() for c in controllers):
+                    # make the output clearer by adding a newline
+                    if wrote_dot:
+                        sys.stdout.write("\n")
+                        sys.stdout.flush()
                     # check for stale lock file when Tor crashes
                     for c in controllers:
                         c.cleanup_lockfile()
                     return
                 sys.stdout.write(".")
+                wrote_dot = True
                 sys.stdout.flush()
             for c in controllers:
                 c.check(listNonRunning=False)
+            # make the output clearer by adding a newline
+            if wrote_dot:
+                sys.stdout.write("\n")
+                sys.stdout.flush()
 
 
 def ConfigureNodes(nodelist):

+ 2 - 0
tools/test-network.sh

@@ -292,6 +292,8 @@ 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
   "$CHUTNEY" stop "$CHUTNEY_NETWORK"
+  # Give tor time to exit gracefully
+  sleep 3
   "$WARNINGS"
   exit "$VERIFY_EXIT_STATUS"
 else

+ 2 - 1
torrc_templates/common.i

@@ -36,7 +36,8 @@ DataDirectory $dir
 RunAsDaemon 1
 ConnLimit $connlimit
 Nickname $nick
-ShutdownWaitLength 0
+# Let tor close connections gracefully before exiting
+ShutdownWaitLength 2
 DisableDebuggerAttachment 0
 
 ControlPort $controlport