commit 3414828: [Test] Add large TCP request test

Vsevolod Stakhov vsevolod at highsecure.ru
Sun Jul 21 08:56:04 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-07-21 09:19:04 +0100
URL: https://github.com/rspamd/rspamd/commit/3414828f7041e675007ba307989f64b926cddadb

[Test] Add large TCP request test

---
 test/functional/cases/230_tcp.robot   | 11 ++++++---
 test/functional/configs/lua_test.conf |  1 +
 test/functional/configs/trivial.conf  |  3 ++-
 test/functional/lua/tcp.lua           | 44 +++++++++++++++++++++++++++++++++++
 4 files changed, 55 insertions(+), 4 deletions(-)

diff --git a/test/functional/cases/230_tcp.robot b/test/functional/cases/230_tcp.robot
index cbdbc6640..deb141ebe 100644
--- a/test/functional/cases/230_tcp.robot
+++ b/test/functional/cases/230_tcp.robot
@@ -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
diff --git a/test/functional/configs/lua_test.conf b/test/functional/configs/lua_test.conf
index 67e1e8103..8ea65353f 100644
--- a/test/functional/configs/lua_test.conf
+++ b/test/functional/configs/lua_test.conf
@@ -25,6 +25,7 @@ logging = {
 	type = "file",
 	level = "debug"
 	filename = "${TMPDIR}/rspamd.log"
+	log_usec = true;
 }
 metric = {
 	name = "default",
diff --git a/test/functional/configs/trivial.conf b/test/functional/configs/trivial.conf
index 06aa194e3..c9b8927f2 100644
--- a/test/functional/configs/trivial.conf
+++ b/test/functional/configs/trivial.conf
@@ -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",
diff --git a/test/functional/lua/tcp.lua b/test/functional/lua/tcp.lua
index a95497086..925a18913 100644
--- a/test/functional/lua/tcp.lua
+++ b/test/functional/lua/tcp.lua
@@ -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,


More information about the Commits mailing list