You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/09/10 09:39:27 UTC
[GitHub] [apisix] spacewander commented on pull request #4965: feat(proxy-mirror): support mirror requests sample_ratio
spacewander commented on pull request #4965:
URL: https://github.com/apache/apisix/pull/4965#issuecomment-916772884
Try this patch?
```
diff --git t/plugin/proxy-mirror.t t/plugin/proxy-mirror.t
index 888e9a86..a6b7e3ca 100644
--- t/plugin/proxy-mirror.t
+++ t/plugin/proxy-mirror.t
@@ -38,7 +38,7 @@ add_block_preprocessor(sub {
local http = require("resty.http")
local httpc = http.new()
- local url = "http://127.0.0.1:1984/stat_count?action=inc"
+ local url = "http://127.0.0.1:1980/stat_count?action=inc"
local res, err = httpc:request_uri(url, {method = "GET"})
if not res then
core.log.error(err)
@@ -588,46 +588,14 @@ passed
-=== TEST 17: set route(stat_count)
---- config
- location /t {
- content_by_lua_block {
- local t = require("lib.test_admin").test
- local code, body = t('/apisix/admin/routes/2',
- ngx.HTTP_PUT,
- [[{
- "upstream": {
- "nodes": {
- "127.0.0.1:1980": 1
- },
- "type": "roundrobin"
- },
- "uri": "/stat_count"
- }]]
- )
-
- if code >= 300 then
- ngx.status = code
- end
- ngx.say(body)
- }
- }
---- request
-GET /t
---- error_code: 200
---- response_body
-passed
-
-
-
-=== TEST 18: send batch requests and get mirror stat count
+=== TEST 17: send batch requests and get mirror stat count
--- config
location /t {
content_by_lua_block {
local t = require("lib.test_admin").test
-- reset count
- local code, count = t('/stat_count?action=reset', ngx.HTTP_GET)
+ local code, _, count = t('/stat_count?action=reset', ngx.HTTP_GET)
if code >= 300 then
ngx.status = code
end
@@ -645,10 +613,12 @@ passed
end
-- get mirror stat count
- code, count = t('/stat_count', ngx.HTTP_GET)
+ local code, _, count = t('/stat_count', ngx.HTTP_GET)
if code >= 300 then
ngx.status = code
+ return
end
+ count = tonumber(count)
assert(count >= 75 and count <= 125, "mirror request count not in [75, 125]")
}
@@ -657,4 +627,3 @@ passed
GET /t
--- error_log_like eval
qr/(uri: \/hello\?sample_ratio=0\.5){75,125}/
---- timeout: 60
```
--
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org