Skip to content

Commit

Permalink
[test] Add EXTENDED_METRICS integration test.
Browse files Browse the repository at this point in the history
This commit add the EXTENDED_Metrics integration test.

Signed-off-by: Eloy Coto <eloy.coto@gmail.com>
  • Loading branch information
eloycoto committed Apr 30, 2019
1 parent 8a2f89a commit 5027c0b
Showing 1 changed file with 132 additions and 2 deletions.
134 changes: 132 additions & 2 deletions t/prometheus-metrics.t
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ In particular, it shows the status codes and the response times
--- response_body_like eval
[
"",
qr/upstream_response_time_seconds(.|\n)*upstream_response_time_seconds_bucket\{le=".*"\} 1(.|\n)*upstream_status\{status="200"\} 1/
qr/upstream_response_time_seconds(.|\n)*upstream_response_time_seconds_bucket\{service="all",le=".*"\} 1(.|\n)*upstream_status\{status="200",service="all"\} 1/
]
--- no_error_log
[error]
Expand Down Expand Up @@ -275,7 +275,137 @@ qr/upstream_response_time_seconds(.|\n)*upstream_response_time_seconds_bucket\{l
--- response_body_like eval
[
"",
qr/total_response_time_seconds(.|\n)*total_response_time_seconds_bucket\{le=".*"\} 1/
qr/total_response_time_seconds(.|\n)*total_response_time_seconds_bucket\{service="all",le=".*"\} 1/
]
--- no_error_log
[error]
=== TEST 6: extended metrics show services id
--- env eval
("APICAST_EXTENDED_METRICS", "true")
--- configuration
{
"services": [
{
"id": 42,
"proxy": {
"policy_chain": [
{
"name": "apicast.policy.upstream",
"configuration": {
"rules": [
{
"regex": "/",
"url": "http://test:$TEST_NGINX_SERVER_PORT"
}
]
}
}
]
}
}
]
}
--- upstream
location / {
content_by_lua_block {
ngx.exit(200);
}
}
location /two {
content_by_lua_block {
ngx.exit(200);
}
}
--- request eval
["GET /", "GET /metrics"]
--- more_headers eval
["", "Host: metrics"]
--- error_code eval
[ 200, 200 ]
--- response_body_like eval
[
"",
qr/total_response_time_seconds(.|\n)*total_response_time_seconds_bucket\{service="42",le=".*"\} 1/,
qr/upstream_response_time_seconds(.|\n)*upstream_response_time_seconds_bucket\{service="42",le=".*"\} 1(.|\n)*upstream_status\{status="42",service="all"\} 1/
]
--- no_error_log
[error]
=== TEST 7: extended metrics with multiple services
--- env eval
("APICAST_EXTENDED_METRICS", "true")
--- configuration
{
"services": [
{
"id": 42,
"proxy": {
"policy_chain": [
{
"name": "apicast.policy.upstream",
"configuration": {
"rules": [
{
"regex": "/",
"url": "http://test:$TEST_NGINX_SERVER_PORT"
}
]
}
}
]
}
},
{
"id": 21,
"proxy": {
"policy_chain": [
{
"name": "apicast.policy.upstream",
"configuration": {
"rules": [
{
"regex": "/",
"url": "http://test:$TEST_NGINX_SERVER_PORT/two"
}
]
}
}
]
}
}
]
}
--- upstream
location / {
content_by_lua_block {
ngx.exit(200);
}
}
location /two {
content_by_lua_block {
ngx.exit(200);
}
}
--- request eval
["GET /", "GET /metrics"]
--- more_headers eval
["", "Host: metrics"]
--- error_code eval
[ 200, 200 ]
--- response_body_like eval
[
"",
qr/total_response_time_seconds(.|\n)*total_response_time_seconds_bucket\{service="42",le=".*"\} 1/,
qr/upstream_response_time_seconds(.|\n)*upstream_response_time_seconds_bucket\{service="42",le=".*"\} 1(.|\n)*upstream_status\{status="42",service="all"\} 1/,
qr/total_response_time_seconds(.|\n)*total_response_time_seconds_bucket\{service="21",le=".*"\} 1/,
qr/upstream_response_time_seconds(.|\n)*upstream_response_time_seconds_bucket\{service="21",le=".*"\} 1(.|\n)*upstream_status\{status="42",service="all"\} 1/,
]
--- no_error_log
[error]

0 comments on commit 5027c0b

Please sign in to comment.