Skip to content
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

tests(clustering/rpc): more cases for deltas validation #14243

Merged
merged 3 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion kong/clustering/services/sync/validate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ local pretty_print_error = declarative.pretty_print_error
local function validate_deltas(deltas, is_full_sync)

local errs = {}
local errs_n = 0

-- generate deltas table mapping primary key string to entity item
local deltas_map = {}
Expand Down Expand Up @@ -45,7 +46,8 @@ local function validate_deltas(deltas, is_full_sync)

local ok, err_t = dao.schema:validate(copy)
if not ok then
errs[#errs + 1] = { [delta_type] = err_t }
errs_n = errs_n + 1
errs[errs_n] = { [delta_type] = err_t }
end
end
end
Expand Down
10 changes: 10 additions & 0 deletions spec/02-integration/18-hybrid_rpc/10-validate_deltas_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,18 @@ for _, strategy in helpers.each_strategy() do
"[error]", true, 10)
assert.logfile(name).has.line(
"unable to create worker mutex and sync", true, 10)

assert.logfile(name).has.line(
"'name': required field missing", true, 10)
assert.logfile(name).has.line(
"'meta': expected a record", true, 10)
assert.logfile(name).has.line(
"'config': expected a record", true, 10)

assert.logfile(name).has.line(
"'key': expected a string", true, 10)
assert.logfile(name).has.line(
"'value': expected a string", true, 10)

local name = nil

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,22 @@ function RpcSyncV2ValidationHandler:init_worker()
{
entity = {
id = fake_uuid,
meta = "wrong", -- should be a record,
config = 100, -- should be a record,
},
type = "workspaces",
version = latest_version,
ws_id = fake_uuid,
},
{
entity = {
key = 100, -- should be a string
value = {}, -- should be a string
},
type = "parameters",
version = latest_version,
ws_id = fake_uuid,
},
}

ngx.log(ngx.DEBUG, "kong.sync.v2.get_delta ok")
Expand Down
Loading