diff --git a/kong/db/init.lua b/kong/db/init.lua index f4fde3ae78c0..edf44f2ac46d 100644 --- a/kong/db/init.lua +++ b/kong/db/init.lua @@ -89,7 +89,6 @@ function DB.new(kong_config, strategy) local connector, strategies, err = Strategies.new(kong_config, strategy, schemas, errors) - if err then return nil, err end diff --git a/spec/02-integration/11-dbless/04-pagination_spec.lua b/spec/02-integration/11-dbless/04-pagination_spec.lua index 358abf161f5b..179ebc1f1356 100644 --- a/spec/02-integration/11-dbless/04-pagination_spec.lua +++ b/spec/02-integration/11-dbless/04-pagination_spec.lua @@ -5,8 +5,6 @@ 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: @@ -14,14 +12,29 @@ local SERVICE_YML = [[ ]] +local POST_FUNC = [[ +plugins: + - name: key-auth + - name: post-function + config: + log: + - | + return function(conf) + local db = kong.db + + assert(db.routes.pagination.max_page_size == 2048) + end +]] + + +local COUNT = 1001 + + describe("dbless pagination #off", function() lazy_setup(function() assert(helpers.start_kong({ - nginx_conf = "spec/fixtures/custom_nginx.template", database = "off", - plugins = "bundled,dbless-pagination-test", })) - print("helpers.start_kong") end) lazy_teardown(function() @@ -29,10 +42,11 @@ describe("dbless pagination #off", function() end) it("Routes", function() - local buffer = {"_format_version: '3.0'", "services:"} - for i = 1, 1001 do + local buffer = {"_format_version: '3.0'", POST_FUNC, "services:"} + for i = 1, COUNT 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()) @@ -45,5 +59,13 @@ describe("dbless pagination #off", function() assert.res_status(201, res) admin_client:close() + assert(helpers.restart_kong({ + database = "off", + })) + + local proxy_client = assert(helpers.proxy_client()) + + res = assert(proxy_client:get("/1", { headers = { host = "example1.dev" } })) + assert.res_status(401, res) end) end) diff --git a/spec/fixtures/custom_plugins/kong/plugins/dbless-pagination-test/handler.lua b/spec/fixtures/custom_plugins/kong/plugins/dbless-pagination-test/handler.lua deleted file mode 100644 index ef6f25cc3fde..000000000000 --- a/spec/fixtures/custom_plugins/kong/plugins/dbless-pagination-test/handler.lua +++ /dev/null @@ -1,22 +0,0 @@ --- The test case 04-client_ipc_spec.lua will load this plugin and check its --- generated error logs. - -local LmdbPaginationTestHandler = { - VERSION = "1.0", - PRIORITY = 1000, -} - - -local function test() - local db = kong.db - - assert(db.routes.pagination.max_page_size == 2048) -end - - -function LmdbPaginationTestHandler:init_worker() - ngx.timer.at(0, test) -end - - -return LmdbPaginationTestHandler diff --git a/spec/fixtures/custom_plugins/kong/plugins/dbless-pagination-test/schema.lua b/spec/fixtures/custom_plugins/kong/plugins/dbless-pagination-test/schema.lua deleted file mode 100644 index 8b6c80ad59e7..000000000000 --- a/spec/fixtures/custom_plugins/kong/plugins/dbless-pagination-test/schema.lua +++ /dev/null @@ -1,12 +0,0 @@ -return { - name = "dns-client-test", - fields = { - { - config = { - type = "record", - fields = { - }, - }, - }, - }, -}