aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAndrew Lewis <nerf@judo.za.org>2017-06-01 16:30:20 +0200
committerAndrew Lewis <nerf@judo.za.org>2017-06-01 16:36:51 +0200
commitc07a20097f247302aa5a44c82b40006990141265 (patch)
tree1259b3704cea784e51f9d98674dbe61201167f9b /test
parent9d72040612f37dbabad845459eb61fd75eaae233 (diff)
downloadrspamd-c07a20097f247302aa5a44c82b40006990141265.tar.gz
rspamd-c07a20097f247302aa5a44c82b40006990141265.zip
[Test] Check controller's error buffer
Diffstat (limited to 'test')
-rw-r--r--test/functional/cases/103_password.robot1
-rw-r--r--test/functional/cases/110_statistics/lib.robot4
-rw-r--r--test/functional/cases/110_statistics/sqlite-broken-stats-dir.robot1
-rw-r--r--test/functional/cases/120_fuzzy/lib.robot6
-rw-r--r--test/functional/cases/120_fuzzy/redis-general.robot4
-rw-r--r--test/functional/configs/dkim.conf8
-rw-r--r--test/functional/configs/plugins.conf7
-rw-r--r--test/functional/configs/pluginsplus.conf7
-rw-r--r--test/functional/configs/trivial.conf8
-rw-r--r--test/functional/lib/rspamd.py28
-rw-r--r--test/functional/lib/rspamd.robot7
-rw-r--r--test/functional/lib/vars.py1
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 =<<EOD
diff --git a/test/functional/configs/plugins.conf b/test/functional/configs/plugins.conf
index a11070cee..eb7971478 100644
--- a/test/functional/configs/plugins.conf
+++ b/test/functional/configs/plugins.conf
@@ -27,6 +27,13 @@ worker {
count = 1
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"
+}
modules {
path = "${TESTDIR}/../../src/plugins/lua/"
}
diff --git a/test/functional/configs/pluginsplus.conf b/test/functional/configs/pluginsplus.conf
index ea86635d3..6422f9f42 100644
--- a/test/functional/configs/pluginsplus.conf
+++ b/test/functional/configs/pluginsplus.conf
@@ -27,6 +27,13 @@ worker {
count = 1
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"
+}
modules {
path = "${TESTDIR}/../../src/plugins/lua/"
}
diff --git a/test/functional/configs/trivial.conf b/test/functional/configs/trivial.conf
index 04f462e1e..81dd8f0c6 100644
--- a/test/functional/configs/trivial.conf
+++ b/test/functional/configs/trivial.conf
@@ -30,3 +30,11 @@ 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"
+}
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'