diff options
author | Mikhail Galanin <mgalanin@mimecast.com> | 2018-09-12 08:57:23 +0100 |
---|---|---|
committer | Mikhail Galanin <mgalanin@mimecast.com> | 2018-09-12 08:57:23 +0100 |
commit | f57f7648494b660636ec233c493570120984cabc (patch) | |
tree | 8e97d6f81298059cfa21f3c563e6044eb8d9962e | |
parent | f0fb847f68543f35257513c6433638f2496ef75b (diff) | |
download | rspamd-f57f7648494b660636ec233c493570120984cabc.tar.gz rspamd-f57f7648494b660636ec233c493570120984cabc.zip |
[Test] Added test for new version of Redis API
-rw-r--r-- | test/functional/cases/240_redis.robot | 1 | ||||
-rw-r--r-- | test/functional/cases/241_redis_is_dead.robot | 2 | ||||
-rw-r--r-- | test/functional/lua/redis.lua | 32 |
3 files changed, 32 insertions, 3 deletions
diff --git a/test/functional/cases/240_redis.robot b/test/functional/cases/240_redis.robot index 70798a96b..cf73f59ad 100644 --- a/test/functional/cases/240_redis.robot +++ b/test/functional/cases/240_redis.robot @@ -22,6 +22,7 @@ Redis client ${result} = Scan Message With Rspamc ${MESSAGE} Check Rspamc ${result} REDIS (0.00)[hello from lua on redis] Check Rspamc ${result} REDIS_ASYNC (0.00)[test value] + Check Rspamc ${result} REDIS_ASYNC201809 (0.00)[test value] *** Keywords *** Lua Setup diff --git a/test/functional/cases/241_redis_is_dead.robot b/test/functional/cases/241_redis_is_dead.robot index e23a24120..0577ef03f 100644 --- a/test/functional/cases/241_redis_is_dead.robot +++ b/test/functional/cases/241_redis_is_dead.robot @@ -22,6 +22,8 @@ ${MESSAGE} ${TESTDIR}/messages/spam_message.eml Dead Redis client ${result} = Scan Message With Rspamc ${MESSAGE} Check Rspamc ${result} REDIS_ERROR_3 (0.00)[Connection refused] + Check Rspamc ${result} REDIS_ASYNC201809_ERROR (0.00)[Connection refused] + Check Rspamc ${result} REDIS_ASYNC_ERROR (0.00)[Connection refused] *** Keywords *** Lua Setup diff --git a/test/functional/lua/redis.lua b/test/functional/lua/redis.lua index 841b20787..a9cf9ed78 100644 --- a/test/functional/lua/redis.lua +++ b/test/functional/lua/redis.lua @@ -34,11 +34,30 @@ local function redis_simple_async_symbol(task) ) end +local function redis_simple_async_api201809(task) + local function redis_cb(err, data) + if err then + task:insert_result('REDIS_ASYNC201809_ERROR', 1.0, err) + else + task:insert_result('REDIS_ASYNC201809', 1.0, data) + end + end + + local attrs = { + task = task, + callback = redis_cb + } + local request = { + 'GET', + 'test_key' + } + redis_lua.request(redis_params, attrs, request) +end + local function redis_symbol(task) - local params = lua_util.deepcopy(redis_params) - params.task = task - local is_ok, connection = redis_lua.redis_connect_sync(params) + local attrs = {task = task} + local is_ok, connection = redis_lua.connect(redis_params, attrs) logger.infox(task, "connect: %1, %2", is_ok, connection) @@ -80,6 +99,13 @@ rspamd_config:register_symbol({ }) rspamd_config:register_symbol({ + name = 'SIMPLE_REDIS_ASYNC201809_TEST', + score = 1.0, + callback = redis_simple_async_api201809, + no_squeeze = true +}) + +rspamd_config:register_symbol({ name = 'REDIS_TEST', score = 1.0, callback = redis_symbol, |