From d133232f34ca0170c5104b7374bd633bfc0b1051 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 13 Jun 2018 14:37:55 +0100 Subject: [PATCH] [Test] Add nginx setup test --- test/functional/configs/nginx.conf | 21 +++++++++++++++++++++ test/functional/lib/rspamd.robot | 18 +++++++++++++++++- test/functional/lib/vars.py | 2 ++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 test/functional/configs/nginx.conf diff --git a/test/functional/configs/nginx.conf b/test/functional/configs/nginx.conf new file mode 100644 index 000000000..e36d6c246 --- /dev/null +++ b/test/functional/configs/nginx.conf @@ -0,0 +1,21 @@ +events { +} +worker_processes 1; +pid ${TMPDIR}/nginx.pid; +error_log ${TMPDIR}/error.log; +http { + include mime.types; + default_type application/octet-stream; + sendfile on; + + server { + # no need for root privileges + listen ${NGINX_ADDR}:${NGINX_PORT}; + server_name localhost + + location / { + root ${TMPDIR} + autoindex on; + } + } +} diff --git a/test/functional/lib/rspamd.robot b/test/functional/lib/rspamd.robot index 6a36746a3..69409eba6 100644 --- a/test/functional/lib/rspamd.robot +++ b/test/functional/lib/rspamd.robot @@ -108,6 +108,22 @@ Run Redis ${redis_log} = Get File ${TMPDIR}/redis.log Log ${redis_log} +Run Nginx + ${template} = Get File ${TESTDIR}/configs/nginx.conf + ${config} = Replace Variables ${template} + Create File ${TMPDIR}/nginx.conf ${config} + Log ${config} + ${result} = Run Process nginx -c ${TMPDIR}/nginx.conf + Run Keyword If ${result.rc} != 0 Log ${result.stderr} + Should Be Equal As Integers ${result.rc} 0 + Wait Until Keyword Succeeds 30 sec 1 sec Check Pidfile ${TMPDIR}/nginx.pid + Wait Until Keyword Succeeds 30 sec 1 sec TCP Connect ${NGINX_ADDR} ${NGINX_PORT} + ${NGINX_PID} = Get File ${TMPDIR}/nginx.pid + Run Keyword If '${NGINX_SCOPE}' == 'Test' Set Test Variable ${NGINX_PID} + ... ELSE IF '${NGINX_SCOPE}' == 'Suite' Set Suite Variable ${NGINX_PID} + ${nginx_log} = Get File ${TMPDIR}/nginx.log + Log ${nginx_log} + Run Rspamc [Arguments] @{args} ${result} = Run Process ${RSPAMC} -t 60 @{args} env:LD_LIBRARY_PATH=${TESTDIR}/../../contrib/aho-corasick @@ -158,5 +174,5 @@ Sync Fuzzy Storage ... ELSE Run Process ${RSPAMADM} control -s @{vargs}[0]/rspamd.sock fuzzy_sync Log ${result.stdout} Run Keyword If $len == 0 Follow Rspamd Log - ... ELSE Custom Follow Rspamd Log @{vargs}[0]/rspamd.log @{vargs}[1] @{vargs}[2] @{vargs}[3] + ... ELSE Custom Follow Rspamd Log @{vargs}[0]/rspamd.log @{vargs}[1] @{vargs}[2] @{vargs}[3] Sleep 0.1s Try give fuzzy storage time to sync diff --git a/test/functional/lib/vars.py b/test/functional/lib/vars.py index 07ac9889d..e707480a8 100644 --- a/test/functional/lib/vars.py +++ b/test/functional/lib/vars.py @@ -17,6 +17,8 @@ PORT_FPROT = 56797 PORT_FPROT_DUPLICATE = 56798 REDIS_ADDR = u'127.0.0.1' REDIS_PORT = 56379 +NGINX_ADDR = u'127.0.0.1' +NGINX_PORT = 56380 RSPAMD_GROUP = 'nogroup' RSPAMD_USER = 'nobody' SOCK_DGRAM = socket.SOCK_DGRAM -- 2.39.5