]> source.dussan.org Git - rspamd.git/commitdiff
[Test] Try harder to kill rspamd + child processes to avoid cascading failures 752/head
authorAndrew Lewis <nerf@judo.za.org>
Mon, 25 Jul 2016 16:06:49 +0000 (17:06 +0100)
committerAndrew Lewis <nerf@judo.za.org>
Mon, 25 Jul 2016 16:44:17 +0000 (17:44 +0100)
circle.yml
test/functional/cases/statistics/lib.robot
test/functional/lib/rspamd.py
test/functional/lib/rspamd.robot

index 596a1469c2404f4ed9640a4babceb4eeacfb8855..7fb9e4a918e6fc4402d74f5842f15300143caaff 100644 (file)
@@ -1,13 +1,8 @@
 dependencies:
     pre:
       - sudo apt-get update -qq
-      - sudo apt-get install -qq cmake libevent-dev libglib2.0-dev libgmime-2.6-dev libluajit-5.1-dev liblua5.1-0-dev libmagic-dev libpcre3-dev libsqlite3-dev libssl-dev make ragel redis-server gcc
+      - sudo apt-get install -qq cmake gcc libevent-dev libglib2.0-dev libgmime-2.6-dev libluajit-5.1-dev liblua5.1-0-dev libmagic-dev libpcre3-dev libsqlite3-dev libssl-dev make python-psutil ragel redis-server
       - sudo pip install robotframework
-#  - echo $TRAVIS_OS_NAME
-#  - if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get update -qq ; fi
-#  - if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -qq cmake libevent-dev libglib2.0-dev libgmime-2.6-dev libluajit-5.1-dev libpcre3-dev libsqlite3-dev libhiredis-dev ; fi
-#  - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update ; fi
-#  - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew install cmake gmime glib luajit pcre hiredis sqlite libevent ; fi
 
 test:
   override:
index 1a6bc80b6661fb8f4de1489069b18702d8405029..5f9e960382944cbe44d675697a7de00209a5d35f 100644 (file)
@@ -48,7 +48,7 @@ Redis Statistics Setup
 
 Redis Statistics Teardown
   Generic Teardown
-  Shutdown Process  ${REDIS_PID}
+  Shutdown Process With Children  ${REDIS_PID}
 
 Statistics Setup
   Generic Setup  STATS_PATH_CACHE  STATS_PATH_HAM  STATS_PATH_SPAM
index ef7c6e29c1716e508c179564a6b22bb5ecc065c9..a90b924bfd86353b52b2481ac3734fc5b2210446 100644 (file)
@@ -1,6 +1,7 @@
 import grp
 import os
 import os.path
+import psutil
 import pwd
 import shutil
 import signal
@@ -23,16 +24,24 @@ def cleanup_temporary_directory(directory):
 def encode_filename(filename):
     return "".join(['%%%0X' % ord(b) for b in filename])
 
+def get_process_children(pid):
+    children = []
+    for p in psutil.process_iter():
+        # ppid could be int or function depending on library version
+        if callable(p.ppid):
+            ppid = p.ppid()
+        else:
+            ppid = p.ppid
+        if ppid == pid:
+            children.append(p.pid)
+    return children
+
 def get_test_directory():
     return os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "../..")
 
 def make_temporary_directory():
     return tempfile.mkdtemp()
 
-def process_should_exist(pid):
-    pid = int(pid)
-    os.kill(pid, 0)
-
 def read_log_from_position(filename, offset):
     offset = long(offset)
     f = open(filename, 'rb')
@@ -83,14 +92,28 @@ def update_dictionary(a, b):
     return a
 
 def shutdown_process(pid):
-    pid = int(pid)
-    process_should_exist(pid)
     i = 0
     while i < 100:
         try:
             os.kill(pid, signal.SIGTERM)
         except OSError as e:
             assert e.errno == 3
-            break
+            return
         i += 1
         time.sleep(0.1)
+    while i < 200:
+        try:
+            os.kill(pid, signal.SIGKILL)
+        except OSError as e:
+            assert e.errno == 3
+            return
+        i += 1
+        time.sleep(0.1)
+    assert False, "Failed to shutdown process %s" % pid
+
+def shutdown_process_with_children(pid):
+    pid = int(pid)
+    children = get_process_children(pid)
+    shutdown_process(pid)
+    for child in children:
+        shutdown_process(child)
index fe5ee83fb0b346e5a51d17242c35b88ed10b8c41..51030c84f15abfa208dc8b5d78ea82ca737ac9c2 100644 (file)
@@ -62,7 +62,7 @@ Generic Setup
   ...  ELSE  Fail  'RSPAMD_SCOPE must be Test or Suite'
 
 Generic Teardown
-  Shutdown Process  ${RSPAMD_PID}
+  Shutdown Process With Children  ${RSPAMD_PID}
   Cleanup Temporary Directory  ${TMPDIR}
 
 Log Logs