commit 8c9043a: [Test] Exclude more speed/fuzz tests to allow unit tests execution under 1 sec

Vsevolod Stakhov vsevolod at rspamd.com
Tue Dec 27 23:07:03 UTC 2022


Author: Vsevolod Stakhov
Date: 2022-12-27 23:05:20 +0000
URL: https://github.com/rspamd/rspamd/commit/8c9043adae0983775a1f1983ec94ef8580b5f1a5 (HEAD -> master)

[Test] Exclude more speed/fuzz tests to allow unit tests execution under 1 sec

---
 test/lua/unit/expressions.lua |  1 -
 test/lua/unit/redis_stat.lua  | 72 -------------------------------------------
 test/lua/unit/smtp_addr.lua   | 30 +++++++++---------
 3 files changed, 16 insertions(+), 87 deletions(-)

diff --git a/test/lua/unit/expressions.lua b/test/lua/unit/expressions.lua
index f4f4d2b58..3d05685b0 100644
--- a/test/lua/unit/expressions.lua
+++ b/test/lua/unit/expressions.lua
@@ -103,7 +103,6 @@ context("Rspamd expressions", function()
           {parse_func, process_func}, pool)
 
       assert_not_nil(expr, "Cannot parse " .. c[1] .. '; error: ' .. (err or 'wut??'))
-      --print(expr)
       res = expr:process(atoms)
       assert_equal(res, c[2], string.format("Processed expr '%s'{%s} returned '%d', expected: '%d'",
           expr:to_string(), c[1], res, c[2]))
diff --git a/test/lua/unit/redis_stat.lua b/test/lua/unit/redis_stat.lua
deleted file mode 100644
index 3071ec023..000000000
--- a/test/lua/unit/redis_stat.lua
+++ /dev/null
@@ -1,72 +0,0 @@
-
-
-context("Redis statistics unit tests", function()
-  local task = require("rspamd_task")
-  local ffi = require("ffi")
-  local rspamd_util = require("rspamd_util")
-  ffi.cdef[[
-  struct rspamd_statfile_config {
-    const char *symbol;
-    const char *label;
-    void *opts;
-    int is_spam;
-    const char *backend;
-    void *data;
-  };
-  unsigned long rspamd_redis_expand_object(const char *pattern,
-    struct rspamd_statfile_config *stcf,
-    struct rspamd_task *task,
-    char **target);
-  struct rspamd_task * rspamd_task_new(struct rspamd_worker *worker, struct rspamd_config *cfg);
-  int rspamd_task_add_recipient (struct rspamd_task *task, const char *rcpt);
-  int rspamd_task_add_sender (struct rspamd_task *task, const char *sender);
-  ]]
---[[
-  test("Substitute redis values", function()
-    local cases = {
-      {"%s%l", "symbollabel"},
-      {"%s%%", "symbol%"},
-      {"%s%u", "symbol"},
-      {"%s%W", "symbolW"},
-      {"%r%l", "test at example.comlabel"},
-      {"%f-from", "test at example.com-from"}
-    }
-    local config = {
-      options = {
-        filters = { 'spf', 'dkim', 'regexp' },
-        url_tld = tld_file,
-        dns = {
-          nameserver = { '8.8.8.8' }
-        },
-      },
-      logging = {
-        type = 'console',
-        level = 'debug'
-      },
-      metric = {
-        name = 'default',
-        actions = {
-          reject = 100500,
-        },
-        unknown_weight = 1
-      }
-    }
-    local cfg = rspamd_util.config_from_ucl(config)
-    assert_not_nil(cfg)
-    local stcf = ffi.new("struct rspamd_statfile_config",
-      {symbol="symbol",label="label"})
-    local t = ffi.C.rspamd_task_new(nil, cfg)
-
-    assert_equal(ffi.C.rspamd_task_add_recipient(t, "Test <test at example.com>"), 1)
-    assert_equal(ffi.C.rspamd_task_add_recipient(t, "Test1 <test1 at example.com>"), 1)
-    assert_equal(ffi.C.rspamd_task_add_sender(t, "Test <test at example.com>"), 1)
-
-    for _,c in ipairs(cases) do
-      local pbuf = ffi.new 'char *[1]'
-      local sz = ffi.C.rspamd_redis_expand_object(c[1], stcf, t, pbuf)
-      local s = ffi.string(pbuf[0])
-      assert_equal(s, c[2])
-    end
-  end)
---]]
-end)
diff --git a/test/lua/unit/smtp_addr.lua b/test/lua/unit/smtp_addr.lua
index cfce20fcc..2cb7755f8 100644
--- a/test/lua/unit/smtp_addr.lua
+++ b/test/lua/unit/smtp_addr.lua
@@ -89,20 +89,22 @@ context("SMTP address check functions", function()
     end)
   end, cases_invalid)
 
-  test("Speed test", function()
-    local case = '<@domain1, at domain2, at domain3:abc%d at example.com>'
-    local niter = 100000
-    local total = 0
+  if os.getenv("RSPAMD_LUA_EXPENSIVE_TESTS") then
+    test("Speed test", function()
+      local case = '<@domain1, at domain2, at domain3:abc%d at example.com>'
+      local niter = 100000
+      local total = 0
 
-    for i = 1,niter do
-      local ncase = string.format(case, i)
-      local t1 = util.get_ticks()
-      local st = ffi.C.rspamd_email_address_from_smtp(ncase, #ncase)
-      local t2 = util.get_ticks()
-      ffi.C.rspamd_email_address_free(st)
-      total = total + t2 - t1
-    end
+      for i = 1,niter do
+        local ncase = string.format(case, i)
+        local t1 = util.get_ticks()
+        local st = ffi.C.rspamd_email_address_from_smtp(ncase, #ncase)
+        local t2 = util.get_ticks()
+        ffi.C.rspamd_email_address_free(st)
+        total = total + t2 - t1
+      end
 
-    print(string.format('Spend %f seconds in processing addrs', total))
-  end)
+      print(string.format('Spend %f seconds in processing addrs', total))
+    end)
+  end
 end)


More information about the Commits mailing list