diff options
Diffstat (limited to 'test/functional/lib/rspamd.robot')
-rw-r--r-- | test/functional/lib/rspamd.robot | 80 |
1 files changed, 51 insertions, 29 deletions
diff --git a/test/functional/lib/rspamd.robot b/test/functional/lib/rspamd.robot index b6180d40d..ded537e03 100644 --- a/test/functional/lib/rspamd.robot +++ b/test/functional/lib/rspamd.robot @@ -1,7 +1,7 @@ *** Settings *** -Library Collections -Library OperatingSystem -Library Process +Library Collections +Library OperatingSystem +Library Process *** Keywords *** Check Rspamc @@ -32,42 +32,64 @@ Follow Rspamd Log ... ELSE Fail 'RSPAMD_SCOPE must be Test or Suite' Generic Setup - ${TMPDIR} ${RSPAMD_PID} ${RSPAMD_LOGPOS} = Run Rspamd + [Arguments] @{vargs} + ${TMPDIR} ${RSPAMD_PID} ${RSPAMD_LOGPOS} = Run Rspamd @{vargs} Run Keyword If '${RSPAMD_SCOPE}' == 'Test' Export Rspamd Vars To Test ${TMPDIR} ${RSPAMD_LOGPOS} ${RSPAMD_PID} ... ELSE IF '${RSPAMD_SCOPE}' == 'Suite' Export Rspamd Vars To Suite ${TMPDIR} ${RSPAMD_LOGPOS} ${RSPAMD_PID} ... ELSE Fail 'RSPAMD_SCOPE must be Test or Suite' Generic Teardown - Shutdown Rspamd ${RSPAMD_PID} - Cleanup Temporary Directory ${TMPDIR} + Shutdown Process ${RSPAMD_PID} + Cleanup Temporary Directory ${TMPDIR} Log Logs - [Arguments] ${logfile} ${position} - ${the_log} ${position} = Read Log From Position ${logfile} ${position} - Log ${the_log} - [Return] ${position} + [Arguments] ${logfile} ${position} + ${the_log} ${position} = Read Log From Position ${logfile} ${position} + Log ${the_log} + [Return] ${position} + +Run Redis + ${template} = Get File ${TESTDIR}/configs/redis-server.conf + ${config} = Replace Variables ${template} + Create File ${TMPDIR}/redis-server.conf ${config} + ${result} = Run Process redis-server ${TMPDIR}/redis-server.conf + Should Be Equal As Integers ${result.rc} 0 + ${REDIS_PID} = Get File ${TMPDIR}/redis.pid + Run Keyword If '${REDIS_SCOPE}' == 'Test' Set Test Variable ${REDIS_PID} + ... ELSE IF '${REDIS_SCOPE}' == 'Suite' Set Suite Variable ${REDIS_PID} Run Rspamc - [Arguments] @{args} - ${result} = Run Process ${RSPAMC} @{args} - [Return] ${result} + [Arguments] @{args} + ${result} = Run Process ${RSPAMC} @{args} + [Return] ${result} Run Rspamd - [Arguments] @{args} &{kw} - ${tmpdir} = Make Temporary Directory - Set Directory Ownership ${tmpdir} ${RSPAMD_USER} ${RSPAMD_GROUP} - Set To Dictionary ${RSPAMD_KEYWORDS} TMPDIR=${tmpdir} - Update Dictionary ${RSPAMD_KEYWORDS} ${kw} - :FOR ${i} IN @{args} - \ Set To Dictionary ${RSPAMD_KEYWORDS} ${i} ${tmpdir} - Populate Rspamd Config ${CONFIG} ${tmpdir} &{RSPAMD_KEYWORDS} - ${result} = Run Process ${RSPAMD} -u ${RSPAMD_USER} -g ${RSPAMD_GROUP} -c ${tmpdir}/rspamd.conf - ${rspamd_logpos} = Log Logs ${tmpdir}/rspamd.log 0 - Should Be Equal As Integers ${result.rc} 0 - ${rspamd_pid} = Get File ${tmpdir}/rspamd.pid - [Return] ${tmpdir} ${rspamd_pid} ${rspamd_logpos} + [Arguments] @{vargs} + ${TMPDIR} = Make Temporary Directory + Set Directory Ownership ${TMPDIR} ${RSPAMD_USER} ${RSPAMD_GROUP} + ${template} = Get File ${CONFIG} + : FOR ${i} IN @{vargs} + \ ${newvalue} = Replace Variables ${${i}} + \ Set Suite Variable ${${i}} ${newvalue} + \ Run Keyword If '${RSPAMD_SCOPE}' == 'Test' Set Test Variable ${${i}} ${newvalue} + \ ... ELSE IF '${RSPAMD_SCOPE}' == 'Suite' Set Suite Variable ${${i}} ${newvalue} + \ ... ELSE Fail 'RSPAMD_SCOPE must be Test or Suite' + ${config} = Replace Variables ${template} + Log ${config} + Create File ${TMPDIR}/rspamd.conf ${config} + ${result} = Run Process ${RSPAMD} -u ${RSPAMD_USER} -g ${RSPAMD_GROUP} + ... -c ${TMPDIR}/rspamd.conf + ${rspamd_logpos} = Log Logs ${TMPDIR}/rspamd.log 0 + Should Be Equal As Integers ${result.rc} 0 + ${rspamd_pid} = Get File ${TMPDIR}/rspamd.pid + [Return] ${TMPDIR} ${rspamd_pid} ${rspamd_logpos} Scan Message With Rspamc - [Arguments] ${msg_file} - ${result} = Run Rspamc -p -h ${LOCAL_ADDR}:${PORT_NORMAL} ${msg_file} - [Return] ${result} + [Arguments] ${msg_file} + ${result} = Run Rspamc -p -h ${LOCAL_ADDR}:${PORT_NORMAL} ${msg_file} + [Return] ${result} + +Sync Fuzzy Storage + ${result} = Run Process ${RSPAMADM} control -s ${TMPDIR}/rspamd.sock fuzzy_sync + Log ${result.stdout} + Follow Rspamd Log |