From e3b5220b1123e78b56fd3a84604d2c78cfa2d504 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 d7545a856ab0..806d83dd21e0 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 @@ -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() @@ -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) @@ -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 \ 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 395beb83f841..9f2b9f1739f6 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 @@ -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() @@ -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() @@ -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 \ 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 09f1f5849d83..9fc3ef37ddfa 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 @@ -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 }) @@ -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() @@ -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 \ 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 c6d8a9f5a51b..4fbecfa0caaf 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 @@ -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() @@ -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() @@ -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 \ 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 215c4bba764d..f45d16058ae4 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 @@ -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() @@ -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() @@ -519,4 +512,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 b998e0b987f9..e85fda29a086 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 @@ -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() @@ -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() @@ -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 \ 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 3e2c2537d2da..7ce516f9a6e9 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 @@ -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() @@ -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() @@ -376,4 +369,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 841eb36949eb..c71e9153fb0e 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 @@ -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() @@ -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() @@ -819,4 +812,3 @@ for _, strategy in helpers.all_strategies() do if strategy ~= "cassandra" then end) end end -end -- for _, client_protocol