From aacbe7ba32565c31acb67bb3fdece6b2e766a090 Mon Sep 17 00:00:00 2001 From: Jun Ouyang Date: Fri, 8 Nov 2024 04:30:39 +0800 Subject: [PATCH] test(ai-proxy): fix red test due to other feature break http protocol behavior (#13848) --- .../38-ai-proxy/02-openai_integration_spec.lua | 14 +++----------- .../38-ai-proxy/03-anthropic_integration_spec.lua | 14 +++----------- .../38-ai-proxy/04-cohere_integration_spec.lua | 14 +++----------- .../38-ai-proxy/05-azure_integration_spec.lua | 14 +++----------- .../38-ai-proxy/06-mistral_integration_spec.lua | 12 ++---------- .../38-ai-proxy/07-llama2_integration_spec.lua | 14 +++----------- .../38-ai-proxy/08-encoding_integration_spec.lua | 12 ++---------- .../38-ai-proxy/09-streaming_integration_spec.lua | 12 ++---------- 8 files changed, 21 insertions(+), 85 deletions(-) diff --git a/spec/03-plugins/38-ai-proxy/02-openai_integration_spec.lua b/spec/03-plugins/38-ai-proxy/02-openai_integration_spec.lua index 17cad9c2cd24..9633989997be 100644 --- a/spec/03-plugins/38-ai-proxy/02-openai_integration_spec.lua +++ b/spec/03-plugins/38-ai-proxy/02-openai_integration_spec.lua @@ -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() @@ -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) @@ -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 \ No newline at end of file diff --git a/spec/03-plugins/38-ai-proxy/03-anthropic_integration_spec.lua b/spec/03-plugins/38-ai-proxy/03-anthropic_integration_spec.lua index 57e1736b4228..0afcc632f629 100644 --- a/spec/03-plugins/38-ai-proxy/03-anthropic_integration_spec.lua +++ b/spec/03-plugins/38-ai-proxy/03-anthropic_integration_spec.lua @@ -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() @@ -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() @@ -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 \ No newline at end of file diff --git a/spec/03-plugins/38-ai-proxy/04-cohere_integration_spec.lua b/spec/03-plugins/38-ai-proxy/04-cohere_integration_spec.lua index 1df3fa9c1a6f..9b38b9626ce5 100644 --- a/spec/03-plugins/38-ai-proxy/04-cohere_integration_spec.lua +++ b/spec/03-plugins/38-ai-proxy/04-cohere_integration_spec.lua @@ -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 }) @@ -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() @@ -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 \ No newline at end of file diff --git a/spec/03-plugins/38-ai-proxy/05-azure_integration_spec.lua b/spec/03-plugins/38-ai-proxy/05-azure_integration_spec.lua index dc2c34b31cfa..984b039d4700 100644 --- a/spec/03-plugins/38-ai-proxy/05-azure_integration_spec.lua +++ b/spec/03-plugins/38-ai-proxy/05-azure_integration_spec.lua @@ -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() @@ -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() @@ -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 \ No newline at end of file diff --git a/spec/03-plugins/38-ai-proxy/06-mistral_integration_spec.lua b/spec/03-plugins/38-ai-proxy/06-mistral_integration_spec.lua index b80bf0a1e079..b4a322f0c3dd 100644 --- a/spec/03-plugins/38-ai-proxy/06-mistral_integration_spec.lua +++ b/spec/03-plugins/38-ai-proxy/06-mistral_integration_spec.lua @@ -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() @@ -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() @@ -526,4 +519,3 @@ for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then end) end end -end -- for _, client_protocol diff --git a/spec/03-plugins/38-ai-proxy/07-llama2_integration_spec.lua b/spec/03-plugins/38-ai-proxy/07-llama2_integration_spec.lua index be18d3b1fb1a..ac15b44ec5a4 100644 --- a/spec/03-plugins/38-ai-proxy/07-llama2_integration_spec.lua +++ b/spec/03-plugins/38-ai-proxy/07-llama2_integration_spec.lua @@ -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() @@ -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() @@ -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 \ No newline at end of file diff --git a/spec/03-plugins/38-ai-proxy/08-encoding_integration_spec.lua b/spec/03-plugins/38-ai-proxy/08-encoding_integration_spec.lua index 97dea7fcc609..756dc12b2a94 100644 --- a/spec/03-plugins/38-ai-proxy/08-encoding_integration_spec.lua +++ b/spec/03-plugins/38-ai-proxy/08-encoding_integration_spec.lua @@ -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() @@ -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() @@ -383,4 +376,3 @@ for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then ---- end end -end -- for _, client_protocol diff --git a/spec/03-plugins/38-ai-proxy/09-streaming_integration_spec.lua b/spec/03-plugins/38-ai-proxy/09-streaming_integration_spec.lua index 5bbe947d3cc3..4445e48efeb7 100644 --- a/spec/03-plugins/38-ai-proxy/09-streaming_integration_spec.lua +++ b/spec/03-plugins/38-ai-proxy/09-streaming_integration_spec.lua @@ -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() @@ -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() @@ -826,4 +819,3 @@ for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then end) end end -end -- for _, client_protocol