forked from vozlt/nginx-module-vts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request vozlt#242 from u5surf/test_display_prometheus
test: Add test for display prometheus
- Loading branch information
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# vi:set ft=perl ts=4 sw=4 et fdm=marker: | ||
|
||
use Test::Nginx::Socket; | ||
|
||
add_response_body_check( | ||
sub { | ||
my ($block, $body, $req_idx, $repeated_req_idx, $dry_run) = @_; | ||
system("echo '$body' | promtool check metrics") == 0 or | ||
bail_out "prometheus Syntax error($body)"; | ||
} | ||
); | ||
|
||
plan tests => repeat_each(2) * blocks() * 3; | ||
no_shuffle(); | ||
run_tests(); | ||
|
||
__DATA__ | ||
=== TEST 1: /status/format/prometheus | ||
--- http_config | ||
vhost_traffic_status_zone; | ||
--- config | ||
location /status { | ||
vhost_traffic_status_display; | ||
vhost_traffic_status_display_format prometheus; | ||
} | ||
--- request | ||
GET /status/format/prometheus | ||
--- response_headers_like | ||
Content-Type: text/plain | ||
--- response_body_like eval | ||
[ | ||
'nginx_vts_info', | ||
] | ||
=== TEST 2: /status | ||
--- http_config | ||
vhost_traffic_status_zone; | ||
--- config | ||
location /status { | ||
vhost_traffic_status_display; | ||
vhost_traffic_status_display_format prometheus; | ||
} | ||
--- request | ||
GET /status | ||
--- response_headers_like | ||
Content-Type: text/plain | ||
--- response_body_like eval | ||
[ | ||
'nginx_vts_info', | ||
] |