[Arguments] ${message} | [Arguments] ${message} | ||||
Run Keyword If ${RSPAMD_FUZZY_ADD_${message}} != 1 Fail "Fuzzy Add was not run" | Run Keyword If ${RSPAMD_FUZZY_ADD_${message}} != 1 Fail "Fuzzy Add was not run" | ||||
@{path_info} = Path Splitter ${message} | @{path_info} = Path Splitter ${message} | ||||
@{fuzzy_files} = List Files In Directory @{pathinfo}[0] pattern=@{pathinfo}[1].fuzzy* absolute=1 | |||||
@{fuzzy_files} = List Files In Directory ${pathinfo}[0] pattern=${pathinfo}[1].fuzzy* absolute=1 | |||||
FOR ${i} IN @{fuzzy_files} | FOR ${i} IN @{fuzzy_files} | ||||
${result} = Scan Message With Rspamc ${i} | ${result} = Scan Message With Rspamc ${i} | ||||
Check Rspamc ${result} ${FLAG1_SYMBOL} | Check Rspamc ${result} ${FLAG1_SYMBOL} |
*** Keywords *** | *** Keywords *** | ||||
Stat Test | Stat Test | ||||
@{result} = HTTP GET ${LOCAL_ADDR} ${PORT_CONTROLLER} /stat | @{result} = HTTP GET ${LOCAL_ADDR} ${PORT_CONTROLLER} /stat | ||||
Check JSON @{result}[1] | |||||
Should Be Equal As Integers @{result}[0] 200 | |||||
Check JSON ${result}[1] | |||||
Should Be Equal As Integers ${result}[0] 200 | |||||
History Test | History Test | ||||
[Arguments] ${rspamc_expected_result} | [Arguments] ${rspamc_expected_result} | ||||
${result} = Scan Message With Rspamc ${MESSAGE} | ${result} = Scan Message With Rspamc ${MESSAGE} | ||||
Check Rspamc ${result} ${rspamc_expected_result} | Check Rspamc ${result} ${rspamc_expected_result} | ||||
@{result} = HTTP GET ${LOCAL_ADDR} ${PORT_CONTROLLER} /history | @{result} = HTTP GET ${LOCAL_ADDR} ${PORT_CONTROLLER} /history | ||||
Check JSON @{result}[1] | |||||
Should Be Equal As Integers @{result}[0] 200 | |||||
Check JSON ${result}[1] | |||||
Should Be Equal As Integers ${result}[0] 200 | |||||
Scan Test | Scan Test | ||||
${content} = Get File ${MESSAGE} | ${content} = Get File ${MESSAGE} | ||||
@{result} = HTTP POST ${LOCAL_ADDR} ${PORT_NORMAL} /check ${content} | @{result} = HTTP POST ${LOCAL_ADDR} ${PORT_NORMAL} /check ${content} | ||||
Check JSON @{result}[1] | |||||
Should Be Equal As Integers @{result}[0] 200 | |||||
Check JSON ${result}[1] | |||||
Should Be Equal As Integers ${result}[0] 200 |
*** Keywords *** | *** Keywords *** | ||||
Proxy Setup | Proxy Setup | ||||
&{d} = Run Rspamd CONFIG=${TESTDIR}/configs/lua_test.conf | &{d} = Run Rspamd CONFIG=${TESTDIR}/configs/lua_test.conf | ||||
Set Suite Variable ${SLAVE_LOGPOS} &{d}[RSPAMD_LOGPOS] | |||||
Set Suite Variable ${SLAVE_PID} &{d}[RSPAMD_PID] | |||||
Set Suite Variable ${SLAVE_TMPDIR} &{d}[TMPDIR] | |||||
Set Suite Variable ${SLAVE_LOGPOS} ${d}[RSPAMD_LOGPOS] | |||||
Set Suite Variable ${SLAVE_PID} ${d}[RSPAMD_PID] | |||||
Set Suite Variable ${SLAVE_TMPDIR} ${d}[TMPDIR] | |||||
&{d} = Run Rspamd CONFIG=${TESTDIR}/configs/proxy.conf | &{d} = Run Rspamd CONFIG=${TESTDIR}/configs/proxy.conf | ||||
Set Suite Variable ${PROXY_LOGPOS} &{d}[RSPAMD_LOGPOS] | |||||
Set Suite Variable ${PROXY_PID} &{d}[RSPAMD_PID] | |||||
Set Suite Variable ${PROXY_TMPDIR} &{d}[TMPDIR] | |||||
Set Suite Variable ${PROXY_LOGPOS} ${d}[RSPAMD_LOGPOS] | |||||
Set Suite Variable ${PROXY_PID} ${d}[RSPAMD_PID] | |||||
Set Suite Variable ${PROXY_TMPDIR} ${d}[TMPDIR] | |||||
Proxy Teardown | Proxy Teardown | ||||
Shutdown Process With Children ${PROXY_PID} | Shutdown Process With Children ${PROXY_PID} |
&{d} = Run Rspamd CONFIG=${TESTDIR}/configs/clickhouse.conf TMPDIR=${TMPDIR} | &{d} = Run Rspamd CONFIG=${TESTDIR}/configs/clickhouse.conf TMPDIR=${TMPDIR} | ||||
${keys} = Get Dictionary Keys ${d} | ${keys} = Get Dictionary Keys ${d} | ||||
FOR ${i} IN @{keys} | FOR ${i} IN @{keys} | ||||
Run Keyword If '${RSPAMD_SCOPE}' == 'Suite' Set Suite Variable ${${i}} &{d}[${i}] | |||||
... ELSE IF '${RSPAMD_SCOPE}' == 'Test' Set Test Variable ${${i}} &{d}[${i}] | |||||
Run Keyword If '${RSPAMD_SCOPE}' == 'Suite' Set Suite Variable ${${i}} ${d}[${i}] | |||||
... ELSE IF '${RSPAMD_SCOPE}' == 'Test' Set Test Variable ${${i}} ${d}[${i}] | |||||
... ELSE Fail 'RSPAMD_SCOPE must be Test or Suite' | ... ELSE Fail 'RSPAMD_SCOPE must be Test or Suite' | ||||
END | END |
*** Keywords *** | *** Keywords *** | ||||
Check Controller Errors | Check Controller Errors | ||||
@{result} = HTTP GET ${LOCAL_ADDR} ${PORT_CONTROLLER} /errors | @{result} = HTTP GET ${LOCAL_ADDR} ${PORT_CONTROLLER} /errors | ||||
Should Be Equal As Integers @{result}[0] 200 | |||||
Log @{result}[1] | |||||
Should Be Equal As Integers ${result}[0] 200 | |||||
Log ${result}[1] | |||||
Check Pidfile | Check Pidfile | ||||
[Arguments] ${pidfile} ${timeout}=1 min | [Arguments] ${pidfile} ${timeout}=1 min | ||||
${has_rc} = Evaluate 'rc' in $kwargs | ${has_rc} = Evaluate 'rc' in $kwargs | ||||
${inverse} = Evaluate 'inverse' in $kwargs | ${inverse} = Evaluate 'inverse' in $kwargs | ||||
${re} = Evaluate 're' in $kwargs | ${re} = Evaluate 're' in $kwargs | ||||
${rc} = Set Variable If ${has_rc} == True &{kwargs}[rc] 0 | |||||
${rc} = Set Variable If ${has_rc} == True ${kwargs}[rc] 0 | |||||
FOR ${i} IN @{args} | FOR ${i} IN @{args} | ||||
Run Keyword If ${re} == True Check Rspamc Match Regexp ${result.stdout} ${i} ${inverse} | Run Keyword If ${re} == True Check Rspamc Match Regexp ${result.stdout} ${i} ${inverse} | ||||
... ELSE Check Rspamc Match String ${result.stdout} ${i} ${inverse} | ... ELSE Check Rspamc Match String ${result.stdout} ${i} ${inverse} | ||||
&{d} = Run Rspamd @{vargs} &{kwargs} | &{d} = Run Rspamd @{vargs} &{kwargs} | ||||
${keys} = Get Dictionary Keys ${d} | ${keys} = Get Dictionary Keys ${d} | ||||
FOR ${i} IN @{keys} | FOR ${i} IN @{keys} | ||||
Run Keyword If '${RSPAMD_SCOPE}' == 'Suite' Set Suite Variable ${${i}} &{d}[${i}] | |||||
... ELSE IF '${RSPAMD_SCOPE}' == 'Test' Set Test Variable ${${i}} &{d}[${i}] | |||||
Run Keyword If '${RSPAMD_SCOPE}' == 'Suite' Set Suite Variable ${${i}} ${d}[${i}] | |||||
... ELSE IF '${RSPAMD_SCOPE}' == 'Test' Set Test Variable ${${i}} ${d}[${i}] | |||||
... ELSE Fail 'RSPAMD_SCOPE must be Test or Suite' | ... ELSE Fail 'RSPAMD_SCOPE must be Test or Suite' | ||||
END | END | ||||
[Arguments] @{vargs} &{kwargs} | [Arguments] @{vargs} &{kwargs} | ||||
${has_CONFIG} = Evaluate 'CONFIG' in $kwargs | ${has_CONFIG} = Evaluate 'CONFIG' in $kwargs | ||||
${has_TMPDIR} = Evaluate 'TMPDIR' in $kwargs | ${has_TMPDIR} = Evaluate 'TMPDIR' in $kwargs | ||||
${CONFIG} = Set Variable If '${has_CONFIG}' == 'True' &{kwargs}[CONFIG] ${CONFIG} | |||||
${CONFIG} = Set Variable If '${has_CONFIG}' == 'True' ${kwargs}[CONFIG] ${CONFIG} | |||||
&{d} = Create Dictionary | &{d} = Create Dictionary | ||||
${tmpdir} = Run Keyword If '${has_TMPDIR}' == 'True' Set Variable &{kwargs}[TMPDIR] | |||||
${tmpdir} = Run Keyword If '${has_TMPDIR}' == 'True' Set Variable ${kwargs}[TMPDIR] | |||||
... ELSE Make Temporary Directory | ... ELSE Make Temporary Directory | ||||
Set Directory Ownership ${tmpdir} ${RSPAMD_USER} ${RSPAMD_GROUP} | Set Directory Ownership ${tmpdir} ${RSPAMD_USER} ${RSPAMD_GROUP} | ||||
${template} = Get File ${CONFIG} | ${template} = Get File ${CONFIG} | ||||
${len} = Get Length ${vargs} | ${len} = Get Length ${vargs} | ||||
${result} = Run Keyword If $len == 0 Run Process ${RSPAMADM} control -s | ${result} = Run Keyword If $len == 0 Run Process ${RSPAMADM} control -s | ||||
... ${TMPDIR}/rspamd.sock fuzzy_sync | ... ${TMPDIR}/rspamd.sock fuzzy_sync | ||||
... ELSE Run Process ${RSPAMADM} control -s @{vargs}[0]/rspamd.sock | |||||
... ELSE Run Process ${RSPAMADM} control -s ${vargs}[0]/rspamd.sock | |||||
... fuzzy_sync | ... fuzzy_sync | ||||
Log ${result.stdout} | Log ${result.stdout} | ||||
Run Keyword If $len == 0 Follow Rspamd Log | 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 | Sleep 0.1s Try give fuzzy storage time to sync |