From c07a20097f247302aa5a44c82b40006990141265 Mon Sep 17 00:00:00 2001 From: Andrew Lewis Date: Thu, 1 Jun 2017 16:30:20 +0200 Subject: [PATCH] [Test] Check controller's error buffer --- test/functional/cases/103_password.robot | 1 + .../functional/cases/110_statistics/lib.robot | 4 ++- .../sqlite-broken-stats-dir.robot | 1 + test/functional/cases/120_fuzzy/lib.robot | 6 ++-- .../cases/120_fuzzy/redis-general.robot | 4 ++- test/functional/configs/dkim.conf | 8 ++++++ test/functional/configs/plugins.conf | 7 +++++ test/functional/configs/pluginsplus.conf | 7 +++++ test/functional/configs/trivial.conf | 8 ++++++ test/functional/lib/rspamd.py | 28 +++++++++++++++++++ test/functional/lib/rspamd.robot | 7 +++++ test/functional/lib/vars.py | 1 + 12 files changed, 78 insertions(+), 4 deletions(-) diff --git a/test/functional/cases/103_password.robot b/test/functional/cases/103_password.robot index 8068911f7..2ae6dec8f 100644 --- a/test/functional/cases/103_password.robot +++ b/test/functional/cases/103_password.robot @@ -6,6 +6,7 @@ Variables ${TESTDIR}/lib/vars.py *** Variables *** ${CONFIG} ${TESTDIR}/configs/password.conf +${CONTROLLER_ERRORS} False ${RSPAMD_SCOPE} Test ${PBKDF_PASSWORD} "$1$rhzzahtm8a5homdhh7z4qiiy7j8pzp4u$k5toro136brshjjuy9t39r785td69qodmd39qzygxuyehn9tqauy" ${CATENA_PASSWORD} "$2$xu1581gidj5cyp4yjgo68qbj6jz1j8o3$j9yg4k58jy3fj8suijxx9d7pea6a6obtufq9kfenosyq8erm87ky" diff --git a/test/functional/cases/110_statistics/lib.robot b/test/functional/cases/110_statistics/lib.robot index 915736f40..7aba131d9 100644 --- a/test/functional/cases/110_statistics/lib.robot +++ b/test/functional/cases/110_statistics/lib.robot @@ -43,8 +43,10 @@ Relearn Test Check Rspamc ${result} BAYES_HAM Redis Statistics Setup - Generic Setup + ${tmpdir} = Make Temporary Directory + Set Suite Variable ${TMPDIR} ${tmpdir} Run Redis + Generic Setup TMPDIR=${tmpdir} Redis Statistics Teardown Normal Teardown diff --git a/test/functional/cases/110_statistics/sqlite-broken-stats-dir.robot b/test/functional/cases/110_statistics/sqlite-broken-stats-dir.robot index b6caa4bd1..4d94ac8d8 100644 --- a/test/functional/cases/110_statistics/sqlite-broken-stats-dir.robot +++ b/test/functional/cases/110_statistics/sqlite-broken-stats-dir.robot @@ -5,6 +5,7 @@ Resource ${TESTDIR}/lib/rspamd.robot Resource lib.robot *** Variables *** +${CONTROLLER_ERRORS} False ${STATS_BACKEND} sqlite3 ${STATS_PATH_CACHE} path = "/does/not/exist/bayes-cache.sqlite"; ${STATS_PATH_HAM} path = "/does/not/exist/bayes-ham.sqlite"; diff --git a/test/functional/cases/120_fuzzy/lib.robot b/test/functional/cases/120_fuzzy/lib.robot index 0458b98bf..c71618b22 100644 --- a/test/functional/cases/120_fuzzy/lib.robot +++ b/test/functional/cases/120_fuzzy/lib.robot @@ -91,11 +91,13 @@ Fuzzy Setup Keyed Fuzzy Setup Generic ${algorithm} ${EMPTY} ${check_settings} Fuzzy Setup Generic - [Arguments] ${algorithm} ${worker_settings} ${check_settings} + [Arguments] ${algorithm} ${worker_settings} ${check_settings} &{kwargs} + ${has_TMPDIR} = Evaluate 'TMPDIR' in $kwargs Set Suite Variable ${SETTINGS_FUZZY_WORKER} ${worker_settings} Set Suite Variable ${SETTINGS_FUZZY_CHECK} ${check_settings} Set Suite Variable ${ALGORITHM} ${algorithm} - Generic Setup + Run Keyword If '${has_TMPDIR}' == 'True' Generic Setup TMPDIR=&{kwargs}[TMPDIR] + ... ELSE Generic Setup Fuzzy Setup Plain Fasthash Fuzzy Setup Plain fasthash diff --git a/test/functional/cases/120_fuzzy/redis-general.robot b/test/functional/cases/120_fuzzy/redis-general.robot index e3889abbe..d79ab30e7 100644 --- a/test/functional/cases/120_fuzzy/redis-general.robot +++ b/test/functional/cases/120_fuzzy/redis-general.robot @@ -21,8 +21,10 @@ Fuzzy Overwrite *** Keywords *** Fuzzy Redis General Setup - Fuzzy Setup Generic siphash backend = "redis"; ${EMPTY} + ${tmpdir} = Make Temporary Directory + Set Suite Variable ${TMPDIR} ${tmpdir} Run Redis + Fuzzy Setup Generic siphash backend \= "redis"; ${EMPTY} TMPDIR=${TMPDIR} Fuzzy Redis General Teardown Normal Teardown diff --git a/test/functional/configs/dkim.conf b/test/functional/configs/dkim.conf index b6ccbb0d6..c2ff52275 100644 --- a/test/functional/configs/dkim.conf +++ b/test/functional/configs/dkim.conf @@ -30,6 +30,14 @@ worker { task_timeout = 60s; } +worker { + type = controller + bind_socket = ${LOCAL_ADDR}:${PORT_CONTROLLER} + count = 1 + secure_ip = ["127.0.0.1", "::1"]; + stats_path = "${TMPDIR}/stats.ucl" +} + dkim { sign_condition =< 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' -- 2.39.5