Skip to content

Commit

Permalink
test(ai-proxy): fix red test due to other feature break http protocol…
Browse files Browse the repository at this point in the history
… behavior (#13848)
  • Loading branch information
oowl authored Nov 7, 2024
1 parent 713908f commit e3b5220
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 85 deletions.
14 changes: 3 additions & 11 deletions spec/03-plugins/38-ai-proxy/02-openai_integration_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ local _EXPECTED_CHAT_STATS = {
},
}

for _, client_protocol in ipairs({ "http", "https", "http2" }) do
for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then
describe(PLUGIN_NAME .. ": (access) [#" .. strategy .. "] [#" .. client_protocol .. "]", function()
describe(PLUGIN_NAME .. ": (access) [#" .. strategy .. "]", function()
local client

lazy_setup(function()
Expand Down Expand Up @@ -826,13 +825,7 @@ for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then
end)

before_each(function()
if client_protocol == "http" then
client = helpers.proxy_client()
elseif client_protocol == "https" then
client = helpers.proxy_ssl_client()
elseif client_protocol == "http2" then
client = helpers.proxy_ssl_client(nil, nil, 2)
end
client = helpers.proxy_client()
-- Note: if file is removed instead of trunacted, file-log ends writing to a unlinked file handle
truncate_file(FILE_LOG_PATH_STATS_ONLY)
truncate_file(FILE_LOG_PATH_NO_LOGS)
Expand Down Expand Up @@ -1701,5 +1694,4 @@ for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then
end)
end)

end end
end -- for _, client_protocol
end end
14 changes: 3 additions & 11 deletions spec/03-plugins/38-ai-proxy/03-anthropic_integration_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ local deepcompare = require("pl.tablex").deepcompare
local PLUGIN_NAME = "ai-proxy"
local MOCK_PORT = helpers.get_available_port()

for _, client_protocol in ipairs({ "http", "https", "http2" }) do
for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then
describe(PLUGIN_NAME .. ": (access) [#" .. strategy .. "] [#" .. client_protocol .. "]", function()
describe(PLUGIN_NAME .. ": (access) [#" .. strategy .. "]", function()
local client

lazy_setup(function()
Expand Down Expand Up @@ -516,13 +515,7 @@ for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then
end)

before_each(function()
if client_protocol == "http" then
client = helpers.proxy_client()
elseif client_protocol == "https" then
client = helpers.proxy_ssl_client()
elseif client_protocol == "http2" then
client = helpers.proxy_ssl_client(nil, nil, true)
end
client = helpers.proxy_client()
end)

after_each(function()
Expand Down Expand Up @@ -787,5 +780,4 @@ for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then
end)
end)

end end
end -- for _, client_protocol
end end
14 changes: 3 additions & 11 deletions spec/03-plugins/38-ai-proxy/04-cohere_integration_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ local pl_file = require "pl.file"
local PLUGIN_NAME = "ai-proxy"
local MOCK_PORT = helpers.get_available_port()

for _, client_protocol in ipairs({ "http", "https", "http2" }) do
for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then
describe(PLUGIN_NAME .. ": (access) [#" .. strategy .. "] [#" .. client_protocol .. "]", function() local client
describe(PLUGIN_NAME .. ": (access) [#" .. strategy .. "]", function() local client

lazy_setup(function()
local bp = helpers.get_db_utils(strategy == "off" and "postgres" or strategy, nil, { PLUGIN_NAME })
Expand Down Expand Up @@ -390,13 +389,7 @@ for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then
end)

before_each(function()
if client_protocol == "http" then
client = helpers.proxy_client()
elseif client_protocol == "https" then
client = helpers.proxy_ssl_client()
elseif client_protocol == "http2" then
client = helpers.proxy_ssl_client(nil, nil, 2)
end
client = helpers.proxy_client()
end)

after_each(function()
Expand Down Expand Up @@ -629,5 +622,4 @@ for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then
end)
end)

end end
end -- for _, client_protocol
end end
14 changes: 3 additions & 11 deletions spec/03-plugins/38-ai-proxy/05-azure_integration_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ local pl_file = require "pl.file"
local PLUGIN_NAME = "ai-proxy"
local MOCK_PORT = helpers.get_available_port()

for _, client_protocol in ipairs({ "http", "https", "http2" }) do
for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then
describe(PLUGIN_NAME .. ": (access) [#" .. strategy .. "] [#" .. client_protocol .. "]", function()
describe(PLUGIN_NAME .. ": (access) [#" .. strategy .. "]", function()
local client

lazy_setup(function()
Expand Down Expand Up @@ -408,13 +407,7 @@ for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then
end)

before_each(function()
if client_protocol == "http" then
client = helpers.proxy_client()
elseif client_protocol == "https" then
client = helpers.proxy_ssl_client()
elseif client_protocol == "http2" then
client = helpers.proxy_ssl_client(nil, nil, 2)
end
client = helpers.proxy_client()
end)

after_each(function()
Expand Down Expand Up @@ -656,5 +649,4 @@ for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then
end)
end)

end end
end -- for _, client_protocol
end end
12 changes: 2 additions & 10 deletions spec/03-plugins/38-ai-proxy/06-mistral_integration_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ local pl_file = require "pl.file"
local PLUGIN_NAME = "ai-proxy"
local MOCK_PORT = helpers.get_available_port()

for _, client_protocol in ipairs({ "http", "https", "http2" }) do
for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then
describe(PLUGIN_NAME .. ": (access) [#" .. strategy .. "] [#" .. client_protocol .. "]", function()
describe(PLUGIN_NAME .. ": (access) [#" .. strategy .. "]", function()
local client

lazy_setup(function()
Expand Down Expand Up @@ -344,13 +343,7 @@ for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then
end)

before_each(function()
if client_protocol == "http" then
client = helpers.proxy_client()
elseif client_protocol == "https" then
client = helpers.proxy_ssl_client()
elseif client_protocol == "http2" then
client = helpers.proxy_ssl_client(nil, nil, 2)
end
client = helpers.proxy_client()
end)

after_each(function()
Expand Down Expand Up @@ -519,4 +512,3 @@ for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then
end)

end end
end -- for _, client_protocol
14 changes: 3 additions & 11 deletions spec/03-plugins/38-ai-proxy/07-llama2_integration_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ local pl_file = require "pl.file"
local PLUGIN_NAME = "ai-proxy"
local MOCK_PORT = helpers.get_available_port()

for _, client_protocol in ipairs({ "http", "https", "http2" }) do

for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then
describe(PLUGIN_NAME .. ": (access) [#" .. strategy .. "] [#" .. client_protocol .. "]", function()
describe(PLUGIN_NAME .. ": (access) [#" .. strategy .. "]", function()
local client

lazy_setup(function()
Expand Down Expand Up @@ -193,13 +192,7 @@ for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then
end)

before_each(function()
if client_protocol == "http" then
client = helpers.proxy_client()
elseif client_protocol == "https" then
client = helpers.proxy_ssl_client()
elseif client_protocol == "http2" then
client = helpers.proxy_ssl_client(nil, nil, 2)
end
client = helpers.proxy_client()
end)

after_each(function()
Expand Down Expand Up @@ -450,5 +443,4 @@ for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then
end)
end)

end end
end -- for _, client_protocol
end end
12 changes: 2 additions & 10 deletions spec/03-plugins/38-ai-proxy/08-encoding_integration_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,8 @@ local plugin_conf = {
},
}

for _, client_protocol in ipairs({ "http", "https", "http2" }) do
for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then
describe(PLUGIN_NAME .. ": (access) [#" .. strategy .. "] [#" .. client_protocol .. "]", function()
describe(PLUGIN_NAME .. ": (access) [#" .. strategy .. "]", function()
local client

lazy_setup(function()
Expand Down Expand Up @@ -242,13 +241,7 @@ for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then
end)

before_each(function()
if client_protocol == "http" then
client = helpers.proxy_client()
elseif client_protocol == "https" then
client = helpers.proxy_ssl_client()
elseif client_protocol == "http2" then
client = helpers.proxy_ssl_client(nil, nil, 2)
end
client = helpers.proxy_client()
end)

after_each(function()
Expand Down Expand Up @@ -376,4 +369,3 @@ for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then
----

end end
end -- for _, client_protocol
12 changes: 2 additions & 10 deletions spec/03-plugins/38-ai-proxy/09-streaming_integration_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ local http = require("resty.http")
local PLUGIN_NAME = "ai-proxy"
local MOCK_PORT = helpers.get_available_port()

for _, client_protocol in ipairs({ "http", "https", "http2" }) do
for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then
describe(PLUGIN_NAME .. ": (access) [#" .. strategy .. "] [#" .. client_protocol .. "]", function()
describe(PLUGIN_NAME .. ": (access) [#" .. strategy .. "]", function()
local client

lazy_setup(function()
Expand Down Expand Up @@ -501,13 +500,7 @@ for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then
end)

before_each(function()
if client_protocol == "http" then
client = helpers.proxy_client()
elseif client_protocol == "https" then
client = helpers.proxy_ssl_client()
elseif client_protocol == "http2" then
client = helpers.proxy_ssl_client(nil, nil, 2)
end
client = helpers.proxy_client()
end)

after_each(function()
Expand Down Expand Up @@ -819,4 +812,3 @@ for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then
end)

end end
end -- for _, client_protocol

1 comment on commit e3b5220

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bazel Build

Docker image available kong/kong:e3b5220b1123e78b56fd3a84604d2c78cfa2d504
Artifacts available https://github.com/Kong/kong/actions/runs/11730821877

Please sign in to comment.