You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by me...@apache.org on 2020/06/05 13:23:55 UTC

[incubator-apisix] branch master updated: test: add test case for #1625 to test the filed of overhead (#1645)

This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new 171db26  test: add test case for #1625 to test the filed of overhead (#1645)
171db26 is described below

commit 171db26e123e9e5b1e7eab897d4aead8286ecfdc
Author: dabue <53...@users.noreply.github.com>
AuthorDate: Fri Jun 5 21:23:42 2020 +0800

    test: add test case for #1625 to test the filed of overhead (#1645)
---
 t/lib/server.lua      |   1 -
 t/plugin/prometheus.t | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 129 insertions(+), 1 deletion(-)

diff --git a/t/lib/server.lua b/t/lib/server.lua
index fe82408..e34602c 100644
--- a/t/lib/server.lua
+++ b/t/lib/server.lua
@@ -28,7 +28,6 @@ function _M.hello1()
     ngx.say("hello1 world")
 end
 
-
 function _M.server_port()
     ngx.print(ngx.var.server_port)
 end
diff --git a/t/plugin/prometheus.t b/t/plugin/prometheus.t
index a5f28f9..4e99b84 100644
--- a/t/plugin/prometheus.t
+++ b/t/plugin/prometheus.t
@@ -534,3 +534,132 @@ GET /apisix/prometheus/metrics
 qr/.*apisix_http_overhead_bucket.*/
 --- no_error_log
 [error]
+
+
+
+=== TEST 26: add service 3 to distinguish other services
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/services/3',
+                ngx.HTTP_PUT,
+                [[{
+                    "plugins": {
+                        "prometheus": {}
+                    },
+                    "upstream": {
+                        "nodes": {
+                            "127.0.0.1:1981": 1
+                        },
+                        "type": "roundrobin"
+                    }
+                }]]
+                )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]
+
+
+
+=== TEST 27: add a route 4 to redirect /sleep1
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/routes/4',
+                 ngx.HTTP_PUT,
+                 [[{
+                    "service_id": 3,
+                    "uri": "/sleep1"
+                }]]
+                )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]
+
+
+
+=== TEST 28: request from client to /sleep1 ( all hit)
+--- pipelined_requests eval
+["GET /sleep1", "GET /sleep1", "GET /sleep1"]
+--- error_code eval
+[200, 200, 200]
+--- no_error_log
+[error]
+
+
+
+=== TEST 29: fetch the prometheus metric data with `overhead`(the overhead < 1s)
+--- request
+GET /apisix/prometheus/metrics
+--- response_body eval
+qr/apisix_http_overhead_bucket.*service=\"3\".*le=\"00500.0.*/
+--- no_error_log
+[error]
+
+
+
+=== TEST 30: delete route 4
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/routes/4',
+                ngx.HTTP_DELETE
+            )
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]
+
+
+
+=== TEST 31: delete service 3
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/services/3',
+                ngx.HTTP_DELETE
+            )
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]