-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
40 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,64 @@ | ||
local fmt = string.format | ||
local helpers = require "spec.helpers" | ||
|
||
|
||
local SERVICE_YML = [[ | ||
- name: my-service-%d | ||
url: https://example%d.dev | ||
plugins: | ||
- name: dbless-pagination-test | ||
routes: | ||
- name: my-route-%d | ||
paths: | ||
- /%d | ||
]] | ||
local strategy = "off" | ||
|
||
|
||
describe("dbless pagination #off", function() | ||
local client | ||
describe("dbless pagination #" .. strategy, function() | ||
local client, admin_client | ||
|
||
lazy_setup(function() | ||
local bp = helpers.get_db_utils(strategy, { | ||
"routes", | ||
"services", | ||
"plugins", | ||
}) | ||
|
||
bp.plugins:insert { | ||
name = "dbless-pagination-test", | ||
config = { }, | ||
} | ||
|
||
for i = 1, 1001 do | ||
local service = assert(bp.services:insert { | ||
url = "https://example1.dev", | ||
name = "my-serivce-" .. i, | ||
}) | ||
|
||
assert(bp.routes:insert({ | ||
paths = { "/" .. i }, | ||
service = service, | ||
name = "my-route-" .. i, | ||
})) | ||
end | ||
|
||
assert(helpers.start_kong({ | ||
nginx_conf = "spec/fixtures/custom_nginx.template", | ||
database = "off", | ||
database = strategy, | ||
plugins = "bundled,dbless-pagination-test", | ||
})) | ||
print("helpers.start_kong") | ||
|
||
client = assert(helpers.proxy_client()) | ||
admin_client = assert(helpers.admin_client()) | ||
end) | ||
|
||
lazy_teardown(function() | ||
admin_client:close() | ||
client:close() | ||
helpers.stop_kong() | ||
end) | ||
|
||
it("Routes", function() | ||
local buffer = {"_format_version: '3.0'", "services:"} | ||
for i = 1, 1001 do | ||
buffer[#buffer + 1] = fmt(SERVICE_YML, i, i, i, i) | ||
end | ||
local config = table.concat(buffer, "\n") | ||
|
||
local admin_client = assert(helpers.admin_client()) | ||
local res = admin_client:post("/config",{ | ||
body = { config = config }, | ||
headers = { | ||
["Content-Type"] = "application/json", | ||
} | ||
}) | ||
assert.res_status(201, res) | ||
admin_client:close() | ||
|
||
local res = admin_client:get("/routes/my-route-1") | ||
print(res:read_body()) | ||
print("-------") | ||
|
||
-- check routes number with :page() API | ||
--local res, err = client:get("/1", {}) | ||
assert.res_status(200, res) | ||
|
||
local res = assert(client:send { | ||
method = "GET", | ||
path = "/1", | ||
}) | ||
--print(require("inspect")(res)) | ||
local resbody = res:read_body() | ||
print"--------" | ||
print(resbody) | ||
--assert.response(res).has.header("X-rows-number", "test") | ||
assert.res_status(200, res) | ||
assert.same(res.headers["X-Rows-Number"], "512") | ||
assert.same(res.headers["X-Max-Page-Size"], "2048") | ||
end) | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters