mirror of
https://gitee.com/iresty/apisix.git
synced 2024-12-14 17:01:20 +08:00
114 lines
2.2 KiB
Perl
114 lines
2.2 KiB
Perl
|
use t::APISIX 'no_plan';
|
||
|
|
||
|
log_level('info');
|
||
|
no_root_location();
|
||
|
|
||
|
run_tests();
|
||
|
|
||
|
__DATA__
|
||
|
|
||
|
=== TEST 1: set stream route(id: 1)
|
||
|
--- config
|
||
|
location /t {
|
||
|
content_by_lua_block {
|
||
|
local t = require("lib.test_admin").test
|
||
|
local code, body = t('/apisix/admin/stream_routes/1',
|
||
|
ngx.HTTP_PUT,
|
||
|
[[{
|
||
|
"remote_addr": "127.0.0.1",
|
||
|
"upstream": {
|
||
|
"nodes": {
|
||
|
"127.0.0.1:1995": 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 2: hit route
|
||
|
--- stream_enable
|
||
|
--- stream_response
|
||
|
hello world
|
||
|
--- no_error_log
|
||
|
[error]
|
||
|
|
||
|
|
||
|
|
||
|
=== TEST 3: set stream route(id: 1)
|
||
|
--- config
|
||
|
location /t {
|
||
|
content_by_lua_block {
|
||
|
local t = require("lib.test_admin").test
|
||
|
local code, body = t('/apisix/admin/stream_routes/1',
|
||
|
ngx.HTTP_PUT,
|
||
|
[[{
|
||
|
"remote_addr": "127.0.0.2",
|
||
|
"upstream": {
|
||
|
"nodes": {
|
||
|
"127.0.0.1:1995": 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 4: not hit route
|
||
|
--- stream_enable
|
||
|
--- stream_response
|
||
|
--- no_error_log
|
||
|
[error]
|
||
|
|
||
|
|
||
|
|
||
|
=== TEST 5: delete route(id: 1)
|
||
|
--- config
|
||
|
location /t {
|
||
|
content_by_lua_block {
|
||
|
local t = require("lib.test_admin").test
|
||
|
local code, body = t('/apisix/admin/stream_routes/1',
|
||
|
ngx.HTTP_DELETE
|
||
|
)
|
||
|
|
||
|
if code >= 300 then
|
||
|
ngx.status = code
|
||
|
end
|
||
|
ngx.say(body)
|
||
|
}
|
||
|
}
|
||
|
--- request
|
||
|
GET /t
|
||
|
--- response_body
|
||
|
passed
|
||
|
--- no_error_log
|
||
|
[error]
|