diff options
author | Andrew Lewis <nerf@judo.za.org> | 2017-06-01 16:30:20 +0200 |
---|---|---|
committer | Andrew Lewis <nerf@judo.za.org> | 2017-06-01 16:36:51 +0200 |
commit | c07a20097f247302aa5a44c82b40006990141265 (patch) | |
tree | 1259b3704cea784e51f9d98674dbe61201167f9b /test/functional/lib | |
parent | 9d72040612f37dbabad845459eb61fd75eaae233 (diff) | |
download | rspamd-c07a20097f247302aa5a44c82b40006990141265.tar.gz rspamd-c07a20097f247302aa5a44c82b40006990141265.zip |
[Test] Check controller's error buffer
Diffstat (limited to 'test/functional/lib')
-rw-r--r-- | test/functional/lib/rspamd.py | 28 | ||||
-rw-r--r-- | test/functional/lib/rspamd.robot | 7 | ||||
-rw-r--r-- | test/functional/lib/vars.py | 1 |
3 files changed, 36 insertions, 0 deletions
diff --git a/test/functional/lib/rspamd.py b/test/functional/lib/rspamd.py index 1ae6e95a1..fd1907384 100644 --- a/test/functional/lib/rspamd.py +++ b/test/functional/lib/rspamd.py @@ -5,6 +5,7 @@ import os import os.path import psutil import pwd +import re import shutil import signal import socket @@ -24,6 +25,29 @@ try: except: import httplib +ignore_message = [ + re.compile("^cannot load controller stats from .*/stats\\.ucl: No such file or directory$"), + re.compile("^regexp module enabled, but no rules are defined$"), + re.compile("^cannot find dependency on symbol FREEMAIL_FROM$"), + re.compile("^cannot find dependency on symbol FREEMAIL_REPLYTO$"), + re.compile("^cannot register delayed condition for DMARC_POLICY_ALLOW$"), + re.compile("^failed to scan: Socket error detected: Connection refused$"), +] + +def Check_Errors_JSON(j): + d = demjson.decode(j, strict=True) + assert type(d) is list, j + e = [] + for c in d: + filtered = False + for r in ignore_message: + if r.match(c['message']): + filtered = True + break + if not filtered: + e.append(c) + assert len(e) == 0, str(e) + def Check_JSON(j): d = demjson.decode(j, strict=True) assert len(d) > 0 @@ -139,6 +163,10 @@ def spamc(addr, port, filename): r = s.recv(2048) return r.decode('utf-8') +def TCP_Connect(addr, port): + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + s.connect((addr, port)) + def update_dictionary(a, b): a.update(b) return a diff --git a/test/functional/lib/rspamd.robot b/test/functional/lib/rspamd.robot index c8ec561ae..3044b8292 100644 --- a/test/functional/lib/rspamd.robot +++ b/test/functional/lib/rspamd.robot @@ -4,6 +4,11 @@ Library OperatingSystem Library Process *** Keywords *** +Check Controller Errors + @{result} = HTTP GET ${LOCAL_ADDR} ${PORT_CONTROLLER} /errors + Check Errors JSON @{result}[1] + Should Be Equal As Integers @{result}[0] 200 + Check Pidfile [Arguments] ${pidfile} Wait Until Created ${pidfile} @@ -63,6 +68,7 @@ Generic Setup Generic Teardown [Arguments] @{ports} + Run Keyword If '${CONTROLLER_ERRORS}' == 'True' Check Controller Errors Shutdown Process With Children ${RSPAMD_PID} Cleanup Temporary Directory ${TMPDIR} : FOR ${i} IN @{ports} @@ -97,6 +103,7 @@ Run Redis Run Keyword If ${result.rc} != 0 Log ${result.stderr} Should Be Equal As Integers ${result.rc} 0 Wait Until Keyword Succeeds 30 sec 1 sec Check Pidfile ${TMPDIR}/redis.pid + Wait Until Keyword Succeeds 30 sec 1 sec TCP Connect ${REDIS_ADDR} ${REDIS_PORT} ${REDIS_PID} = Get File ${TMPDIR}/redis.pid Run Keyword If '${REDIS_SCOPE}' == 'Test' Set Test Variable ${REDIS_PID} ... ELSE IF '${REDIS_SCOPE}' == 'Suite' Set Suite Variable ${REDIS_PID} diff --git a/test/functional/lib/vars.py b/test/functional/lib/vars.py index d76c3c0c5..f053422d1 100644 --- a/test/functional/lib/vars.py +++ b/test/functional/lib/vars.py @@ -1,5 +1,6 @@ import socket +CONTROLLER_ERRORS = True KEY_PVT1 = 'ekd3x36tfa5gd76t6pa8hqif3ott7n1siuux68exbkk7ukscte9y' KEY_PUB1 = 'm8kneubpcjsb8sbsoj7jy7azj9fdd3xmj63txni86a8ye9ncomny' LOCAL_ADDR = u'127.0.0.1' |