diff --git a/spec/02-integration/18-hybrid_rpc/01-rpc_spec.lua b/spec/02-integration/18-hybrid_rpc/01-rpc_spec.lua index 6b717e293cbf..8f670a0388e1 100644 --- a/spec/02-integration/18-hybrid_rpc/01-rpc_spec.lua +++ b/spec/02-integration/18-hybrid_rpc/01-rpc_spec.lua @@ -2,10 +2,9 @@ local helpers = require "spec.helpers" local cjson = require("cjson.safe") local CLUSTERING_SYNC_STATUS = require("kong.constants").CLUSTERING_SYNC_STATUS --- we need incremental sync to verify rpc -for _, inc_sync in ipairs { "on" } do +-- register a test rpc service in custom plugin rpc-hello-test for _, strategy in helpers.each_strategy() do - describe("Hybrid Mode RPC #" .. strategy .. " inc_sync=" .. inc_sync, function() + describe("Hybrid Mode RPC #" .. strategy, function() lazy_setup(function() helpers.get_db_utils(strategy, { @@ -20,7 +19,8 @@ for _, strategy in helpers.each_strategy() do cluster_listen = "127.0.0.1:9005", nginx_conf = "spec/fixtures/custom_nginx.template", cluster_rpc = "on", - cluster_incremental_sync = inc_sync, -- incremental sync + plugins = "bundled,rpc-hello-test", + cluster_incremental_sync = "off", })) assert(helpers.start_kong({ @@ -33,7 +33,8 @@ for _, strategy in helpers.each_strategy() do proxy_listen = "0.0.0.0:9002", nginx_conf = "spec/fixtures/custom_nginx.template", cluster_rpc = "on", - cluster_incremental_sync = inc_sync, -- incremental sync + plugins = "bundled,rpc-hello-test", + cluster_incremental_sync = "off", })) end) @@ -69,9 +70,13 @@ for _, strategy in helpers.each_strategy() do assert(tonumber(m[2]) >= 9) -- check the available rpc service - table.sort(v.rpc_capabilities) - assert.same("kong.sync.v2", v.rpc_capabilities[1]) - return true + for _, c in ipairs(v.rpc_capabilities) do + if c == "kong.test" then + return true + end + end + + return false end end end, 10) @@ -79,4 +84,3 @@ for _, strategy in helpers.each_strategy() do end) end) end -- for _, strategy -end -- for inc_sync diff --git a/spec/02-integration/18-hybrid_rpc/04-concentrator_spec.lua b/spec/02-integration/18-hybrid_rpc/04-concentrator_spec.lua index f88e0bba8aa1..445bcee6ec12 100644 --- a/spec/02-integration/18-hybrid_rpc/04-concentrator_spec.lua +++ b/spec/02-integration/18-hybrid_rpc/04-concentrator_spec.lua @@ -28,10 +28,9 @@ local function obtain_dp_node_id() -- luacheck: ignore end --- we need incremental sync to verify rpc -for _, inc_sync in ipairs { "on" } do +-- register a test rpc service in custom plugin rpc-hello-test for _, strategy in helpers.each_strategy() do - describe("Hybrid Mode RPC over DB concentrator #" .. strategy .. " inc_sync=" .. inc_sync, function() + describe("Hybrid Mode RPC over DB concentrator #" .. strategy, function() lazy_setup(function() helpers.get_db_utils(strategy, { @@ -47,7 +46,8 @@ for _, strategy in helpers.each_strategy() do admin_listen = "127.0.0.1:" .. helpers.get_available_port(), nginx_conf = "spec/fixtures/custom_nginx.template", cluster_rpc = "on", - cluster_incremental_sync = inc_sync, -- incremental sync + plugins = "bundled,rpc-hello-test", + cluster_incremental_sync = "off", })) assert(helpers.start_kong({ @@ -59,7 +59,8 @@ for _, strategy in helpers.each_strategy() do cluster_listen = "127.0.0.1:" .. helpers.get_available_port(), nginx_conf = "spec/fixtures/custom_nginx.template", cluster_rpc = "on", - cluster_incremental_sync = inc_sync, -- incremental sync + plugins = "bundled,rpc-hello-test", + cluster_incremental_sync = "off", })) assert(helpers.start_kong({ @@ -72,7 +73,8 @@ for _, strategy in helpers.each_strategy() do proxy_listen = "0.0.0.0:9002", nginx_conf = "spec/fixtures/custom_nginx.template", cluster_rpc = "on", - cluster_incremental_sync = inc_sync, -- incremental sync + plugins = "bundled,rpc-hello-test", + cluster_incremental_sync = "off", })) end) @@ -87,4 +89,3 @@ for _, strategy in helpers.each_strategy() do --end) end) end -- for _, strategy -end -- for inc_sync diff --git a/spec/fixtures/custom_plugins/kong/plugins/rpc-hello-test/handler.lua b/spec/fixtures/custom_plugins/kong/plugins/rpc-hello-test/handler.lua new file mode 100644 index 000000000000..7ef7af7a4da4 --- /dev/null +++ b/spec/fixtures/custom_plugins/kong/plugins/rpc-hello-test/handler.lua @@ -0,0 +1,14 @@ +local RpcHelloTestHandler = { + VERSION = "1.0", + PRIORITY = 1000, +} + + +function RpcHelloTestHandler:init_worker() + kong.rpc.callbacks:register("kong.test.hello", function(node_id, greeting) + return "hello ".. greeting + end) +end + + +return RpcHelloTestHandler diff --git a/spec/fixtures/custom_plugins/kong/plugins/rpc-hello-test/schema.lua b/spec/fixtures/custom_plugins/kong/plugins/rpc-hello-test/schema.lua new file mode 100644 index 000000000000..a11e24948267 --- /dev/null +++ b/spec/fixtures/custom_plugins/kong/plugins/rpc-hello-test/schema.lua @@ -0,0 +1,12 @@ +return { + name = "rpc-hello-test", + fields = { + { + config = { + type = "record", + fields = { + }, + }, + }, + }, +}