aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAndrew Lewis <nerf@judo.za.org>2024-02-29 12:42:37 +0200
committerAndrew Lewis <nerf@judo.za.org>2024-02-29 12:42:37 +0200
commitf47853130d6dacc227934ec0ee196422a9528ff8 (patch)
tree7f0335321e2c1a32d49ab848c90457ca96d9707a /test
parent642ca8c3a410d0fcd53d756534c22ea4c3b9013e (diff)
downloadrspamd-f47853130d6dacc227934ec0ee196422a9528ff8.tar.gz
rspamd-f47853130d6dacc227934ec0ee196422a9528ff8.zip
[Test] Use Robot-native process management
- Partially unbreak functional tests in Github Actions
Diffstat (limited to 'test')
-rw-r--r--test/functional/cases/001_merged/160_antivirus.robot62
-rw-r--r--test/functional/cases/001_merged/310_udp.robot9
-rw-r--r--test/functional/cases/001_merged/__init__.robot5
-rw-r--r--test/functional/cases/140_proxy.robot10
-rw-r--r--test/functional/cases/151_rspamadm_async.robot2
-rw-r--r--test/functional/configs/composites.conf1
-rw-r--r--test/functional/configs/redis-server.conf2
-rw-r--r--test/functional/lib/rspamd.py7
-rw-r--r--test/functional/lib/rspamd.robot58
9 files changed, 66 insertions, 90 deletions
diff --git a/test/functional/cases/001_merged/160_antivirus.robot b/test/functional/cases/001_merged/160_antivirus.robot
index 0870ba6a8..16eeeb08e 100644
--- a/test/functional/cases/001_merged/160_antivirus.robot
+++ b/test/functional/cases/001_merged/160_antivirus.robot
@@ -1,5 +1,4 @@
*** Settings ***
-Suite Teardown Antivirus Teardown
Library Process
Library ${RSPAMD_TESTDIR}/lib/rspamd.py
Resource ${RSPAMD_TESTDIR}/lib/rspamd.robot
@@ -14,19 +13,19 @@ ${SETTINGS_FPROT} {symbols_enabled = [FPROT_VIRUS, FPROT2_VIRUS_DUPLICATE_DEFA
*** 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}
@@ -41,16 +40,16 @@ CLAMAV CACHE MISS
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
@@ -58,8 +57,7 @@ FPROT HIT - PATTERN
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}
@@ -76,19 +74,19 @@ FPROT CACHE MISS
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}
@@ -103,26 +101,10 @@ AVAST CACHE MISS
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}
@@ -137,15 +119,19 @@ Run Dummy
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}
diff --git a/test/functional/cases/001_merged/310_udp.robot b/test/functional/cases/001_merged/310_udp.robot
index e94ed60e1..70f9b5626 100644
--- a/test/functional/cases/001_merged/310_udp.robot
+++ b/test/functional/cases/001_merged/310_udp.robot
@@ -1,6 +1,6 @@
*** 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
@@ -31,10 +31,11 @@ UDP Setup
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}
diff --git a/test/functional/cases/001_merged/__init__.robot b/test/functional/cases/001_merged/__init__.robot
index 7ac640d73..909d0417a 100644
--- a/test/functional/cases/001_merged/__init__.robot
+++ b/test/functional/cases/001_merged/__init__.robot
@@ -1,6 +1,6 @@
*** 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
@@ -25,4 +25,5 @@ Multi Teardown
Rspamd Teardown
Dummy Http Teardown
Dummy Https Teardown
- Redis Teardown \ No newline at end of file
+ Redis Teardown
+ Try Reap Zombies
diff --git a/test/functional/cases/140_proxy.robot b/test/functional/cases/140_proxy.robot
index d43cfa43c..a2b872f51 100644
--- a/test/functional/cases/140_proxy.robot
+++ b/test/functional/cases/140_proxy.robot
@@ -30,21 +30,21 @@ Proxy Setup
# 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
diff --git a/test/functional/cases/151_rspamadm_async.robot b/test/functional/cases/151_rspamadm_async.robot
index 6aff67a2d..999215978 100644
--- a/test/functional/cases/151_rspamadm_async.robot
+++ b/test/functional/cases/151_rspamadm_async.robot
@@ -9,6 +9,8 @@ Variables ${RSPAMD_TESTDIR}/lib/vars.py
*** 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 ***
diff --git a/test/functional/configs/composites.conf b/test/functional/configs/composites.conf
index 28b645e60..b3a28013a 100644
--- a/test/functional/configs/composites.conf
+++ b/test/functional/configs/composites.conf
@@ -1,5 +1,6 @@
options = {
pidfile = "{= env.TMPDIR =}/rspamd.pid"
+ url_tld = "{= env.TESTDIR =}/../lua/unit/test_tld.dat"
}
logging = {
type = "file",
diff --git a/test/functional/configs/redis-server.conf b/test/functional/configs/redis-server.conf
index 094302575..0659aa8d3 100644
--- a/test/functional/configs/redis-server.conf
+++ b/test/functional/configs/redis-server.conf
@@ -1,5 +1,5 @@
bind ${RSPAMD_REDIS_ADDR}
-daemonize yes
+daemonize no
loglevel debug
logfile ${RSPAMD_TMPDIR}/redis.log
pidfile ${RSPAMD_TMPDIR}/redis.pid
diff --git a/test/functional/lib/rspamd.py b/test/functional/lib/rspamd.py
index 76132ad5a..57f179123 100644
--- a/test/functional/lib/rspamd.py
+++ b/test/functional/lib/rspamd.py
@@ -244,6 +244,13 @@ def TCP_Connect(addr, port):
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())
diff --git a/test/functional/lib/rspamd.robot b/test/functional/lib/rspamd.robot
index 696b5f97d..a5f897365 100644
--- a/test/functional/lib/rspamd.robot
+++ b/test/functional/lib/rspamd.robot
@@ -204,11 +204,12 @@ Redis SET
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}
@@ -216,7 +217,7 @@ Rspamd Setup
# 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
@@ -226,7 +227,8 @@ Rspamd Teardown
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
@@ -242,20 +244,17 @@ Run Redis
${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
@@ -284,7 +283,7 @@ Run Rspamd
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}
@@ -298,24 +297,11 @@ Run Rspamd
... 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
@@ -370,29 +356,21 @@ Sync Fuzzy Storage
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}