| 1 |
*** Settings *** |
| 2 |
Library ${RSPAMD_TESTDIR}/lib/rspamd.py |
| 3 |
Resource ${RSPAMD_TESTDIR}/lib/rspamd.robot |
| 4 |
Variables ${RSPAMD_TESTDIR}/lib/vars.py |
| 5 |
|
| 6 |
*** Test Cases *** |
| 7 |
Metrics Default Content Type |
| 8 |
[Documentation] Without Accept header, should return OpenMetrics format |
| 9 |
@{result} = HTTP With Headers GET ${RSPAMD_LOCAL_ADDR} ${RSPAMD_PORT_CONTROLLER} /metrics |
| 10 |
Should Be Equal As Integers ${result}[0] 200 |
| 11 |
Should Contain ${result}[2][Content-Type] application/openmetrics-text |
| 12 |
Should Contain ${result}[1].decode('utf-8') \# EOF |
| 13 |
|
| 14 |
Metrics With OpenMetrics Accept |
| 15 |
[Documentation] With Accept: application/openmetrics-text, should return OpenMetrics |
| 16 |
&{headers} = Create Dictionary Accept=application/openmetrics-text |
| 17 |
@{result} = HTTP With Headers GET ${RSPAMD_LOCAL_ADDR} ${RSPAMD_PORT_CONTROLLER} /metrics headers=${headers} |
| 18 |
Should Be Equal As Integers ${result}[0] 200 |
| 19 |
Should Contain ${result}[2][Content-Type] application/openmetrics-text |
| 20 |
Should Contain ${result}[1].decode('utf-8') \# EOF |
| 21 |
|
| 22 |
Metrics With Text Plain Accept |
| 23 |
[Documentation] With Accept: text/plain, should return Prometheus 0.0.4 format |
| 24 |
&{headers} = Create Dictionary Accept=text/plain |
| 25 |
@{result} = HTTP With Headers GET ${RSPAMD_LOCAL_ADDR} ${RSPAMD_PORT_CONTROLLER} /metrics headers=${headers} |
| 26 |
Should Be Equal As Integers ${result}[0] 200 |
| 27 |
Should Contain ${result}[2][Content-Type] text/plain |
| 28 |
Should Contain ${result}[1].decode('utf-8') \# EOF |
| 29 |
|
| 30 |
Metrics With Wildcard Accept |
| 31 |
[Documentation] With Accept: */*, should return default (OpenMetrics) |
| 32 |
&{headers} = Create Dictionary Accept=*/* |
| 33 |
@{result} = HTTP With Headers GET ${RSPAMD_LOCAL_ADDR} ${RSPAMD_PORT_CONTROLLER} /metrics headers=${headers} |
| 34 |
Should Be Equal As Integers ${result}[0] 200 |
| 35 |
Should Contain ${result}[2][Content-Type] application/openmetrics-text |
| 36 |
|
| 37 |
Metrics With Quality Factor |
| 38 |
[Documentation] Accept header with quality factors should prefer higher quality |
| 39 |
&{headers} = Create Dictionary Accept=text/plain;q=0.9, application/openmetrics-text;q=1.0 |
| 40 |
@{result} = HTTP With Headers GET ${RSPAMD_LOCAL_ADDR} ${RSPAMD_PORT_CONTROLLER} /metrics headers=${headers} |
| 41 |
Should Be Equal As Integers ${result}[0] 200 |
| 42 |
Should Contain ${result}[2][Content-Type] application/openmetrics-text |
| 43 |
|
| 44 |
Metrics Fallback For Unknown Accept |
| 45 |
[Documentation] With unsupported Accept type, should fallback to text/plain |
| 46 |
&{headers} = Create Dictionary Accept=application/xml |
| 47 |
@{result} = HTTP With Headers GET ${RSPAMD_LOCAL_ADDR} ${RSPAMD_PORT_CONTROLLER} /metrics headers=${headers} |
| 48 |
Should Be Equal As Integers ${result}[0] 200 |
| 49 |
Should Contain ${result}[2][Content-Type] text/plain |
| 50 |
|
| 51 |
Stat With Msgpack Accept |
| 52 |
[Documentation] With Accept: application/msgpack, should return msgpack format |
| 53 |
&{headers} = Create Dictionary Accept=application/msgpack |
| 54 |
@{result} = HTTP With Headers GET ${RSPAMD_LOCAL_ADDR} ${RSPAMD_PORT_CONTROLLER} /stat headers=${headers} |
| 55 |
Should Be Equal As Integers ${result}[0] 200 |
| 56 |
Should Contain ${result}[2][Content-Type] application/msgpack |
| 57 |
|
| 58 |
Stat With JSON Accept |
| 59 |
[Documentation] With Accept: application/json, should return JSON format |
| 60 |
&{headers} = Create Dictionary Accept=application/json |
| 61 |
@{result} = HTTP With Headers GET ${RSPAMD_LOCAL_ADDR} ${RSPAMD_PORT_CONTROLLER} /stat headers=${headers} |
| 62 |
Should Be Equal As Integers ${result}[0] 200 |
| 63 |
Should Contain ${result}[2][Content-Type] application/json |
| 64 |
|
| 65 |
Stat With Zstd Encoding |
| 66 |
[Documentation] With Accept-Encoding: zstd, should return zstd compressed response |
| 67 |
&{headers} = Create Dictionary Accept-Encoding=zstd |
| 68 |
@{result} = HTTP With Headers GET ${RSPAMD_LOCAL_ADDR} ${RSPAMD_PORT_CONTROLLER} /stat headers=${headers} |
| 69 |
Should Be Equal As Integers ${result}[0] 200 |
| 70 |
Should Contain ${result}[2][Content-Encoding] zstd |
| 71 |
|
| 72 |
Stat With Gzip Encoding |
| 73 |
[Documentation] With Accept-Encoding: gzip, should return gzip compressed response |
| 74 |
&{headers} = Create Dictionary Accept-Encoding=gzip |
| 75 |
@{result} = HTTP With Headers GET ${RSPAMD_LOCAL_ADDR} ${RSPAMD_PORT_CONTROLLER} /stat headers=${headers} |
| 76 |
Should Be Equal As Integers ${result}[0] 200 |
| 77 |
Should Contain ${result}[2][Content-Encoding] gzip |
| 78 |
|
| 79 |
Stat With Msgpack And Zstd |
| 80 |
[Documentation] With Accept: msgpack and Accept-Encoding: zstd, should return compressed msgpack |
| 81 |
&{headers} = Create Dictionary Accept=application/msgpack Accept-Encoding=zstd |
| 82 |
@{result} = HTTP With Headers GET ${RSPAMD_LOCAL_ADDR} ${RSPAMD_PORT_CONTROLLER} /stat headers=${headers} |
| 83 |
Should Be Equal As Integers ${result}[0] 200 |
| 84 |
Should Contain ${result}[2][Content-Type] application/msgpack |
| 85 |
Should Contain ${result}[2][Content-Encoding] zstd |