From 26022859e09928e8cee9ee0fa5aafac96545f71a Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Tue, 28 May 2024 10:59:49 -0700 Subject: [PATCH 1/5] chore(wasm): testing Kong/ngx_wasm_module#546 --- .requirements | 2 +- kong/runloop/wasm.lua | 7 ------- spec/02-integration/20-wasm/01-admin-api_spec.lua | 4 ++++ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.requirements b/.requirements index 346d65fd07df..b2f129796733 100644 --- a/.requirements +++ b/.requirements @@ -21,7 +21,7 @@ ATC_ROUTER=ffd11db657115769bf94f0c4f915f98300bc26b6 # 1.6.2 SNAPPY=23b3286820105438c5dbb9bc22f1bb85c5812c8a # 1.2.0 KONG_MANAGER=nightly -NGX_WASM_MODULE=91d447ffd0e9bb08f11cc69d1aa9128ec36b4526 +NGX_WASM_MODULE=98c4572495b70470df5d00deae1cd6461d3aff8a WASMER=3.1.1 WASMTIME=19.0.0 V8=12.0.267.17 diff --git a/kong/runloop/wasm.lua b/kong/runloop/wasm.lua index af9bbc2cbae8..aa352927c9b8 100644 --- a/kong/runloop/wasm.lua +++ b/kong/runloop/wasm.lua @@ -945,13 +945,6 @@ function _M.attach(ctx) return kong.response.error(500) end end - - jit.off(proxy_wasm.start) - ok, err = proxy_wasm.start() - if not ok then - log(CRIT, "failed to execute ", chain.label, " filter chain for request: ", err) - return kong.response.error(500) - end end diff --git a/spec/02-integration/20-wasm/01-admin-api_spec.lua b/spec/02-integration/20-wasm/01-admin-api_spec.lua index 6ca6d75798c1..a613cfd2d14f 100644 --- a/spec/02-integration/20-wasm/01-admin-api_spec.lua +++ b/spec/02-integration/20-wasm/01-admin-api_spec.lua @@ -22,6 +22,8 @@ describe("wasm admin API [#" .. strategy .. "]", function() local service, route lazy_setup(function() + helpers.clean_prefix() + require("kong.runloop.wasm").enable({ { name = "tests", path = FILTER_PATH .. "/tests.wasm", @@ -547,6 +549,8 @@ describe("wasm admin API - wasm = off [#" .. strategy .. "]", function() local service lazy_setup(function() + helpers.clean_prefix() + bp, db = helpers.get_db_utils(strategy, { "routes", "services", From 380e758912f9d6114bce43dc4caf5b71cd57df50 Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Tue, 28 May 2024 11:47:31 -0700 Subject: [PATCH 2/5] tests: make things run faster --- .../20-wasm/04-proxy-wasm_spec.lua | 69 ++++++++++--------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/spec/02-integration/20-wasm/04-proxy-wasm_spec.lua b/spec/02-integration/20-wasm/04-proxy-wasm_spec.lua index ce637af87f6b..de19fdab8689 100644 --- a/spec/02-integration/20-wasm/04-proxy-wasm_spec.lua +++ b/spec/02-integration/20-wasm/04-proxy-wasm_spec.lua @@ -136,6 +136,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() database = strategy, nginx_conf = "spec/fixtures/custom_nginx.template", wasm = true, + wasm_filters = "tests", dns_hostsfile = hosts_file, plugins = "pre-function,post-function", })) @@ -152,7 +153,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() describe("runs a filter chain", function() it("with a single filter", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -166,7 +167,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() end) it("with multiple filters", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -182,7 +183,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() describe("filters can", function() it("add request headers", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -203,7 +204,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() end) it("remove request headers", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -223,7 +224,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() end) it("add response headers on_request_headers", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -243,7 +244,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() end) it("add response headers on_response_headers", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -266,7 +267,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() -- describe+it: -- "filters can NOT ..." it("NOT add response headers on_log", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -286,7 +287,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() pending("throw a trap", function() -- Used to work but now broken (obscure wasmtime SIGSEV), no clue - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -303,7 +304,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() end) pending("send a local response", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -322,7 +323,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() end) it("read kong.client.protocol", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -342,7 +343,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() end) it("read kong.nginx.subsystem", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -362,7 +363,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() end) it("read kong.node.id", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -382,7 +383,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() end) it("read kong.node.memory_stats", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -402,7 +403,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() end) it("read kong.request.forwarded_host", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -422,7 +423,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() end) it("read kong.request.forwarded_port", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -442,7 +443,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() end) it("read kong.request.forwarded_scheme", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -462,7 +463,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() end) pending("read kong.response.source", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -483,7 +484,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() end) it("read kong.router.route", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -504,7 +505,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() end) it("read kong.router.service", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -525,7 +526,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() end) it("write kong.service.target", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local target = helpers.mock_upstream_host .. ":" .. @@ -551,7 +552,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() -- target is being set to mock_upstream:15555 instead of -- 127.0.0.1:1555 as expected... pending("write kong.service.upstream", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -572,7 +573,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() end) it("write kong.service.request.scheme", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -591,7 +592,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() end) pending("read kong.service.response.status", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -612,7 +613,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() end) it("write kong.response.status", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -633,7 +634,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() end) it("read kong.configuration", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -653,7 +654,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() end) it("read kong.route_id", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -673,7 +674,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() end) it("read kong.service_id", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -693,7 +694,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() end) it("read kong.ctx.shared[]", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -715,7 +716,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() end) it("write kong.ctx.shared[]", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -737,7 +738,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() end) it("clear kong.ctx.shared[]", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -759,7 +760,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() end) it("send an http dispatch, return its response body", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -787,7 +788,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() end) pending("resolves DNS hostnames to send an http dispatch, return its response body", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -819,7 +820,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() pending("start on_tick background timer", function() -- Pending on internal ngx_wasm_module changes - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { @@ -837,7 +838,7 @@ describe("proxy-wasm filters (#wasm) (#" .. strategy .. ")", function() describe("behavior with", function() pending("multiple filters, one sends a local response", function() - local client = helpers.proxy_client() + local client = helpers.proxy_client(5000) finally(function() client:close() end) local res = assert(client:send { From 24fee0c17e8e35c571996bccc147ad6e6a74de09 Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Wed, 29 May 2024 09:35:09 -0700 Subject: [PATCH 3/5] update to latest sha --- .requirements | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.requirements b/.requirements index b2f129796733..03b78266e488 100644 --- a/.requirements +++ b/.requirements @@ -21,7 +21,7 @@ ATC_ROUTER=ffd11db657115769bf94f0c4f915f98300bc26b6 # 1.6.2 SNAPPY=23b3286820105438c5dbb9bc22f1bb85c5812c8a # 1.2.0 KONG_MANAGER=nightly -NGX_WASM_MODULE=98c4572495b70470df5d00deae1cd6461d3aff8a +NGX_WASM_MODULE=75e101780f09ade9a4bada0aa8340c0f6eb74f97 WASMER=3.1.1 WASMTIME=19.0.0 V8=12.0.267.17 From 1e2bd7e8b0e64119f88fa62a1171653ad727de96 Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Mon, 3 Jun 2024 10:16:29 -0700 Subject: [PATCH 4/5] update to latest commit --- .requirements | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.requirements b/.requirements index 03b78266e488..caa2bd3af196 100644 --- a/.requirements +++ b/.requirements @@ -21,7 +21,7 @@ ATC_ROUTER=ffd11db657115769bf94f0c4f915f98300bc26b6 # 1.6.2 SNAPPY=23b3286820105438c5dbb9bc22f1bb85c5812c8a # 1.2.0 KONG_MANAGER=nightly -NGX_WASM_MODULE=75e101780f09ade9a4bada0aa8340c0f6eb74f97 +NGX_WASM_MODULE=a7bb6a17dc8f0f82e2cb7e77c6e6f897e435ec1d WASMER=3.1.1 WASMTIME=19.0.0 V8=12.0.267.17 From 53ee6e57983a69cdaab234ddb6a3ee5d25683a64 Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Mon, 10 Jun 2024 11:34:47 -0700 Subject: [PATCH 5/5] update to da0bb1726cd82e8e21ea1f93645fe1b06c2e6a28 --- .requirements | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.requirements b/.requirements index caa2bd3af196..a499f0b54d86 100644 --- a/.requirements +++ b/.requirements @@ -21,7 +21,7 @@ ATC_ROUTER=ffd11db657115769bf94f0c4f915f98300bc26b6 # 1.6.2 SNAPPY=23b3286820105438c5dbb9bc22f1bb85c5812c8a # 1.2.0 KONG_MANAGER=nightly -NGX_WASM_MODULE=a7bb6a17dc8f0f82e2cb7e77c6e6f897e435ec1d +NGX_WASM_MODULE=da0bb1726cd82e8e21ea1f93645fe1b06c2e6a28 WASMER=3.1.1 WASMTIME=19.0.0 V8=12.0.267.17