]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Test] Add logic to match test id and logs id
authorVsevolod Stakhov <vsevolod@rspamd.com>
Tue, 29 Jul 2025 13:17:00 +0000 (14:17 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Tue, 29 Jul 2025 13:17:00 +0000 (14:17 +0100)
test/functional/cases/110_statistics/300-multiclass-redis.robot
test/functional/cases/110_statistics/multiclass_lib.robot
test/functional/lib/rspamd.robot

index 12ec34d6287b62f1d937b034593d9b345c4c6ecf..aa9e0425d6cc5d5b34248236ce3997ee9f01c123 100644 (file)
@@ -2,6 +2,7 @@
 Documentation   Multiclass Bayes Classification Tests with Redis Backend
 Suite Setup     Rspamd Redis Setup
 Suite Teardown  Rspamd Redis Teardown
+Test Setup      Set Test Hash Documentation
 Resource        multiclass_lib.robot
 
 *** Variables ***
index e8b0b3b64a6e59713e05b1167bc9c6cb969a6b03..9f70e05fb6b7f44f41c3e7db13281a857480c853 100644 (file)
@@ -21,9 +21,9 @@ Learn Multiclass
     # Extract filename from message path for queue-id
     ${path}  ${filename} =  Split Path  ${message}
     IF  "${user}"
-        ${result} =  Run Rspamc  -d  ${user}  --queue-id  ${filename}  -h  ${RSPAMD_LOCAL_ADDR}:${RSPAMD_PORT_CONTROLLER}  learn_class:${class}  ${message}
+        ${result} =  Run Rspamc  -d  ${user}  -h  ${RSPAMD_LOCAL_ADDR}:${RSPAMD_PORT_CONTROLLER}  learn_class:${class}  ${message}
     ELSE
-        ${result} =  Run Rspamc  --queue-id  ${filename}  -h  ${RSPAMD_LOCAL_ADDR}:${RSPAMD_PORT_CONTROLLER}  learn_class:${class}  ${message}
+        ${result} =  Run Rspamc  -h  ${RSPAMD_LOCAL_ADDR}:${RSPAMD_PORT_CONTROLLER}  learn_class:${class}  ${message}
     END
     Check Rspamc  ${result}
 
@@ -33,9 +33,9 @@ Learn Multiclass Legacy
     # Extract filename from message path for queue-id
     ${path}  ${filename} =  Split Path  ${message}
     IF  "${user}"
-        ${result} =  Run Rspamc  -d  ${user}  --queue-id  ${filename}  -h  ${RSPAMD_LOCAL_ADDR}:${RSPAMD_PORT_CONTROLLER}  learn_${class}  ${message}
+        ${result} =  Run Rspamc  -d  ${user}  -h  ${RSPAMD_LOCAL_ADDR}:${RSPAMD_PORT_CONTROLLER}  learn_${class}  ${message}
     ELSE
-        ${result} =  Run Rspamc  --queue-id  ${filename}  -h  ${RSPAMD_LOCAL_ADDR}:${RSPAMD_PORT_CONTROLLER}  learn_${class}  ${message}
+        ${result} =  Run Rspamc  -h  ${RSPAMD_LOCAL_ADDR}:${RSPAMD_PORT_CONTROLLER}  learn_${class}  ${message}
     END
     Check Rspamc  ${result}
 
index 5d23e3cebbf928e47dba6e10226c5e67b52e08a7..f61998f46ec0f15a93ff8030a4d9193457da8341 100644 (file)
@@ -419,10 +419,23 @@ Run Nginx
   ${nginx_log} =  Get File  ${RSPAMD_TMPDIR}/nginx.log
   Log  ${nginx_log}
 
+Set Test Hash Documentation
+  ${log_tag} =  Evaluate  __import__('hashlib').md5('${TEST NAME}'.encode()).hexdigest()[:8]
+  Log    TEST CONTEXT: [${log_tag}] ${TEST NAME}    console=True
+
 Run Rspamc
   [Arguments]  @{args}
-  ${result} =  Run Process  ${RSPAMC}  -t  60  --header  Queue-ID\=${TEST NAME}
-  ...  @{args}  env:LD_LIBRARY_PATH=${RSPAMD_TESTDIR}/../../contrib/aho-corasick
+  ${log_tag} =  Evaluate  __import__('hashlib').md5('${TEST NAME}'.encode()).hexdigest()[:8]
+  # Check if --queue-id is already provided in the arguments
+  ${args_str} =  Evaluate  ' '.join(@{args})
+  ${has_queue_id} =  Evaluate  '--queue-id' in '${args_str}'
+  IF  ${has_queue_id}
+    ${result} =  Run Process  ${RSPAMC}  -t  60  --log-tag  ${log_tag}
+    ...  @{args}  env:LD_LIBRARY_PATH=${RSPAMD_TESTDIR}/../../contrib/aho-corasick
+  ELSE
+    ${result} =  Run Process  ${RSPAMC}  -t  60  --queue-id  ${TEST NAME}  --log-tag  ${log_tag}
+    ...  @{args}  env:LD_LIBRARY_PATH=${RSPAMD_TESTDIR}/../../contrib/aho-corasick
+  END
   Log  ${result.stdout}
   [Return]  ${result}