]> source.dussan.org Git - rspamd.git/commitdiff
[Test] Add large TCP request test
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 21 Jul 2019 08:19:04 +0000 (09:19 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 21 Jul 2019 08:19:04 +0000 (09:19 +0100)
test/functional/cases/230_tcp.robot
test/functional/configs/lua_test.conf
test/functional/configs/trivial.conf
test/functional/lua/tcp.lua

index cbdbc6640be3b2da196e5a00b50805320a807e0a..deb141ebe09c8148609affd86edfa19820daa9fe 100644 (file)
@@ -1,6 +1,6 @@
 *** Settings ***
-Test Setup      Servers Setup
-Test Teardown   Servers Teardown
+Suite Setup      Servers Setup
+Suite Teardown   Servers Teardown
 Library         Process
 Library         ${TESTDIR}/lib/rspamd.py
 Resource        ${TESTDIR}/lib/rspamd.robot
@@ -11,7 +11,7 @@ Variables       ${TESTDIR}/lib/vars.py
 ${URL_TLD}      ${TESTDIR}/../lua/unit/test_tld.dat
 ${CONFIG}       ${TESTDIR}/configs/lua_test.conf
 ${MESSAGE}      ${TESTDIR}/messages/spam_message.eml
-${RSPAMD_SCOPE}  Test
+${RSPAMD_SCOPE}  Suite
 
 *** Test Cases ***
 Simple TCP request
@@ -24,6 +24,11 @@ SSL TCP request
   Check Rspamc  ${result}  TCP_SSL_RESPONSE (0.00)[test]
   Check Rspamc  ${result}  TCP_SSL_RESPONSE_2 (0.00)[test2]
 
+SSL Large TCP request
+  ${result} =  Scan Message With Rspamc  ${MESSAGE}
+  Check Rspamc  ${result}  TCP_SSL_LARGE (0.00)
+  Check Rspamc  ${result}  TCP_SSL_LARGE_2 (0.00)
+
 Sync API TCP request
   ${result} =  Scan Message With Rspamc  ${MESSAGE}
   Check Rspamc  ${result}  HTTP_SYNC_RESPONSE
index 67e1e8103c638a0ae87403c0842ec7ea312daf2b..8ea65353f81e40b1ee6e414e35c6aeea979389a3 100644 (file)
@@ -25,6 +25,7 @@ logging = {
        type = "file",
        level = "debug"
        filename = "${TMPDIR}/rspamd.log"
+       log_usec = true;
 }
 metric = {
        name = "default",
index 06aa194e35be03d6da8dd5c591f5135614dc738c..c9b8927f211b44dfb7ee827ea7593cb5476f6d90 100644 (file)
@@ -13,7 +13,8 @@ logging = {
        log_urls = true;
        type = "file",
        level = "debug"
-       filename = "${TMPDIR}/rspamd.log"
+       filename = "${TMPDIR}/rspamd.log";
+       log_usec = true;
 }
 metric = {
        name = "default",
index a95497086d3d61d233ac53b5808eb619f6ad7b30..925a189136ec59ae5248b43d03b45f9bc63397d7 100644 (file)
@@ -59,6 +59,44 @@ local function http_simple_tcp_ssl_symbol(task)
   })
 end
 
+local function http_large_tcp_ssl_symbol(task)
+  local data = {}
+
+  local function ssl_get_cb(err, rep, conn)
+    logger.errx(task, 'ssl_get_cb: got reply: %s, error: %s, conn: %s', rep, err, conn)
+    task:insert_result('TCP_SSL_LARGE_2', 1.0)
+  end
+  local function ssl_read_post_cb(err, conn)
+    logger.errx(task, 'ssl_large_read_post_cb: write done: error: %s, conn: %s', err, conn)
+    conn:add_read(ssl_get_cb)
+  end
+  local function ssl_read_cb(err, rep, conn)
+    logger.errx(task, 'ssl_large_read_cb: got reply: %s, error: %s, conn: %s', rep, err, conn)
+    conn:add_write(ssl_read_post_cb, data)
+    task:insert_result('TCP_SSL_LARGE', 1.0)
+  end
+
+  if task:get_queue_id() == 'SSL Large TCP request' then
+    logger.errx(task, 'ssl_large_tcp_symbol: begin')
+    for i = 1,10000000 do
+      data[i] = 'test\n'
+    end
+
+    rspamd_tcp:request({
+      task = task,
+      callback = ssl_read_cb,
+      host = '127.0.0.1',
+      data = data,
+      read = true,
+      ssl = true,
+      ssl_noverify = true,
+      port = 14433,
+    })
+  else
+    logger.errx(task, 'ssl_large_tcp_symbol: skip')
+  end
+end
+
 local function http_simple_tcp_symbol(task)
   logger.errx(task, 'connect_sync, before')
 
@@ -211,6 +249,12 @@ rspamd_config:register_symbol({
   callback = http_simple_tcp_ssl_symbol,
   no_squeeze = true
 })
+rspamd_config:register_symbol({
+  name = 'LARGE_TCP_ASYNC_SSL_TEST',
+  score = 1.0,
+  callback = http_large_tcp_ssl_symbol,
+  no_squeeze = true
+})
 rspamd_config:register_symbol({
   name = 'SIMPLE_TCP_TEST',
   score = 1.0,