commit f72bc8f: [Test] Increase resilence of the NN tests

Vsevolod Stakhov vsevolod at highsecure.ru
Mon Aug 24 16:07:08 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-08-24 13:33:26 +0100
URL: https://github.com/rspamd/rspamd/commit/f72bc8f83e9b24b145a84d05ea93b11f4b788a32

[Test] Increase resilence of the NN tests

---
 test/functional/cases/330_neural.robot | 18 +++++++--------
 test/functional/configs/neural.conf    | 42 ++++++++++++++++++++++++++++++++++
 test/functional/lib/rspamd.robot       |  2 +-
 test/functional/lua/neural.lua         | 13 +++++++++--
 4 files changed, 62 insertions(+), 13 deletions(-)

diff --git a/test/functional/cases/330_neural.robot b/test/functional/cases/330_neural.robot
index 89ba19f11..a9a338f95 100644
--- a/test/functional/cases/330_neural.robot
+++ b/test/functional/cases/330_neural.robot
@@ -8,7 +8,7 @@ Variables       ${TESTDIR}/lib/vars.py
 
 *** Variables ***
 ${URL_TLD}      ${TESTDIR}/../lua/unit/test_tld.dat
-${CONFIG}       ${TESTDIR}/configs/plugins.conf
+${CONFIG}       ${TESTDIR}/configs/neural.conf
 ${MESSAGE}      ${TESTDIR}/messages/spam_message.eml
 ${REDIS_SCOPE}  Suite
 ${RSPAMD_SCOPE}  Suite
@@ -18,9 +18,9 @@ Train
   Sleep  2s  Wait for redis mess
   FOR    ${INDEX}    IN RANGE    0    10
     ${result} =  Scan Message With Rspamc  ${MESSAGE}  --header  Settings={symbols_enabled = ["SPAM_SYMBOL"]}
-    Check Rspamc  ${result}  SPAM_SYMBOL (1.00)
+    Check Rspamc  ${result}  SPAM_SYMBOL
     ${result} =  Scan Message With Rspamc  ${MESSAGE}  --header  Settings={symbols_enabled = ["HAM_SYMBOL"]}
-    Check Rspamc  ${result}  HAM_SYMBOL (-1.00)
+    Check Rspamc  ${result}  HAM_SYMBOL
   END
 
 Check Neural HAM
@@ -37,10 +37,10 @@ Check Neural SPAM
 
 Train INVERSE
   FOR    ${INDEX}    IN RANGE    0    10
-    ${result} =  Scan Message With Rspamc  ${MESSAGE}  --header  Settings={symbols_enabled = ["SPAM_SYMBOL"]; SPAM_SYMBOL = -1}
-    Check Rspamc  ${result}  SPAM_SYMBOL (-1.00)
-    ${result} =  Scan Message With Rspamc  ${MESSAGE}  --header  Settings={symbols_enabled = ["HAM_SYMBOL"]; HAM_SYMBOL = 1;}
-    Check Rspamc  ${result}  HAM_SYMBOL (1.00)
+    ${result} =  Scan Message With Rspamc  ${MESSAGE}  --header  Settings={symbols_enabled = ["SPAM_SYMBOL"]; SPAM_SYMBOL = -5;}
+    Check Rspamc  ${result}  SPAM_SYMBOL
+    ${result} =  Scan Message With Rspamc  ${MESSAGE}  --header  Settings={symbols_enabled = ["HAM_SYMBOL"]; HAM_SYMBOL = 5;}
+    Check Rspamc  ${result}  HAM_SYMBOL
   END
 
 Check Neural HAM INVERSE
@@ -59,9 +59,7 @@ Neural Setup
   ${TMPDIR} =    Make Temporary Directory
   Set Suite Variable        ${TMPDIR}
   Run Redis
-  ${PLUGIN_CONFIG} =  Get File  ${TESTDIR}/configs/neural.conf
-  Set Suite Variable  ${PLUGIN_CONFIG}
-  Generic Setup  PLUGIN_CONFIG
+  Generic Setup
 
 Neural Teardown
   Shutdown Process With Children  ${REDIS_PID}
diff --git a/test/functional/configs/neural.conf b/test/functional/configs/neural.conf
index a6abad3e0..0a2ded95e 100644
--- a/test/functional/configs/neural.conf
+++ b/test/functional/configs/neural.conf
@@ -1,3 +1,45 @@
+options = {
+  url_tld = "${URL_TLD}"
+  pidfile = "${TMPDIR}/rspamd.pid"
+  lua_path = "${INSTALLROOT}/share/rspamd/lib/?.lua"
+  filters = [];
+  explicit_modules = ["settings"];
+}
+
+logging = {
+  type = "file",
+  level = "debug"
+  filename = "${TMPDIR}/rspamd.log"
+  log_usec = true;
+}
+metric = {
+  name = "default",
+  actions = {
+    reject = 100500,
+    add_header = 50500,
+  }
+  unknown_weight = 1
+}
+worker {
+  type = normal
+  bind_socket = ${LOCAL_ADDR}:${PORT_NORMAL}
+  count = 1
+  task_timeout = 10s;
+}
+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/"
+}
+
+lua = "${TESTDIR}/lua/test_coverage.lua";
+
 neural {
   rules {
       SHORT {
diff --git a/test/functional/lib/rspamd.robot b/test/functional/lib/rspamd.robot
index cd68b1d86..b6c05db62 100644
--- a/test/functional/lib/rspamd.robot
+++ b/test/functional/lib/rspamd.robot
@@ -57,8 +57,8 @@ Generic Setup
 Generic Teardown
   Run Keyword If  '${CONTROLLER_ERRORS}' == 'True'  Check Controller Errors
   Shutdown Process With Children  ${RSPAMD_PID}
+  Save Run Results  ${TMPDIR}  rspamd.conf rspamd.log redis.log clickhouse-config.xml
   Log does not contain segfault record
-  Save Run Results  ${TMPDIR}  rspamd.log redis.log rspamd.conf clickhouse-config.xml
   Collect Lua Coverage
   Cleanup Temporary Directory  ${TMPDIR}
 
diff --git a/test/functional/lua/neural.lua b/test/functional/lua/neural.lua
index 68d7ca2ae..70857d429 100644
--- a/test/functional/lua/neural.lua
+++ b/test/functional/lua/neural.lua
@@ -1,6 +1,6 @@
 rspamd_config:register_symbol({
   name = 'SPAM_SYMBOL',
-  score = 1.0,
+  score = 5.0,
   callback = function()
     return true, 'Fires always'
   end
@@ -8,7 +8,16 @@ rspamd_config:register_symbol({
 
 rspamd_config:register_symbol({
   name = 'HAM_SYMBOL',
-  score = -1.0,
+  score = -3.0,
+  callback = function()
+    return true, 'Fires always'
+  end
+})
+
+rspamd_config:register_symbol({
+  name = 'NEUTRAL_SYMBOL',
+  score = 1.0,
+  flags = 'explicit_disable',
   callback = function()
     return true, 'Fires always'
   end


More information about the Commits mailing list