aboutsummaryrefslogtreecommitdiffstats
path: root/lualib
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-01-04 19:19:43 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-01-04 19:19:43 +0000
commit077d9b3c2f22dd2d4e66971e999dc01ac2fa2b44 (patch)
tree848dc758ca32845d61f7d6b8cba3581159a622db /lualib
parent4402c24ee0f9cb77bea4c8b028734e563ce5eb9a (diff)
downloadrspamd-077d9b3c2f22dd2d4e66971e999dc01ac2fa2b44.tar.gz
rspamd-077d9b3c2f22dd2d4e66971e999dc01ac2fa2b44.zip
[Feature] Add timeout to rspamc when doing corpus test
Diffstat (limited to 'lualib')
-rw-r--r--lualib/rspamadm/corpus_test.lua7
-rw-r--r--lualib/rspamadm/rescore.lua2
-rw-r--r--lualib/rspamadm/rescore_utility.lua4
3 files changed, 7 insertions, 6 deletions
diff --git a/lualib/rspamadm/corpus_test.lua b/lualib/rspamadm/corpus_test.lua
index b29fa5602..fa296a0b4 100644
--- a/lualib/rspamadm/corpus_test.lua
+++ b/lualib/rspamadm/corpus_test.lua
@@ -4,9 +4,10 @@ local lua_util = require "lua_util"
local HAM = "HAM"
local SPAM = "SPAM"
-local function scan_email(n_parellel, path)
+local function scan_email(n_parellel, path, timeout)
- local rspamc_command = string.format("rspamc -j --compact -n %s %s", n_parellel, path)
+ local rspamc_command = string.format("rspamc -j --compact -n %s -t %.3f %s",
+ n_parellel, timeout, path)
local result = assert(io.popen(rspamc_command))
result = result:read("*all")
return result
@@ -93,7 +94,7 @@ return function (_, res)
if ham_directory then
io.write("Scanning ham corpus...\n")
- local ham_results = scan_email(connections, ham_directory)
+ local ham_results = scan_email(connections, ham_directory, res["timeout"])
ham_results = scan_results_to_logs(ham_results, HAM)
no_of_ham = #ham_results
diff --git a/lualib/rspamadm/rescore.lua b/lualib/rspamadm/rescore.lua
index 538122f68..4f6cc5075 100644
--- a/lualib/rspamadm/rescore.lua
+++ b/lualib/rspamadm/rescore.lua
@@ -202,7 +202,7 @@ return function (_, res)
local logs = rescore_utility.get_all_logs(res["logdir"])
local all_symbols = rescore_utility.get_all_symbols(logs)
- local original_symbol_scores = rescore_utility.get_all_symbol_scores()
+ local original_symbol_scores = rescore_utility.get_all_symbol_scores(res["timeout"])
shuffle(logs)
diff --git a/lualib/rspamadm/rescore_utility.lua b/lualib/rspamadm/rescore_utility.lua
index 4c6504e76..2390fc565 100644
--- a/lualib/rspamadm/rescore_utility.lua
+++ b/lualib/rspamadm/rescore_utility.lua
@@ -69,9 +69,9 @@ function utility.get_all_logs(dir_path)
return all_logs
end
-function utility.get_all_symbol_scores()
+function utility.get_all_symbol_scores(timeout)
- local output = assert(io.popen("rspamc counters -j --compact"))
+ local output = assert(io.popen("rspamc counters -j --compact -t " .. tostring(timeout)))
output = output:read("*all")
local parser = ucl.parser()