aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/configs/stats.conf4
-rw-r--r--test/functional/test_helper.bash12
-rw-r--r--test/functional/tests.bats34
3 files changed, 47 insertions, 3 deletions
diff --git a/test/functional/configs/stats.conf b/test/functional/configs/stats.conf
index b37615caa..20423c16f 100644
--- a/test/functional/configs/stats.conf
+++ b/test/functional/configs/stats.conf
@@ -42,16 +42,20 @@ worker {
classifier {
tokenizer {
name = "osb";
+ hash = ${STATS_HASH}
+ key = ${STATS_KEY}
}
statfile {
symbol = BAYES_SPAM;
path = ${STATSDIR}/rspamd-bats-bayes.spam;
size = 1M;
+ backend = ${STATS_BACKEND}
}
statfile {
symbol = BAYES_HAM;
path = ${STATSDIR}/rspamd-bats-bayes.ham;
size = 1M;
+ backend = ${STATS_BACKEND}
}
cache {
diff --git a/test/functional/test_helper.bash b/test/functional/test_helper.bash
index 5ee2e20ae..2430002c2 100644
--- a/test/functional/test_helper.bash
+++ b/test/functional/test_helper.bash
@@ -5,6 +5,9 @@ function run_rspamd() {
RSPAMD_USER=${RSPAMD_USER:-"nobody"}
RSPAMD_GROUP=${RSPAMD_GROUP:-"nogroup"}
RSPAMD=${RSPAMD:-"$BATS_TEST_DIRNAME/../../src/rspamd"}
+ STATS_BACKEND=${STATS_BACKEND:-"mmap"}
+ STATS_HASH=${STATS_HASH:-"compat"}
+ STATS_KEY=${STATS_KEY:-"osipg87ms5gzsis33fdrhaqn5wocp6qfofzxjbw8k1wh9yb6adty"}
if [ -f ${TMPDIR}/rspamd-bats-${BATS_TEST_NUMBER}.log ] ; then
rm -f ${TMPDIR}/rspamd-bats-${BATS_TEST_NUMBER}.log
@@ -13,7 +16,10 @@ function run_rspamd() {
TMPDIR=${TMPDIR} \
STATSDIR=${STATSDIR} \
LUADIR=${LUADIR} \
- TEST_NUM=${BATS_TEST_NUMBER}
+ TEST_NUM=${BATS_TEST_NUMBER} \
+ STATS_BACKEND=${STATS_BACKEND} \
+ STATS_HASH=${STATS_HASH} \
+ STATS_KEY=${STATS_KEY}
}
@@ -23,6 +29,10 @@ function teardown() {
while [ $? -eq 0 ] ; do
pkill -TERM rspamd || true
pgrep rspamd > /dev/null 2>&1
+ if [ $? -eq 0 ] ; then
+ sleep 0.1
+ fi
+ pgrep rspamd > /dev/null 2>&1
done
) || true
}
diff --git a/test/functional/tests.bats b/test/functional/tests.bats
index 4f2750dcd..9cb945ea5 100644
--- a/test/functional/tests.bats
+++ b/test/functional/tests.bats
@@ -119,6 +119,38 @@ RSPAMC="$BATS_TEST_DIRNAME/../../src/client/rspamc"
clear_stats
}
+@test "Test rspamd re-learn sqlite3 backend" {
+ export RSPAMD_CONFIG="$BATS_TEST_DIRNAME/configs/stats.conf" \
+ STATSDIR=${BATS_TMPDIR} \
+ STATS_BACKEND="sqlite3"
+ clear_stats
+ run_rspamd
+ run ${RSPAMC} -h localhost:56790 \
+ --key y3ms1knmetxf8gdeixkf74b6tbpxqugmxzqksnjodiqei7tksyty \
+ learn_spam \
+ "$BATS_TEST_DIRNAME/messages/spam_message.eml"
+ [ "$status" -eq 0 ]
+
+ echo $output | egrep 'success.*true'
+
+ run ${RSPAMC} -h localhost:56790 \
+ --key y3ms1knmetxf8gdeixkf74b6tbpxqugmxzqksnjodiqei7tksyty \
+ learn_ham \
+ "$BATS_TEST_DIRNAME/messages/spam_message.eml"
+ [ "$status" -eq 0 ]
+
+ echo $output | egrep 'success.*true'
+
+ run ${RSPAMC} -h localhost:56789 \
+ --key y3ms1knmetxf8gdeixkf74b6tbpxqugmxzqksnjodiqei7tksyty \
+ symbols \
+ "$BATS_TEST_DIRNAME/messages/spam_message.eml"
+ [ "$status" -eq 0 ]
+
+ echo $output | grep 'BAYES_HAM'
+ clear_stats
+}
+
@test "Test learn message with bad statfiles" {
export RSPAMD_CONFIG="$BATS_TEST_DIRNAME/configs/stats.conf" \
STATSDIR=/non/existent
@@ -134,7 +166,6 @@ RSPAMC="$BATS_TEST_DIRNAME/../../src/client/rspamc"
}
@test "Test rspamd dependencies" {
- clear_stats
sed -e 's|@@LUA_SCRIPT@@|${CURDIR}/functional/cases/deps.lua|' < \
"$BATS_TEST_DIRNAME/configs/lua_test.conf" > \
"$BATS_TMPDIR/rspamd.conf"
@@ -147,5 +178,4 @@ RSPAMC="$BATS_TEST_DIRNAME/../../src/client/rspamc"
[ "$status" -eq 0 ]
echo $output | grep 'DEP10'
- clear_stats
} \ No newline at end of file