| 1 |
*** Settings *** |
| 2 |
Library Collections |
| 3 |
Library OperatingSystem |
| 4 |
Library Process |
| 5 |
|
| 6 |
*** Keywords *** |
| 7 |
Check Controller Errors |
| 8 |
@{result} = HTTP GET ${RSPAMD_LOCAL_ADDR} ${RSPAMD_PORT_CONTROLLER} /errors |
| 9 |
Should Be Equal As Integers ${result}[0] 200 |
| 10 |
Log ${result}[1] |
| 11 |
|
| 12 |
Check Pidfile |
| 13 |
[Arguments] ${pidfile} ${timeout}=1 min |
| 14 |
Wait Until Created ${pidfile} timeout=${timeout} |
| 15 |
${size} = Get File Size ${pidfile} |
| 16 |
Should Not Be Equal As Integers ${size} 0 |
| 17 |
|
| 18 |
Check Rspamc |
| 19 |
[Arguments] ${result} @{args} &{kwargs} |
| 20 |
IF ${result.rc} != 0 |
| 21 |
Log ${result.stderr} |
| 22 |
END |
| 23 |
${has_rc} = Evaluate 'rc' in $kwargs |
| 24 |
${inverse} = Evaluate 'inverse' in $kwargs |
| 25 |
${re} = Evaluate 're' in $kwargs |
| 26 |
${rc} = Set Variable If ${has_rc} == True ${kwargs}[rc] 0 |
| 27 |
FOR ${i} IN @{args} |
| 28 |
IF ${re} == True |
| 29 |
Check Rspamc Match Regexp ${result.stdout} ${i} ${inverse} |
| 30 |
ELSE |
| 31 |
Check Rspamc Match String ${result.stdout} ${i} ${inverse} |
| 32 |
END |
| 33 |
END |
| 34 |
IF @{args} == @{EMPTY} |
| 35 |
Check Rspamc Match Default ${result.stdout} ${inverse} |
| 36 |
END |
| 37 |
Should Be Equal As Integers ${result.rc} ${rc} |
| 38 |
|
| 39 |
Check Rspamc Match Default |
| 40 |
[Arguments] ${subject} ${inverse} |
| 41 |
IF ${inverse} == False |
| 42 |
Should Contain ${subject} success = true |
| 43 |
ELSE |
| 44 |
Should Not Contain ${subject} success = true |
| 45 |
END |
| 46 |
|
| 47 |
Check Rspamc Match Regexp |
| 48 |
[Arguments] ${subject} ${re} ${inverse} |
| 49 |
IF ${inverse} == False |
| 50 |
Should Match Regexp ${subject} ${re} |
| 51 |
ELSE |
| 52 |
Should Not Match Regexp ${subject} ${re} |
| 53 |
END |
| 54 |
|
| 55 |
Check Rspamc Match String |
| 56 |
[Arguments] ${subject} ${str} ${inverse} |
| 57 |
IF ${inverse} == False |
| 58 |
Should Contain ${subject} ${str} |
| 59 |
ELSE |
| 60 |
Should Not Contain ${subject} ${str} |
| 61 |
END |
| 62 |
|
| 63 |
Do Not Expect Added Header |
| 64 |
[Arguments] ${header_name} |
| 65 |
IF 'milter' not in ${SCAN_RESULT} |
| 66 |
RETURN |
| 67 |
END |
| 68 |
IF 'add_headers' not in ${SCAN_RESULT}[milter] |
| 69 |
RETURN |
| 70 |
END |
| 71 |
Dictionary Should Not Contain Key ${SCAN_RESULT}[milter][add_headers] ${header_name} |
| 72 |
... msg=${header_name} was added |
| 73 |
|
| 74 |
Do Not Expect Removed Header |
| 75 |
[Arguments] ${header_name} |
| 76 |
IF 'milter' not in ${SCAN_RESULT} |
| 77 |
RETURN |
| 78 |
END |
| 79 |
IF 'remove_headers' not in ${SCAN_RESULT}[milter] |
| 80 |
RETURN |
| 81 |
END |
| 82 |
Dictionary Should Not Contain Key ${SCAN_RESULT}[milter][remove_headers] ${header_name} |
| 83 |
... msg=${header_name} was removed |
| 84 |
|
| 85 |
Do Not Expect Symbol |
| 86 |
[Arguments] ${symbol} |
| 87 |
Dictionary Should Not Contain Key ${SCAN_RESULT}[symbols] ${symbol} |
| 88 |
... msg=Symbol ${symbol} was not expected to be found in result |
| 89 |
|
| 90 |
Do Not Expect Symbol With Option |
| 91 |
[Arguments] ${symbol} ${option} |
| 92 |
IF '${symbol}' not in ${SCAN_RESULT}[symbols] |
| 93 |
RETURN |
| 94 |
END |
| 95 |
${have_options} = Convert To List ${SCAN_RESULT}[symbols][${symbol}][options] |
| 96 |
Should Not Contain ${have_options} ${option} |
| 97 |
... msg="Options for symbol ${symbol} ${SCAN_RESULT}[symbols][${symbol}][options] doesn't contain ${option}" |
| 98 |
|
| 99 |
Do Not Expect Symbols |
| 100 |
[Arguments] @{symbols} |
| 101 |
FOR ${symbol} IN @{symbols} |
| 102 |
Dictionary Should Not Contain Key ${SCAN_RESULT}[symbols] ${symbol} |
| 103 |
... msg=Symbol ${symbol} was not expected to be found in result |
| 104 |
END |
| 105 |
|
| 106 |
Expect Action |
| 107 |
[Arguments] ${action} |
| 108 |
Should Be Equal ${SCAN_RESULT}[action] ${action} |
| 109 |
|
| 110 |
Expect Added Header |
| 111 |
[Arguments] ${header_name} ${header_value} ${pos}=-1 |
| 112 |
Dictionary Should Contain Key ${SCAN_RESULT} milter |
| 113 |
... msg=milter block was not present in protocol response |
| 114 |
Dictionary Should Contain Key ${SCAN_RESULT}[milter] add_headers |
| 115 |
... msg=add_headers block was not present in protocol response |
| 116 |
Dictionary Should Contain Key ${SCAN_RESULT}[milter][add_headers] ${header_name} |
| 117 |
... msg=${header_name} was not added |
| 118 |
Dictionary Should Contain Key ${SCAN_RESULT}[milter][add_headers][${header_name}] value |
| 119 |
... msg=no value field in ${header_name} index: ${SCAN_RESULT}[milter][add_headers][${header_name}] |
| 120 |
Should Be Equal ${SCAN_RESULT}[milter][add_headers][${header_name}][value] ${header_value} |
| 121 |
Should Be Equal as Numbers ${SCAN_RESULT}[milter][add_headers][${header_name}][order] ${pos} |
| 122 |
|
| 123 |
Expect Header Is Present |
| 124 |
[Arguments] ${header_name} |
| 125 |
Dictionary Should Contain Key ${SCAN_RESULT} milter |
| 126 |
... msg=milter block was not present in protocol response |
| 127 |
Dictionary Should Contain Key ${SCAN_RESULT}[milter] add_headers |
| 128 |
... msg=add_headers block was not present in protocol response |
| 129 |
Dictionary Should Contain Key ${SCAN_RESULT}[milter][add_headers] ${header_name} |
| 130 |
... msg=${header_name} was not added |
| 131 |
|
| 132 |
Expect Email |
| 133 |
[Arguments] ${email} |
| 134 |
List Should Contain Value ${SCAN_RESULT}[emails] ${email} |
| 135 |
|
| 136 |
Expect Removed Header |
| 137 |
[Arguments] ${header_name} ${pos}=0 |
| 138 |
Dictionary Should Contain Key ${SCAN_RESULT} milter |
| 139 |
... msg=milter block was not present in protocol response |
| 140 |
Dictionary Should Contain Key ${SCAN_RESULT}[milter] remove_headers |
| 141 |
... msg=remove_headers block was not present in protocol response |
| 142 |
Dictionary Should Contain Key ${SCAN_RESULT}[milter][remove_headers] ${header_name} |
| 143 |
... msg=${header_name} was not removed |
| 144 |
Should Be Equal as Numbers ${SCAN_RESULT}[milter][remove_headers][${header_name}] ${pos} |
| 145 |
|
| 146 |
Expect Required Score |
| 147 |
[Arguments] ${required_score} |
| 148 |
Should Be Equal As Numbers ${SCAN_RESULT}[required_score] ${required_score} |
| 149 |
|
| 150 |
Expect Required Score To Be Null |
| 151 |
Should Be Equal ${SCAN_RESULT}[required_score] ${NONE} |
| 152 |
|
| 153 |
Expect Score |
| 154 |
[Arguments] ${score} |
| 155 |
Should Be Equal As Numbers ${SCAN_RESULT}[score] ${score} |
| 156 |
... msg="Expected message score of ${score} but got ${SCAN_RESULT}[score]" |
| 157 |
|
| 158 |
Expect Symbol |
| 159 |
[Arguments] ${symbol} |
| 160 |
Dictionary Should Contain Key ${SCAN_RESULT}[symbols] ${symbol} |
| 161 |
... msg=Symbol ${symbol} wasn't found in result |
| 162 |
|
| 163 |
Expect URL |
| 164 |
[Arguments] ${url} |
| 165 |
List Should Contain Value ${SCAN_RESULT}[urls] ${url} |
| 166 |
|
| 167 |
Expect Extended URL |
| 168 |
[Arguments] ${url} |
| 169 |
${found_url} = Set Variable ${FALSE} |
| 170 |
${url_list} = Convert To List ${SCAN_RESULT}[urls] |
| 171 |
FOR ${item} IN @{url_list} |
| 172 |
${d} = Convert To Dictionary ${item} |
| 173 |
${found_url} = Evaluate "${d}[url]" == "${url}" |
| 174 |
Exit For Loop If ${found_url} == ${TRUE} |
| 175 |
END |
| 176 |
Should Be True ${found_url} msg="Expected URL was not found: ${url}" |
| 177 |
|
| 178 |
Expect Symbol With Exact Options |
| 179 |
[Arguments] ${symbol} @{options} |
| 180 |
Expect Symbol ${symbol} |
| 181 |
${have_options} = Convert To List ${SCAN_RESULT}[symbols][${symbol}][options] |
| 182 |
Lists Should Be Equal ${have_options} ${options} ignore_order=True |
| 183 |
... msg="Symbol ${symbol} has options ${SCAN_RESULT}[symbols][${symbol}][options] but expected ${options}" |
| 184 |
|
| 185 |
Expect Symbol With Option |
| 186 |
[Arguments] ${symbol} ${option} |
| 187 |
Expect Symbol ${symbol} |
| 188 |
${have_options} = Convert To List ${SCAN_RESULT}[symbols][${symbol}][options] |
| 189 |
Should Contain ${have_options} ${option} |
| 190 |
... msg="Options for symbol ${symbol} ${SCAN_RESULT}[symbols][${symbol}][options] doesn't contain ${option}" |
| 191 |
|
| 192 |
Expect Symbol With Score |
| 193 |
[Arguments] ${symbol} ${score} |
| 194 |
Dictionary Should Contain Key ${SCAN_RESULT}[symbols] ${symbol} |
| 195 |
... msg=Symbol ${symbol} wasn't found in result |
| 196 |
Should Be Equal As Numbers ${SCAN_RESULT}[symbols][${symbol}][score] ${score} |
| 197 |
... msg="Symbol ${symbol} has score of ${SCAN_RESULT}[symbols][${symbol}][score] but expected ${score}" |
| 198 |
|
| 199 |
Expect Symbols |
| 200 |
[Arguments] @{symbols} |
| 201 |
FOR ${symbol} IN @{symbols} |
| 202 |
Dictionary Should Contain Key ${SCAN_RESULT}[symbols] ${symbol} |
| 203 |
... msg=Symbol ${symbol} wasn't found in result |
| 204 |
END |
| 205 |
|
| 206 |
Expect Symbols With Scores |
| 207 |
[Arguments] &{symscores} |
| 208 |
FOR ${key} ${value} IN &{symscores} |
| 209 |
Dictionary Should Contain Key ${SCAN_RESULT}[symbols] ${key} |
| 210 |
... msg=Symbol ${key} wasn't found in result |
| 211 |
Should Be Equal As Numbers ${SCAN_RESULT}[symbols][${key}][score] ${value} |
| 212 |
... msg="Symbol ${key} has score of ${SCAN_RESULT}[symbols][${key}][score] but expected ${value}" |
| 213 |
END |
| 214 |
|
| 215 |
Expect Symbol With Score And Exact Options |
| 216 |
[Arguments] ${symbol} ${score} @{options} |
| 217 |
Expect Symbol With Exact Options ${symbol} @{options} |
| 218 |
Expect Symbol With Score ${symbol} ${score} |
| 219 |
|
| 220 |
Export Rspamd Variables To Environment |
| 221 |
&{all_vars} = Get Variables no_decoration=True |
| 222 |
FOR ${k} ${v} IN &{all_vars} |
| 223 |
IF '${k}'.startswith("RSPAMD_") |
| 224 |
Set Environment Variable ${k} ${v} |
| 225 |
END |
| 226 |
END |
| 227 |
|
| 228 |
Export Scoped Variables |
| 229 |
[Arguments] ${scope} &{vars} |
| 230 |
IF '${scope}' == 'Test' |
| 231 |
FOR ${k} ${v} IN &{vars} |
| 232 |
Set Test Variable ${${k}} ${v} |
| 233 |
END |
| 234 |
ELSE IF '${scope}' == 'Suite' |
| 235 |
FOR ${k} ${v} IN &{vars} |
| 236 |
Set Suite Variable ${${k}} ${v} |
| 237 |
END |
| 238 |
ELSE IF '${scope}' == 'Global' |
| 239 |
FOR ${k} ${v} IN &{vars} |
| 240 |
Set Global Variable ${${k}} ${v} |
| 241 |
END |
| 242 |
ELSE |
| 243 |
Fail message="Don't know what to do with scope: ${scope}" |
| 244 |
END |
| 245 |
|
| 246 |
Log does not contain segfault record |
| 247 |
${log} = Get File ${RSPAMD_TMPDIR}/rspamd.log encoding_errors=ignore |
| 248 |
Should not contain ${log} (Segmentation fault) msg=Segmentation fault detected |
| 249 |
|
| 250 |
Redis HSET |
| 251 |
[Arguments] ${hash} ${key} ${value} |
| 252 |
${result} = Run Process redis-cli -h ${RSPAMD_REDIS_ADDR} -p ${RSPAMD_REDIS_PORT} |
| 253 |
... HSET ${hash} ${key} ${value} |
| 254 |
IF ${result.rc} != 0 |
| 255 |
Log ${result.stderr} |
| 256 |
END |
| 257 |
Log ${result.stdout} |
| 258 |
Should Be Equal As Integers ${result.rc} 0 |
| 259 |
|
| 260 |
Redis SET |
| 261 |
[Arguments] ${key} ${value} |
| 262 |
${result} = Run Process redis-cli -h ${RSPAMD_REDIS_ADDR} -p ${RSPAMD_REDIS_PORT} |
| 263 |
... SET ${key} ${value} |
| 264 |
IF ${result.rc} != 0 |
| 265 |
Log ${result.stderr} |
| 266 |
END |
| 267 |
Log ${result.stdout} |
| 268 |
Should Be Equal As Integers ${result.rc} 0 |
| 269 |
|
| 270 |
Redis Teardown |
| 271 |
Terminate Process ${REDIS_PROCESS} |
| 272 |
Wait For Process ${REDIS_PROCESS} |
| 273 |
Cleanup Temporary Directory ${REDIS_TMPDIR} |
| 274 |
|
| 275 |
Rspamd Setup |
| 276 |
[Arguments] ${check_port}=${RSPAMD_PORT_NORMAL} |
| 277 |
# Create and chown temporary directory |
| 278 |
${RSPAMD_TMPDIR} = Make Temporary Directory |
| 279 |
Set Directory Ownership ${RSPAMD_TMPDIR} ${RSPAMD_USER} ${RSPAMD_GROUP} |
| 280 |
|
| 281 |
# Export ${RSPAMD_TMPDIR} to appropriate scope according to ${RSPAMD_SCOPE} |
| 282 |
IF '${RSPAMD_SCOPE}' == 'Test' |
| 283 |
Set Test Variable ${RSPAMD_TMPDIR} |
| 284 |
ELSE IF '${RSPAMD_SCOPE}' == 'Suite' |
| 285 |
Set Suite Variable ${RSPAMD_TMPDIR} |
| 286 |
# Needed for child suites (e.g. directory suites with per-file .robot suites) |
| 287 |
Set Global Variable ${RSPAMD_TMPDIR} |
| 288 |
ELSE IF '${RSPAMD_SCOPE}' == 'Global' |
| 289 |
Set Global Variable ${RSPAMD_TMPDIR} |
| 290 |
ELSE |
| 291 |
Fail message="Don't know what to do with scope: ${RSPAMD_SCOPE}" |
| 292 |
END |
| 293 |
|
| 294 |
Run Rspamd check_port=${check_port} |
| 295 |
|
| 296 |
Rspamd Redis Setup |
| 297 |
Run Redis |
| 298 |
Rspamd Setup |
| 299 |
|
| 300 |
Rspamd Teardown |
| 301 |
IF '${CONTROLLER_ERRORS}' == 'True' |
| 302 |
Run Keyword And Warn On Failure Check Controller Errors |
| 303 |
END |
| 304 |
Terminate Process ${RSPAMD_PROCESS} |
| 305 |
Wait For Process ${RSPAMD_PROCESS} |
| 306 |
Save Run Results ${RSPAMD_TMPDIR} configdump.stdout configdump.stderr rspamd.stderr rspamd.stdout rspamd.conf rspamd.log redis.log clickhouse-config.xml |
| 307 |
Log does not contain segfault record |
| 308 |
Collect Lua Coverage |
| 309 |
Cleanup Temporary Directory ${RSPAMD_TMPDIR} |
| 310 |
|
| 311 |
Rspamd Redis Teardown |
| 312 |
Rspamd Teardown |
| 313 |
Redis Teardown |
| 314 |
|
| 315 |
Run Redis |
| 316 |
${RSPAMD_TMPDIR} = Make Temporary Directory |
| 317 |
${template} = Get File ${RSPAMD_TESTDIR}/configs/redis-server.conf |
| 318 |
${config} = Replace Variables ${template} |
| 319 |
Create File ${RSPAMD_TMPDIR}/redis-server.conf ${config} |
| 320 |
Log ${config} |
| 321 |
${result} = Start Process redis-server ${RSPAMD_TMPDIR}/redis-server.conf |
| 322 |
Wait Until Keyword Succeeds 5x 1 sec Check Pidfile ${RSPAMD_TMPDIR}/redis.pid timeout=0.5s |
| 323 |
Wait Until Keyword Succeeds 5x 1 sec Redis Check ${RSPAMD_REDIS_ADDR} ${RSPAMD_REDIS_PORT} |
| 324 |
${REDIS_PID} = Get File ${RSPAMD_TMPDIR}/redis.pid |
| 325 |
${REDIS_PID} = Convert To Number ${REDIS_PID} |
| 326 |
Export Scoped Variables ${REDIS_SCOPE} REDIS_PID=${REDIS_PID} REDIS_PROCESS=${result} REDIS_TMPDIR=${RSPAMD_TMPDIR} |
| 327 |
${redis_log} = Get File ${RSPAMD_TMPDIR}/redis.log |
| 328 |
Log ${redis_log} |
| 329 |
|
| 330 |
Run Rspamd |
| 331 |
[Arguments] ${check_port}=${RSPAMD_PORT_NORMAL} |
| 332 |
Export Rspamd Variables To Environment |
| 333 |
|
| 334 |
# Copy config file to TMPDIR so it gets saved on teardown |
| 335 |
Copy File ${CONFIG} ${RSPAMD_TMPDIR}/rspamd.conf |
| 336 |
|
| 337 |
# Dump templated config or errors to log |
| 338 |
${result} = Run Process ${RSPAMADM} |
| 339 |
... --var\=TMPDIR\=${RSPAMD_TMPDIR} |
| 340 |
... --var\=DBDIR\=${RSPAMD_TMPDIR} |
| 341 |
... --var\=LOCAL_CONFDIR\=/non-existent |
| 342 |
... --var\=CONFDIR\=${RSPAMD_TESTDIR}/../../conf/ |
| 343 |
... configdump -c ${CONFIG} |
| 344 |
... env:RSPAMD_LOCAL_CONFDIR=/non-existent |
| 345 |
... env:RSPAMD_TMPDIR=${RSPAMD_TMPDIR} |
| 346 |
... env:RSPAMD_CONFDIR=${RSPAMD_TESTDIR}/../../conf/ |
| 347 |
... env:LD_LIBRARY_PATH=${RSPAMD_TESTDIR}/../../contrib/aho-corasick |
| 348 |
... env:RSPAMD_NO_CLEANUP=1 |
| 349 |
... env:ASAN_OPTIONS=quarantine_size_mb=2048:malloc_context_size=20:fast_unwind_on_malloc=0:log_path=${RSPAMD_TMPDIR}/rspamd-asan |
| 350 |
# We need to send output to files (or discard output) to avoid hanging Robot |
| 351 |
... stdout=${RSPAMD_TMPDIR}/configdump.stdout stderr=${RSPAMD_TMPDIR}/configdump.stderr |
| 352 |
|
| 353 |
# Always save configdump output to files, even if it failed |
| 354 |
# First save process output directly to ensure we have something even if files weren't created |
| 355 |
${stdout_exists} = Run Keyword And Return Status File Should Exist ${RSPAMD_TMPDIR}/configdump.stdout |
| 356 |
${stderr_exists} = Run Keyword And Return Status File Should Exist ${RSPAMD_TMPDIR}/configdump.stderr |
| 357 |
|
| 358 |
IF not ${stdout_exists} |
| 359 |
# File wasn't created, use process stdout if available |
| 360 |
${stdout_len} = Get Length ${result.stdout} |
| 361 |
IF ${stdout_len} > 0 |
| 362 |
Create File ${RSPAMD_TMPDIR}/configdump.stdout ${result.stdout} |
| 363 |
ELSE |
| 364 |
Create File ${RSPAMD_TMPDIR}/configdump.stdout <configdump stdout not created, process crashed?> |
| 365 |
END |
| 366 |
END |
| 367 |
|
| 368 |
IF not ${stderr_exists} |
| 369 |
# File wasn't created, use process stderr if available |
| 370 |
${stderr_len} = Get Length ${result.stderr} |
| 371 |
IF ${stderr_len} > 0 |
| 372 |
Create File ${RSPAMD_TMPDIR}/configdump.stderr ${result.stderr} |
| 373 |
ELSE |
| 374 |
Create File ${RSPAMD_TMPDIR}/configdump.stderr <configdump stderr not created, process crashed?> |
| 375 |
END |
| 376 |
END |
| 377 |
|
| 378 |
IF ${result.rc} == 0 |
| 379 |
${configdump} = Get File ${RSPAMD_TMPDIR}/configdump.stdout encoding_errors=ignore |
| 380 |
ELSE |
| 381 |
${configdump} = Get File ${RSPAMD_TMPDIR}/configdump.stderr encoding_errors=ignore |
| 382 |
Log Configdump failed with rc=${result.rc} level=WARN |
| 383 |
END |
| 384 |
Log ${configdump} |
| 385 |
|
| 386 |
# Fix directory ownership (maybe do this somewhere else) |
| 387 |
Set Directory Ownership ${RSPAMD_TMPDIR} ${RSPAMD_USER} ${RSPAMD_GROUP} |
| 388 |
|
| 389 |
# Run Rspamd |
| 390 |
${result} = Start Process ${RSPAMD} -f -u ${RSPAMD_USER} -g ${RSPAMD_GROUP} |
| 391 |
... -c ${CONFIG} |
| 392 |
... --var\=TMPDIR\=${RSPAMD_TMPDIR} |
| 393 |
... --var\=DBDIR\=${RSPAMD_TMPDIR} |
| 394 |
... --var\=LOCAL_CONFDIR\=/non-existent |
| 395 |
... --var\=CONFDIR\=${RSPAMD_TESTDIR}/../../conf/ |
| 396 |
... --insecure |
| 397 |
... env:RSPAMD_LOCAL_CONFDIR=/non-existent |
| 398 |
... env:RSPAMD_TMPDIR=${RSPAMD_TMPDIR} |
| 399 |
... env:RSPAMD_CONFDIR=${RSPAMD_TESTDIR}/../../conf/ |
| 400 |
... env:LD_LIBRARY_PATH=${RSPAMD_TESTDIR}/../../contrib/aho-corasick |
| 401 |
... env:RSPAMD_NO_CLEANUP=1 |
| 402 |
... env:ASAN_OPTIONS=quarantine_size_mb=2048:malloc_context_size=20:fast_unwind_on_malloc=0:log_path=${RSPAMD_TMPDIR}/rspamd-asan |
| 403 |
... stdout=${RSPAMD_TMPDIR}/rspamd.stdout stderr=${RSPAMD_TMPDIR}/rspamd.stderr |
| 404 |
|
| 405 |
Export Scoped Variables ${RSPAMD_SCOPE} RSPAMD_PROCESS=${result} |
| 406 |
|
| 407 |
# Confirm worker is reachable |
| 408 |
FOR ${index} IN RANGE 37 |
| 409 |
${ok} = Rspamd Startup Check ${check_port} |
| 410 |
IF ${ok} CONTINUE |
| 411 |
Sleep 0.4s |
| 412 |
END |
| 413 |
|
| 414 |
Rspamd Startup Check |
| 415 |
[Arguments] ${check_port}=${RSPAMD_PORT_NORMAL} |
| 416 |
${handle} = Get Process Object |
| 417 |
${res} = Evaluate $handle.poll() |
| 418 |
IF ${res} != None |
| 419 |
${stderr} = Get File ${RSPAMD_TMPDIR}/rspamd.stderr |
| 420 |
Fail Process Is Gone, stderr: ${stderr} |
| 421 |
END |
| 422 |
${ping} = Run Keyword And Return Status Ping Rspamd ${RSPAMD_LOCAL_ADDR} ${check_port} |
| 423 |
[Return] ${ping} |
| 424 |
|
| 425 |
Rspamadm Setup |
| 426 |
${RSPAMADM_TMPDIR} = Make Temporary Directory |
| 427 |
Set Suite Variable ${RSPAMADM_TMPDIR} |
| 428 |
|
| 429 |
Rspamadm Teardown |
| 430 |
Cleanup Temporary Directory ${RSPAMADM_TMPDIR} |
| 431 |
|
| 432 |
Rspamadm |
| 433 |
[Arguments] @{args} |
| 434 |
${result} = Run Process ${RSPAMADM} |
| 435 |
... --var\=TMPDIR\=${RSPAMADM_TMPDIR} |
| 436 |
... --var\=DBDIR\=${RSPAMADM_TMPDIR} |
| 437 |
... --var\=LOCAL_CONFDIR\=/nonexistent |
| 438 |
... @{args} |
| 439 |
[Return] ${result} |
| 440 |
|
| 441 |
Run Nginx |
| 442 |
${template} = Get File ${RSPAMD_TESTDIR}/configs/nginx.conf |
| 443 |
${config} = Replace Variables ${template} |
| 444 |
Create File ${RSPAMD_TMPDIR}/nginx.conf ${config} |
| 445 |
Log ${config} |
| 446 |
${result} = Run Process nginx -c ${RSPAMD_TMPDIR}/nginx.conf |
| 447 |
IF ${result.rc} != 0 |
| 448 |
Log ${result.stderr} |
| 449 |
END |
| 450 |
Should Be Equal As Integers ${result.rc} 0 |
| 451 |
Wait Until Keyword Succeeds 10x 1 sec Check Pidfile ${RSPAMD_TMPDIR}/nginx.pid timeout=0.5s |
| 452 |
Wait Until Keyword Succeeds 5x 1 sec TCP Connect ${NGINX_ADDR} ${NGINX_PORT} |
| 453 |
${NGINX_PID} = Get File ${RSPAMD_TMPDIR}/nginx.pid |
| 454 |
IF '${NGINX_SCOPE}' == 'Test' |
| 455 |
Set Test Variable ${NGINX_PID} |
| 456 |
ELSE IF '${NGINX_SCOPE}' == 'Suite' |
| 457 |
Set Suite Variable ${NGINX_PID} |
| 458 |
END |
| 459 |
${nginx_log} = Get File ${RSPAMD_TMPDIR}/nginx.log |
| 460 |
Log ${nginx_log} |
| 461 |
|
| 462 |
Set Test Hash Documentation |
| 463 |
${log_tag} = Evaluate __import__('hashlib').md5('${TEST NAME}'.encode()).hexdigest()[:8] |
| 464 |
Log TEST CONTEXT: [${log_tag}] ${TEST NAME} console=True |
| 465 |
|
| 466 |
Run Rspamc |
| 467 |
[Arguments] @{args} |
| 468 |
${log_tag} = Evaluate __import__('hashlib').md5('${TEST NAME}'.encode()).hexdigest()[:8] |
| 469 |
# Check if --queue-id is already provided in the arguments |
| 470 |
${args_str} = Evaluate ' '.join(@{args}) |
| 471 |
${has_queue_id} = Evaluate '--queue-id' in '${args_str}' |
| 472 |
IF ${has_queue_id} |
| 473 |
${result} = Run Process ${RSPAMC} -t 60 --log-tag ${log_tag} |
| 474 |
... @{args} env:LD_LIBRARY_PATH=${RSPAMD_TESTDIR}/../../contrib/aho-corasick |
| 475 |
ELSE |
| 476 |
${result} = Run Process ${RSPAMC} -t 60 --queue-id ${TEST NAME} --log-tag ${log_tag} |
| 477 |
... @{args} env:LD_LIBRARY_PATH=${RSPAMD_TESTDIR}/../../contrib/aho-corasick |
| 478 |
END |
| 479 |
Log ${result.stdout} |
| 480 |
[Return] ${result} |
| 481 |
|
| 482 |
Scan File By Reference |
| 483 |
[Arguments] ${filename} &{headers} |
| 484 |
Set To Dictionary ${headers} File=${filename} |
| 485 |
${result} = Scan File /dev/null &{headers} |
| 486 |
[Return] ${result} |
| 487 |
|
| 488 |
Scan Message With Rspamc |
| 489 |
[Arguments] ${msg_file} @{vargs} |
| 490 |
${result} = Run Rspamc -p -h ${RSPAMD_LOCAL_ADDR}:${RSPAMD_PORT_NORMAL} @{vargs} ${msg_file} |
| 491 |
[Return] ${result} |
| 492 |
|
| 493 |
Sync Fuzzy Storage |
| 494 |
[Arguments] @{vargs} |
| 495 |
${len} = Get Length ${vargs} |
| 496 |
IF $len == 0 |
| 497 |
${result} = Run Process ${RSPAMADM} control -s |
| 498 |
... ${RSPAMD_TMPDIR}/rspamd.sock fuzzy_sync |
| 499 |
ELSE |
| 500 |
Run Process ${RSPAMADM} control -s ${vargs}[0]/rspamd.sock |
| 501 |
... fuzzy_sync |
| 502 |
END |
| 503 |
Log ${result.stdout} |
| 504 |
Sleep 0.1s Try give fuzzy storage time to sync |
| 505 |
|
| 506 |
Run Control Command |
| 507 |
[Documentation] Run a control socket command and return the result |
| 508 |
[Arguments] ${command} ${socket} |
| 509 |
${result} = Run Process ${RSPAMADM} control -s |
| 510 |
... ${socket} ${command} timeout=10s |
| 511 |
Log ${result.stdout} |
| 512 |
Log ${result.stderr} |
| 513 |
[Return] ${result} |
| 514 |
|
| 515 |
Run Control Command JSON |
| 516 |
[Documentation] Run a control socket command and return JSON result |
| 517 |
[Arguments] ${command} ${socket} |
| 518 |
${result} = Run Process ${RSPAMADM} control -j -s |
| 519 |
... ${socket} ${command} timeout=10s |
| 520 |
Log ${result.stdout} |
| 521 |
Log ${result.stderr} |
| 522 |
[Return] ${result} |
| 523 |
|
| 524 |
Run Dummy Http |
| 525 |
${result} = Start Process ${RSPAMD_TESTDIR}/util/dummy_http.py -pf /tmp/dummy_http.pid |
| 526 |
... stderr=/tmp/dummy_http.log stdout=/tmp/dummy_http.log |
| 527 |
${status} ${error} = Run Keyword And Ignore Error Wait Until Created /tmp/dummy_http.pid timeout=2 second |
| 528 |
IF '${status}' == 'FAIL' |
| 529 |
${logstatus} ${log} = Run Keyword And Ignore Error Get File /tmp/dummy_http.log |
| 530 |
IF '${logstatus}' == 'PASS' |
| 531 |
Log dummy_http.py failed to start. Log output:\n${log} level=ERROR |
| 532 |
ELSE |
| 533 |
Log dummy_http.py failed to start. No log file found at /tmp/dummy_http.log level=ERROR |
| 534 |
END |
| 535 |
Fail dummy_http.py did not create PID file in 2 seconds |
| 536 |
END |
| 537 |
Export Scoped Variables ${RSPAMD_SCOPE} DUMMY_HTTP_PROC=${result} |
| 538 |
|
| 539 |
Run Dummy Https |
| 540 |
${result} = Start Process ${RSPAMD_TESTDIR}/util/dummy_http.py |
| 541 |
... -c ${RSPAMD_TESTDIR}/util/server.pem -k ${RSPAMD_TESTDIR}/util/server.pem |
| 542 |
... -pf /tmp/dummy_https.pid -p 18081 |
| 543 |
... stderr=/tmp/dummy_https.log stdout=/tmp/dummy_https.log |
| 544 |
${status} ${error} = Run Keyword And Ignore Error Wait Until Created /tmp/dummy_https.pid timeout=2 second |
| 545 |
IF '${status}' == 'FAIL' |
| 546 |
${logstatus} ${log} = Run Keyword And Ignore Error Get File /tmp/dummy_https.log |
| 547 |
IF '${logstatus}' == 'PASS' |
| 548 |
Log dummy_https.py failed to start. Log output:\n${log} level=ERROR |
| 549 |
ELSE |
| 550 |
Log dummy_https.py failed to start. No log file found at /tmp/dummy_https.log level=ERROR |
| 551 |
END |
| 552 |
Fail dummy_https.py did not create PID file in 2 seconds |
| 553 |
END |
| 554 |
Export Scoped Variables ${RSPAMD_SCOPE} DUMMY_HTTPS_PROC=${result} |
| 555 |
|
| 556 |
Run Dummy Llm |
| 557 |
${result} = Start Process ${RSPAMD_TESTDIR}/util/dummy_llm.py 18080 |
| 558 |
... stderr=/tmp/dummy_llm.log stdout=/tmp/dummy_llm.log |
| 559 |
${status} ${error} = Run Keyword And Ignore Error Wait Until Created /tmp/dummy_llm.pid timeout=2 second |
| 560 |
IF '${status}' == 'FAIL' |
| 561 |
${logstatus} ${log} = Run Keyword And Ignore Error Get File /tmp/dummy_llm.log |
| 562 |
IF '${logstatus}' == 'PASS' |
| 563 |
Log dummy_llm.py failed to start. Log output:\n${log} level=ERROR |
| 564 |
ELSE |
| 565 |
Log dummy_llm.py failed to start. No log file found at /tmp/dummy_llm.log level=ERROR |
| 566 |
END |
| 567 |
Fail dummy_llm.py did not create PID file in 2 seconds |
| 568 |
END |
| 569 |
Export Scoped Variables ${RSPAMD_SCOPE} DUMMY_LLM_PROC=${result} |
| 570 |
|
| 571 |
Dummy Llm Teardown |
| 572 |
Terminate Process ${DUMMY_LLM_PROC} |
| 573 |
Wait For Process ${DUMMY_LLM_PROC} |
| 574 |
|
| 575 |
Dummy Http Teardown |
| 576 |
Terminate Process ${DUMMY_HTTP_PROC} |
| 577 |
Wait For Process ${DUMMY_HTTP_PROC} |
| 578 |
|
| 579 |
Dummy Https Teardown |
| 580 |
Terminate Process ${DUMMY_HTTPS_PROC} |
| 581 |
Wait For Process ${DUMMY_HTTPS_PROC} |
| 582 |
|
| 583 |
Run Dummy Http Early Response |
| 584 |
${result} = Start Process ${RSPAMD_TESTDIR}/util/dummy_http_early_response.py -pf /tmp/dummy_http_early.pid -p 18083 |
| 585 |
... stderr=/tmp/dummy_http_early.log stdout=/tmp/dummy_http_early.log |
| 586 |
${status} ${error} = Run Keyword And Ignore Error Wait Until Created /tmp/dummy_http_early.pid timeout=2 second |
| 587 |
IF '${status}' == 'FAIL' |
| 588 |
${logstatus} ${log} = Run Keyword And Ignore Error Get File /tmp/dummy_http_early.log |
| 589 |
IF '${logstatus}' == 'PASS' |
| 590 |
Log dummy_http_early_response.py failed to start. Log output:\n${log} level=ERROR |
| 591 |
ELSE |
| 592 |
Log dummy_http_early_response.py failed to start. No log file found at /tmp/dummy_http_early.log level=ERROR |
| 593 |
END |
| 594 |
Fail dummy_http_early_response.py did not create PID file in 2 seconds |
| 595 |
END |
| 596 |
Export Scoped Variables ${RSPAMD_SCOPE} DUMMY_HTTP_EARLY_PROC=${result} |
| 597 |
|
| 598 |
Dummy Http Early Teardown |
| 599 |
Terminate Process ${DUMMY_HTTP_EARLY_PROC} |
| 600 |
Wait For Process ${DUMMY_HTTP_EARLY_PROC} |