Skip to content

Commit

Permalink
tests(clustering/rpc): fix ee tests for inc sync (#10539)
Browse files Browse the repository at this point in the history
* tests(rbac): fix 01-rbac/01-rbac_spec.lua (#10463)

* db(dao/workspaces): check kong.conf in select_by_name

* fix 01-rbac/01-rbac_spec.lua

* tests(keyring): pagesize must not be less than 2 (#10462)

* (keyring): pagesize must not be less than 2

* comments

* math.max

* fix(*): remove hardcoded size 1000 from :each interface call (#10480)

* set ws_id nil in tests (#10488)

* fix(incremental sync): fix bug that CP generates entity without expanding foreigns (#10526)

* fix(incremental sync): fix bug that CP generates entity without expanding foreigns

* added XXX EE only

* chore: fallback workspace (#10469)

* remove field_ws_id

* Revert "remove field_ws_id"

This reverts commit 880f5dac107364c7df9800b910631ce1c94451b2.

---------

Co-authored-by: Xiaochen Wang <wangxiaochen0@gmail.com>
  • Loading branch information
2 people authored and bungle committed Nov 7, 2024
1 parent dc832f0 commit bda6173
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 11 deletions.
3 changes: 2 additions & 1 deletion kong/db/declarative/export.lua
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,8 @@ end


local function export_config_sync()
return export_from_db_impl(sync_emitter.new(), false, false, true)
-- XXX EE: has extra parameter @skip_ttl
return export_from_db_impl(sync_emitter.new(), false, false, false, true)
end


Expand Down
9 changes: 8 additions & 1 deletion kong/db/declarative/import.lua
Original file line number Diff line number Diff line change
Expand Up @@ -439,10 +439,17 @@ end
-- _transform: true,
-- }
local function load_into_cache(entities, meta, hash)
meta = meta or {}

local default_workspace_id = assert(find_ws(entities, "default"))
local should_transform = meta._transform == nil and true or meta._transform

local fallback_workspace = meta._workspace -- XXX EE
and find_ws(entities, meta._workspace)
or default_workspace_id

assert(type(default_workspace_id) == "string")
assert(type(fallback_workspace) == "string")

-- set it for insert_entity_for_txn()
kong.default_workspace = default_workspace_id
Expand Down Expand Up @@ -470,7 +477,7 @@ local function load_into_cache(entities, meta, hash)

for _, item in pairs(items) do
if not schema.workspaceable or item.ws_id == null or item.ws_id == nil then
item.ws_id = default_workspace_id
item.ws_id = fallback_workspace -- XXX EE
end

assert(type(item.ws_id) == "string")
Expand Down
3 changes: 2 additions & 1 deletion kong/enterprise_edition/counters/sales/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ local function get_plugins_count()
["kafka-upstream"] = 0,
}

for plugin, err in kong.db.plugins:each(1000, GLOBAL_QUERY_OPTS) do
-- like each(page_size,)
for plugin, err in kong.db.plugins:each(nil, GLOBAL_QUERY_OPTS) do
if err then
kong.log.err("failed to list plugins: ", err)
return nil
Expand Down
2 changes: 1 addition & 1 deletion kong/enterprise_edition/tls/plugins/sni_filter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ local function each_enabled_plugin(entity, plugin_name)
}
}

local iter = entity:each(1000, options)
local iter = entity:each(nil, options) -- like each(page_size,)
local function iterator()
local element, err = iter()
if err then return nil, err end
Expand Down
2 changes: 1 addition & 1 deletion kong/keyring/strategies/cluster.lua
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ function _M.init(config)

load_envelope_keys(config)

local r, err = kong.db.keyring_meta:each(1)
local r, err = kong.db.keyring_meta:each()
if err then
error(err)
end
Expand Down
2 changes: 1 addition & 1 deletion kong/plugins/acme/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ local ngx_timer_at = ngx.timer.at
local ngx_re_match = ngx.re.match

local function find_plugin()
for plugin, err in kong.db.plugins:each(1000) do
for plugin, err in kong.db.plugins:each() do -- like each(page_size)
if err then
return nil, err
end
Expand Down
2 changes: 1 addition & 1 deletion kong/plugins/ai-semantic-cache/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ local SEMANTIC_CACHE_NAMESPACE_PREFIX = "kong_semantic_cache:"


local function each_by_name(entity, name)
local iter = entity:each(1000)
local iter = entity:each() -- like each(page_size)
local function iterator()
local element, err = iter()
if err then return nil, err end
Expand Down
2 changes: 1 addition & 1 deletion kong/plugins/degraphql/handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function DeGraphQLHandler:update_router(force)

local routers = {}

for route, err in kong.db.degraphql_routes:each(1000) do
for route, err in kong.db.degraphql_routes:each() do -- like each(page_size)
if err then
kong.log.err("Degraphql plugin could not load routes: ", err)
-- Break when error and try again on the next update_router
Expand Down
2 changes: 1 addition & 1 deletion kong/plugins/graphql-proxy-cache-advanced/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ end


local function each_by_name(entity, name)
local iter = entity:each(1000)
local iter = entity:each() -- like each(page_size)
local function iterator()
local element, err = iter()
if err then return nil, err end
Expand Down
2 changes: 1 addition & 1 deletion kong/plugins/proxy-cache-advanced/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ end


local function each_by_name(entity, name)
local iter = entity:each(1000)
local iter = entity:each() -- like each(page_size)
local function iterator()
local element, err = iter()
if err then return nil, err end
Expand Down
4 changes: 3 additions & 1 deletion spec-ee/02-integration/01-rbac/01-rbac_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,9 @@ for _, strategy in spec_helpers.each_strategy() do
end)
describe("check_cascade", function()
local entities
local old_conf
setup(function()
old_conf = kong.configuration
kong.configuration= {
rbac = "both",
}
Expand Down Expand Up @@ -703,7 +705,7 @@ for _, strategy in spec_helpers.each_strategy() do
}
end)
teardown(function()
kong.configuration = nil
kong.configuration = old_conf
end)

it("all entities allowed", function()
Expand Down
1 change: 1 addition & 0 deletions spec/02-integration/04-admin_api/15-off_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,7 @@ describe("Admin API #off", function()
local config = assert(lyaml.load(json.config))
config.workspaces[1].id = "<uuid>" -- see below
config.workspaces[1].created_at = 12345 -- see below
config.workspaces[1].ws_id = nil -- see below
config.consumers[1].ws_id = "<uuid>" -- see below
assert:set_parameter("TableFormatLevel", -1)
assert.same({
Expand Down

0 comments on commit bda6173

Please sign in to comment.