-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(request-id): we can use different ids with the same request #4479
Changes from 5 commits
344701b
18e2ded
fe7df38
ffe870e
9e02e21
6f1efed
cdb3798
2489318
83ef3f3
08fef26
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -387,3 +387,86 @@ GET /t | |||||
request header not present | ||||||
--- no_error_log | ||||||
[error] | ||||||
|
||||||
|
||||||
|
||||||
=== TEST 10: add plugin with custom header name in global rule and add plugin with default header name in specific route | ||||||
--- config | ||||||
location /t { | ||||||
content_by_lua_block { | ||||||
local t = require("lib.test_admin").test | ||||||
local code, body = t('/apisix/admin/global_rules/1', | ||||||
ngx.HTTP_PUT, | ||||||
[[{ | ||||||
"plugins": { | ||||||
"request-id": { | ||||||
"header_name":"Custom-Header-Name" | ||||||
} | ||||||
} | ||||||
}]] | ||||||
) | ||||||
if code >= 300 then | ||||||
ngx.status = code | ||||||
ngx.say(body) | ||||||
return | ||||||
end | ||||||
local code, body = t('/apisix/admin/routes/1', | ||||||
ngx.HTTP_PUT, | ||||||
[[{ | ||||||
"plugins": { | ||||||
"request-id": { | ||||||
} | ||||||
}, | ||||||
"upstream": { | ||||||
"nodes": { | ||||||
"127.0.0.1:1982": 1 | ||||||
}, | ||||||
"type": "roundrobin" | ||||||
}, | ||||||
"uri": "/opentracing" | ||||||
}]] | ||||||
) | ||||||
if code >= 300 then | ||||||
ngx.status = code | ||||||
return | ||||||
end | ||||||
ngx.say(body) | ||||||
} | ||||||
} | ||||||
--- request | ||||||
GET /t | ||||||
--- response_body | ||||||
passed | ||||||
--- no_error_log | ||||||
[error] | ||||||
|
||||||
|
||||||
=== TEST 11: check for multiple request-ids in the response header are different | ||||||
--- config | ||||||
location /t { | ||||||
content_by_lua_block { | ||||||
local http = require "resty.http" | ||||||
local httpc = http.new() | ||||||
local uri = "http://127.0.0.1:" .. ngx.var.server_port .. "/opentracing" | ||||||
local res, err = httpc:request_uri(uri, | ||||||
{ | ||||||
method = "GET", | ||||||
headers = { | ||||||
["Content-Type"] = "application/json", | ||||||
} | ||||||
}) | ||||||
|
||||||
if res.headers["X-Request-Id"] and res.headers["Custom-Header-Name"] and res.headers["X-Request-Id"] ~= res.headers["Custom-Header-Name"] then | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should not verify these two values when they are present, actually they must present. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, got it |
||||||
ngx.say("X-Request-Id and Custom-Header-Name is different") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
else | ||||||
ngx.say("failed") | ||||||
end | ||||||
} | ||||||
} | ||||||
--- request | ||||||
GET /t | ||||||
--- response_body | ||||||
X-Request-Id and Custom-Header-Name is different | ||||||
--- no_error_log | ||||||
[error] | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the linter: https://github.com/apache/apisix/pull/4479/checks?check_run_id=2929454713
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there should be 3 blank lines between test cases, or you can use the reindex to do. the CI error is about this.