*** Settings ***
-Suite Teardown Antivirus Teardown
Library Process
Library ${RSPAMD_TESTDIR}/lib/rspamd.py
Resource ${RSPAMD_TESTDIR}/lib/rspamd.robot
*** Test Cases ***
CLAMAV MISS
- Run Dummy Clam ${RSPAMD_PORT_CLAM}
+ ${process} = Run Dummy Clam ${RSPAMD_PORT_CLAM}
Scan File ${MESSAGE}
... Settings=${SETTINGS_CLAM}
Do Not Expect Symbol CLAM_VIRUS
- Shutdown clamav
+ [Teardown] Terminate Process ${process}
CLAMAV HIT
- Run Dummy Clam ${RSPAMD_PORT_CLAM} 1
+ ${process} = Run Dummy Clam ${RSPAMD_PORT_CLAM} 1
Scan File ${MESSAGE2}
... Settings=${SETTINGS_CLAM}
Expect Symbol CLAM_VIRUS
Do Not Expect Symbol CLAMAV_VIRUS_FAIL
- Shutdown clamav
+ [Teardown] Terminate Process ${process}
CLAMAV CACHE HIT
Scan File ${MESSAGE2}
Do Not Expect Symbol CLAMAV_VIRUS_FAIL
FPROT MISS
- Run Dummy Fprot ${RSPAMD_PORT_FPROT}
+ ${process} = Run Dummy Fprot ${RSPAMD_PORT_FPROT}
Scan File ${MESSAGE2}
... Settings=${SETTINGS_FPROT}
Do Not Expect Symbol FPROT_VIRUS
Do Not Expect Symbol FPROT_EICAR
- Shutdown fport
+ [Teardown] Terminate Process ${process}
FPROT HIT - PATTERN
- Run Dummy Fprot ${RSPAMD_PORT_FPROT} 1
- Run Dummy Fprot ${RSPAMD_PORT_FPROT2_DUPLICATE} 1 /tmp/dummy_fprot_dupe.pid
+ ${process1} = Run Dummy Fprot ${RSPAMD_PORT_FPROT} 1
+ ${process2} = Run Dummy Fprot ${RSPAMD_PORT_FPROT2_DUPLICATE} 1 /tmp/dummy_fprot_dupe.pid
Scan File ${MESSAGE}
... Settings=${SETTINGS_FPROT}
Expect Symbol FPROT_EICAR
Expect Symbol FPROT2_VIRUS_DUPLICATE_PATTERN
Do Not Expect Symbol FPROT2_VIRUS_DUPLICATE_DEFAULT
Do Not Expect Symbol FPROT2_VIRUS_DUPLICATE_NOPE
- Shutdown fport
- Shutdown fport duplicate
+ [Teardown] Double FProt Teardown ${process1} ${process2}
FPROT CACHE HIT
Scan File ${MESSAGE}
Do Not Expect Symbol FPROT_VIRUS
AVAST MISS
- Run Dummy Avast ${RSPAMD_PORT_AVAST}
+ ${process} = Run Dummy Avast ${RSPAMD_PORT_AVAST}
Scan File ${MESSAGE}
... Settings=${SETTINGS_AVAST}
Do Not Expect Symbol AVAST_VIRUS
- Shutdown avast
+ [Teardown] Terminate Process ${process}
AVAST HIT
- Run Dummy Avast ${RSPAMD_PORT_AVAST} 1
+ ${process} = Run Dummy Avast ${RSPAMD_PORT_AVAST} 1
Scan File ${MESSAGE2}
... Settings=${SETTINGS_AVAST}
Expect Symbol AVAST_VIRUS
Do Not Expect Symbol AVAST_VIRUS_FAIL
- Shutdown avast
+ [Teardown] Terminate Process ${process}
AVAST CACHE HIT
Scan File ${MESSAGE2}
Do Not Expect Symbol AVAST_VIRUS_FAIL
*** Keywords ***
-Antivirus Teardown
- Shutdown clamav
- Shutdown fport
- Shutdown avast
-
-Shutdown clamav
- ${clamav_pid} = Get File if exists /tmp/dummy_clamav.pid
- Run Keyword if ${clamav_pid} Shutdown Process With Children ${clamav_pid}
-
-Shutdown fport
- ${fport_pid} = Get File if exists /tmp/dummy_fprot.pid
- Run Keyword if ${fport_pid} Shutdown Process With Children ${fport_pid}
-
-Shutdown fport duplicate
- ${fport_pid} = Get File if exists /tmp/dummy_fprot_dupe.pid
- Run Keyword if ${fport_pid} Shutdown Process With Children ${fport_pid}
-
-Shutdown avast
- ${avast_pid} = Get File if exists /tmp/dummy_avast.pid
- Run Keyword if ${avast_pid} Shutdown Process With Children ${avast_pid}
+Double FProt Teardown
+ [Arguments] ${process1} ${process2}
+ Terminate Process ${process1}
+ Terminate Process ${process2}
Run Dummy
[Arguments] @{varargs}
Log To Console ${res.stdout}
Log To Console ${res.stderr}
Fail Dummy server failed to start
+ [Return] ${process}
Run Dummy Clam
[Arguments] ${port} ${found}= ${pid}=/tmp/dummy_clamav.pid
- Run Dummy ${RSPAMD_TESTDIR}/util/dummy_clam.py ${port} ${found} ${pid}
+ ${process} = Run Dummy ${RSPAMD_TESTDIR}/util/dummy_clam.py ${port} ${found} ${pid}
+ [Return] ${process}
Run Dummy Fprot
[Arguments] ${port} ${found}= ${pid}=/tmp/dummy_fprot.pid
- Run Dummy ${RSPAMD_TESTDIR}/util/dummy_fprot.py ${port} ${found} ${pid}
+ ${process} = Run Dummy ${RSPAMD_TESTDIR}/util/dummy_fprot.py ${port} ${found} ${pid}
+ [Return] ${process}
Run Dummy Avast
[Arguments] ${port} ${found}= ${pid}=/tmp/dummy_avast.pid
- Run Dummy ${RSPAMD_TESTDIR}/util/dummy_avast.py ${port} ${found} ${pid}
+ ${process} = Run Dummy ${RSPAMD_TESTDIR}/util/dummy_avast.py ${port} ${found} ${pid}
+ [Return] ${process}
*** Settings ***
-Test Setup UDP Setup
-Test Teardown UDP Teardown
+Suite Setup UDP Setup
+Suite Teardown UDP Teardown
Library Process
Library ${RSPAMD_TESTDIR}/lib/rspamd.py
Resource ${RSPAMD_TESTDIR}/lib/rspamd.robot
Run Dummy UDP
UDP Teardown
- ${udp_pid} = Get File /tmp/dummy_udp.pid
- Shutdown Process With Children ${udp_pid}
+ Terminate Process ${DUMMY_UDP_PROC}
+ Wait For Process ${DUMMY_UDP_PROC}
Run Dummy UDP
[Arguments]
${result} = Start Process ${RSPAMD_TESTDIR}/util/dummy_udp.py 5005
Wait Until Created /tmp/dummy_udp.pid
+ Set Suite Variable ${DUMMY_UDP_PROC} ${result}
*** Settings ***
Suite Setup Multi Setup
-Suite Teardown Rspamd Redis Teardown
+Suite Teardown Multi Teardown
Library ${RSPAMD_TESTDIR}/lib/rspamd.py
Resource ${RSPAMD_TESTDIR}/lib/rspamd.robot
Variables ${RSPAMD_TESTDIR}/lib/vars.py
Rspamd Teardown
Dummy Http Teardown
Dummy Https Teardown
- Redis Teardown
\ No newline at end of file
+ Redis Teardown
+ Try Reap Zombies
# Run slave & copy variables
Set Suite Variable ${CONFIG} ${RSPAMD_TESTDIR}/configs/lua_test.conf
Rspamd Setup
- Set Suite Variable ${SLAVE_PID} ${RSPAMD_PID}
+ Set Suite Variable ${SLAVE_PROCESS} ${RSPAMD_PROCESS}
Set Suite Variable ${SLAVE_TMPDIR} ${RSPAMD_TMPDIR}
# Run proxy & copy variables
Set Suite Variable ${CONFIG} ${RSPAMD_TESTDIR}/configs/proxy.conf
- Rspamd Setup
- Set Suite Variable ${PROXY_PID} ${RSPAMD_PID}
+ Rspamd Setup check_port=${RSPAMD_PORT_PROXY}
+ Set Suite Variable ${PROXY_PROCESS} ${RSPAMD_PROCESS}
Set Suite Variable ${PROXY_TMPDIR} ${RSPAMD_TMPDIR}
Proxy Teardown
# Restore variables & run normal teardown
- Set Suite Variable ${RSPAMD_PID} ${PROXY_PID}
+ Set Suite Variable ${RSPAMD_PROCESS} ${PROXY_PROCESS}
Set Suite Variable ${RSPAMD_TMPDIR} ${PROXY_TMPDIR}
Rspamd Teardown
# Do it again for slave
- Set Suite Variable ${RSPAMD_PID} ${SLAVE_PID}
+ Set Suite Variable ${RSPAMD_PROCESS} ${SLAVE_PROCESS}
Set Suite Variable ${RSPAMD_TMPDIR} ${SLAVE_TMPDIR}
Rspamd Teardown
*** Variables ***
${CONFIG} ${RSPAMD_TESTDIR}/configs/plugins.conf
${REDIS_SCOPE} Test
+# For dummy http
+${RSPAMD_SCOPE} Test
${RSPAMD_URL_TLD} ${RSPAMD_TESTDIR}/../lua/unit/test_tld.dat
*** Test Cases ***
options = {
pidfile = "{= env.TMPDIR =}/rspamd.pid"
+ url_tld = "{= env.TESTDIR =}/../lua/unit/test_tld.dat"
}
logging = {
type = "file",
bind ${RSPAMD_REDIS_ADDR}
-daemonize yes
+daemonize no
loglevel debug
logfile ${RSPAMD_TMPDIR}/redis.log
pidfile ${RSPAMD_TMPDIR}/redis.pid
s.close()
+def try_reap_zombies():
+ try:
+ os.waitpid(-1, os.WNOHANG)
+ except ChildProcessError:
+ pass
+
+
def ping_rspamd(addr, port):
return str(urlopen("http://%s:%s/ping" % (addr, port)).read())
Should Be Equal As Integers ${result.rc} 0
Redis Teardown
- ${redis_pid} = Get Variable Value ${REDIS_PID}
- Shutdown Process With Children ${redis_pid}
+ Terminate Process ${REDIS_PROCESS}
+ Wait For Process ${REDIS_PROCESS}
Cleanup Temporary Directory ${REDIS_TMPDIR}
Rspamd Setup
+ [Arguments] ${check_port}=${RSPAMD_PORT_NORMAL}
# Create and chown temporary directory
${RSPAMD_TMPDIR} = Make Temporary Directory
Set Directory Ownership ${RSPAMD_TMPDIR} ${RSPAMD_USER} ${RSPAMD_GROUP}
# Export ${RSPAMD_TMPDIR} to appropriate scope according to ${RSPAMD_SCOPE}
Export Scoped Variables ${RSPAMD_SCOPE} RSPAMD_TMPDIR=${RSPAMD_TMPDIR}
- Run Rspamd
+ Run Rspamd check_port=${check_port}
Rspamd Redis Setup
Run Redis
IF '${CONTROLLER_ERRORS}' == 'True'
Run Keyword And Warn On Failure Check Controller Errors
END
- Shutdown Process With Children ${RSPAMD_PID}
+ Terminate Process ${RSPAMD_PROCESS}
+ Wait For Process ${RSPAMD_PROCESS}
Save Run Results ${RSPAMD_TMPDIR} configdump.stdout configdump.stderr rspamd.stderr rspamd.stdout rspamd.conf rspamd.log redis.log clickhouse-config.xml
Log does not contain segfault record
Collect Lua Coverage
${config} = Replace Variables ${template}
Create File ${RSPAMD_TMPDIR}/redis-server.conf ${config}
Log ${config}
- ${result} = Run Process redis-server ${RSPAMD_TMPDIR}/redis-server.conf
- IF ${result.rc} != 0
- Log ${result.stderr}
- END
- Should Be Equal As Integers ${result.rc} 0
+ ${result} = Start Process redis-server ${RSPAMD_TMPDIR}/redis-server.conf
Wait Until Keyword Succeeds 5x 1 sec Check Pidfile ${RSPAMD_TMPDIR}/redis.pid timeout=0.5s
Wait Until Keyword Succeeds 5x 1 sec Redis Check ${RSPAMD_REDIS_ADDR} ${RSPAMD_REDIS_PORT}
${REDIS_PID} = Get File ${RSPAMD_TMPDIR}/redis.pid
${REDIS_PID} = Convert To Number ${REDIS_PID}
- Export Scoped Variables ${REDIS_SCOPE} REDIS_PID=${REDIS_PID} REDIS_TMPDIR=${RSPAMD_TMPDIR}
+ Export Scoped Variables ${REDIS_SCOPE} REDIS_PID=${REDIS_PID} REDIS_PROCESS=${result} REDIS_TMPDIR=${RSPAMD_TMPDIR}
${redis_log} = Get File ${RSPAMD_TMPDIR}/redis.log
Log ${redis_log}
Run Rspamd
+ [Arguments] ${check_port}=${RSPAMD_PORT_NORMAL}
Export Rspamd Variables To Environment
# Dump templated config or errors to log
Set Directory Ownership ${RSPAMD_TMPDIR} ${RSPAMD_USER} ${RSPAMD_GROUP}
# Run Rspamd
- ${result} = Run Process ${RSPAMD} -u ${RSPAMD_USER} -g ${RSPAMD_GROUP}
+ ${result} = Start Process ${RSPAMD} -f -u ${RSPAMD_USER} -g ${RSPAMD_GROUP}
... -c ${CONFIG}
... --var\=TMPDIR\=${RSPAMD_TMPDIR}
... --var\=DBDIR\=${RSPAMD_TMPDIR}
... env:ASAN_OPTIONS=quarantine_size_mb=2048:malloc_context_size=20:fast_unwind_on_malloc=0:log_path=${RSPAMD_TMPDIR}/rspamd-asan
... stdout=${RSPAMD_TMPDIR}/rspamd.stdout stderr=${RSPAMD_TMPDIR}/rspamd.stderr
- # Log stdout/stderr
- ${rspamd_stdout} = Get File ${RSPAMD_TMPDIR}/rspamd.stdout encoding_errors=ignore
- ${rspamd_stderror} = Get File ${RSPAMD_TMPDIR}/rspamd.stderr encoding_errors=ignore
- Log ${rspamd_stdout}
- Log ${rspamd_stderror}
-
- # Abort if it failed
- Should Be Equal As Integers ${result.rc} 0
-
- # Wait for pid file to be written
- Wait Until Keyword Succeeds 10x 1 sec Check Pidfile ${RSPAMD_TMPDIR}/rspamd.pid timeout=0.5s
+ Export Scoped Variables ${RSPAMD_SCOPE} RSPAMD_PROCESS=${result}
# Confirm worker is reachable
- Wait Until Keyword Succeeds 5x 1 sec Ping Rspamd ${RSPAMD_LOCAL_ADDR} ${RSPAMD_PORT_NORMAL}
+ Wait Until Keyword Succeeds 15x 1 sec Ping Rspamd ${RSPAMD_LOCAL_ADDR} ${check_port}
- # Read PID from PIDfile and export it to appropriate scope as ${RSPAMD_PID}
- ${RSPAMD_PID} = Get File ${RSPAMD_TMPDIR}/rspamd.pid
- Export Scoped Variables ${RSPAMD_SCOPE} RSPAMD_PID=${RSPAMD_PID}
Run Nginx
${template} = Get File ${RSPAMD_TESTDIR}/configs/nginx.conf
Sleep 0.1s Try give fuzzy storage time to sync
Run Dummy Http
- ${fileExists} = File Exists /tmp/dummy_http.pid
- IF ${fileExists} is True
- ${http_pid} = Get File /tmp/dummy_http.pid
- Shutdown Process With Children ${http_pid}
- END
${result} = Start Process ${RSPAMD_TESTDIR}/util/dummy_http.py -pf /tmp/dummy_http.pid
Wait Until Created /tmp/dummy_http.pid timeout=2 second
+ Export Scoped Variables ${RSPAMD_SCOPE} DUMMY_HTTP_PROC=${result}
Run Dummy Https
- ${fileExists} = File Exists /tmp/dummy_https.pid
- IF ${fileExists} is True
- ${http_pid} = Get File /tmp/dummy_https.pid
- Shutdown Process With Children ${http_pid}
- END
${result} = Start Process ${RSPAMD_TESTDIR}/util/dummy_http.py
... -c ${RSPAMD_TESTDIR}/util/server.pem -k ${RSPAMD_TESTDIR}/util/server.pem
... -pf /tmp/dummy_https.pid -p 18081
Wait Until Created /tmp/dummy_https.pid timeout=2 second
+ Export Scoped Variables ${RSPAMD_SCOPE} DUMMY_HTTPS_PROC=${result}
Dummy Http Teardown
- ${http_pid} = Get File /tmp/dummy_http.pid
- Shutdown Process With Children ${http_pid}
+ Terminate Process ${DUMMY_HTTP_PROC}
+ Wait For Process ${DUMMY_HTTP_PROC}
Dummy Https Teardown
- ${https_pid} = Get File /tmp/dummy_https.pid
- Shutdown Process With Children ${https_pid}
+ Terminate Process ${DUMMY_HTTPS_PROC}
+ Wait For Process ${DUMMY_HTTPS_PROC}