From 0c60d57b2dc2f284eca2720891e87c2168a294dd Mon Sep 17 00:00:00 2001 From: u5surf Date: Mon, 2 Jan 2023 12:18:35 +0900 Subject: [PATCH] Add histogram_bucket test --- t/023.histogram_buckets.t | 46 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 t/023.histogram_buckets.t diff --git a/t/023.histogram_buckets.t b/t/023.histogram_buckets.t new file mode 100644 index 0000000..130ba4a --- /dev/null +++ b/t/023.histogram_buckets.t @@ -0,0 +1,46 @@ +# vi:set ft=perl ts=4 sw=4 et fdm=marker: + +use Test::Nginx::Socket; +use Fcntl; + +plan tests => repeat_each() * blocks() * 4; +no_shuffle(); +run_tests(); + +__DATA__ + +=== TEST 1: access status with vhost_traffic_status_histogram_bucket to get the request and responseBuckets after accessing upstream backend +--- http_config + vhost_traffic_status_zone; + vhost_traffic_status_histogram_buckets .1 .5 1 2; + upstream backend { + server 127.0.0.1; + } + server { + server_name _; + vhost_traffic_status_filter_by_host on; + } +--- config + location /status { + vhost_traffic_status_display; + vhost_traffic_status_display_format json; + access_log off; + } + location /one { + proxy_set_header Host one.example.org; + proxy_pass http://backend; + } +--- user_files eval +[ + ['one/file.txt' => 'one.example.org:OK'], +] +--- request eval +[ + 'GET /one/file.txt', + 'GET /status/', +] +--- response_body_like eval +[ + 'OK', + '\"requestBuckets\"\:\{\"msecs\"\:\[100,500,1000,2000\],\"counters\"\:\[1,1,1,1\].*\"responseBuckets\"\:\{\"msecs\"\:\[100,500,1000,2000\],\"counters\"\:\[1,1,1,1\]', +]