commit 2e022c5: [Test] Improve test stability

Andrew Lewis nerf at judo.za.org
Mon Oct 26 10:14:06 UTC 2020


Author: Andrew Lewis
Date: 2020-10-19 10:04:57 +0200
URL: https://github.com/rspamd/rspamd/commit/2e022c546fe8a36ca717ce1d0082b789c99af8c2 (refs/pull/3524/head)

[Test] Improve test stability
 - Antivirus: better visibility into why test servers mightn't start
 - Antivirus: don't use ephemeral port range
 - Fuzzy skip hash: wait for map reload

---
 test/functional/cases/120_fuzzy/lib.robot |  6 +++---
 test/functional/cases/160_antivirus.robot | 25 +++++++++++++++++--------
 test/functional/lib/vars.py               |  8 ++++----
 3 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/test/functional/cases/120_fuzzy/lib.robot b/test/functional/cases/120_fuzzy/lib.robot
index fab223411..ca6143253 100644
--- a/test/functional/cases/120_fuzzy/lib.robot
+++ b/test/functional/cases/120_fuzzy/lib.robot
@@ -28,10 +28,10 @@ Fuzzy Skip Add Test Base
   Check Rspamc  ${result}
   Sync Fuzzy Storage
   Scan File  ${message}
-  Create File  ${TMPDIR}/test.map
   Expect Symbol  R_TEST_FUZZY_DENIED
-  Append To File  ${TMPDIR}/skip_hash.map.tmp  2d875d4737c59c4822fd01dadeba52a329de3933f766c6f167904c6a426bbfa7ea63a66bf807b25c5ee853baee58bfb18d3b423fcd13cfa7c3d77a840039a1ea
-  Hard Link  ${TMPDIR}/skip_hash.map.tmp  ${TMPDIR}/skip_hash.map
+  Create File  ${TMPDIR}/skip_hash.map.tmp  2d875d4737c59c4822fd01dadeba52a329de3933f766c6f167904c6a426bbfa7ea63a66bf807b25c5ee853baee58bfb18d3b423fcd13cfa7c3d77a840039a1ea
+  Move File  ${TMPDIR}/skip_hash.map.tmp  ${TMPDIR}/skip_hash.map
+  Sleep  1s  Wait for reload
   Scan File  ${message}
   Do Not Expect Symbol  R_TEST_FUZZY_DENIED
 
diff --git a/test/functional/cases/160_antivirus.robot b/test/functional/cases/160_antivirus.robot
index 5752f5355..8ad9d2bce 100644
--- a/test/functional/cases/160_antivirus.robot
+++ b/test/functional/cases/160_antivirus.robot
@@ -124,17 +124,26 @@ Shutdown avast
   ${avast_pid} =  Get File if exists  /tmp/dummy_avast.pid
   Run Keyword if  ${avast_pid}  Shutdown Process With Children  ${avast_pid}
 
+Run Dummy
+  [Arguments]  @{varargs}
+  ${process} =  Start Process  @{varargs}
+  ${pid} =  Get From List  ${varargs}  -1
+  ${pass} =  Run Keyword And Return Status  Wait Until Created  ${pid}
+  Run Keyword If  ${pass}  Return From Keyword
+  Wait For Process  ${process}
+  ${res} =  Get Process Result  ${process}
+  Log To Console  ${res.stdout}
+  Log To Console  ${res.stderr}
+  Fail  Dummy server failed to start
+
 Run Dummy Clam
-  [Arguments]  ${port}  ${found}=
-  ${result} =  Start Process  ${TESTDIR}/util/dummy_clam.py  ${port}  ${found}
-  Wait Until Created  /tmp/dummy_clamav.pid
+  [Arguments]  ${port}  ${found}=  ${pid}=/tmp/dummy_clamav.pid
+  Run Dummy  ${TESTDIR}/util/dummy_clam.py  ${port}  ${found}  ${pid}
 
 Run Dummy Fprot
   [Arguments]  ${port}  ${found}=  ${pid}=/tmp/dummy_fprot.pid
-  Start Process  ${TESTDIR}/util/dummy_fprot.py  ${port}  ${found}  ${pid}
-  Wait Until Created  ${pid}
+  Run Dummy  ${TESTDIR}/util/dummy_fprot.py  ${port}  ${found}  ${pid}
 
 Run Dummy Avast
-  [Arguments]  ${port}  ${found}=
-  ${result} =  Start Process  ${TESTDIR}/util/dummy_avast.py  ${port}  ${found}
-  Wait Until Created  /tmp/dummy_avast.pid
+  [Arguments]  ${port}  ${found}=  ${pid}=/tmp/dummy_avast.pid
+  Run Dummy  ${TESTDIR}/util/dummy_avast.py  ${port}  ${found}  ${pid}
diff --git a/test/functional/lib/vars.py b/test/functional/lib/vars.py
index 3cec9767a..51690e591 100644
--- a/test/functional/lib/vars.py
+++ b/test/functional/lib/vars.py
@@ -12,10 +12,10 @@ PORT_FUZZY_SLAVE = 56792
 PORT_NORMAL = 56789
 PORT_NORMAL_SLAVE = 56794
 PORT_PROXY = 56795
-PORT_CLAM = 56796
-PORT_FPROT = 56797
-PORT_FPROT2_DUPLICATE = 56798
-PORT_AVAST = 56799
+PORT_CLAM = 2100
+PORT_FPROT = 2101
+PORT_FPROT2_DUPLICATE = 2102
+PORT_AVAST = 2103
 P0F_SOCKET = '/tmp/p0f.sock'
 REDIS_ADDR = '127.0.0.1'
 REDIS_PORT = 56379


More information about the Commits mailing list