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 and fffonion committed Nov 12, 2024
1 parent 37bb7bf commit aacbe7b
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 @@ -69,9 +69,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 @@ -832,13 +831,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 @@ -1708,5 +1701,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 @@ -13,9 +13,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 @@ -523,13 +522,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 @@ -794,5 +787,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 @@ -12,9 +12,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 @@ -397,13 +396,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 @@ -636,5 +629,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 @@ -12,9 +12,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 @@ -415,13 +414,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 @@ -663,5 +656,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 @@ -12,9 +12,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 @@ -351,13 +350,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 @@ -526,4 +519,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 @@ -12,10 +12,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 @@ -200,13 +199,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 @@ -457,5 +450,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 @@ -117,9 +117,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 @@ -249,13 +248,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 @@ -383,4 +376,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 @@ -14,9 +14,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 @@ -508,13 +507,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 @@ -826,4 +819,3 @@ for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then
end)

end end
end -- for _, client_protocol

0 comments on commit aacbe7b

Please sign in to comment.