monkeyDluffy6017 commented on code in PR #9673:
URL: https://github.com/apache/apisix/pull/9673#discussion_r1231841077


##########
t/plugin/prometheus4.t:
##########
@@ -134,3 +134,62 @@ GET /hello
 GET /apisix/prometheus/metrics
 --- response_body eval
 
qr/apisix_http_status\{code="200",route="10",matched_uri="\/hello",matched_host="",service="",consumer="",node="127.0.0.1",dummy=""\}
 \d+/
+
+
+
+=== TEST 7: set route
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/routes/1',
+                ngx.HTTP_PUT,
+                [[{
+                    "plugins": {
+                        "prometheus": {}
+                    },
+                    "upstream": {
+                        "nodes": {
+                            "127.0.0.1:1980": 1
+                        },
+                        "type": "roundrobin"
+                    },
+                    "uri": "/hello1"
+                }]]
+                )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- response_body
+passed
+
+
+
+=== TEST 8: set default_buckets
+--- yaml_config
+plugin_attr:
+    prometheus:
+        default_buckets:
+            - 15
+            - 55
+            - 105
+            - 205
+            - 505
+--- request
+GET /hello1

Review Comment:
   I ususally wirte like this, what do you think?
   ```suggestion
   === TEST 7: set route
   --- yaml_config
   plugin_attr:
       prometheus:
           default_buckets:
               - 15
               - 55
               - 105
               - 205
               - 505
   --- config
       location /t {
           content_by_lua_block {
               local t = require("lib.test_admin").test
               local code, body = t('/apisix/admin/routes/1',
                   ngx.HTTP_PUT,
                   [[{
                       "plugins": {
                           "prometheus": {}
                       },
                       "upstream": {
                           "nodes": {
                               "127.0.0.1:1980": 1
                           },
                           "type": "roundrobin"
                       },
                       "uri": "/hello1"
                   }]]
                   )
   
               if code >= 300 then
                   ngx.status = code
               end
               ngx.say(body)
           }
       }
   --- request
   GET /hello1
   --- response_body
   passed
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to