From 08deb580bdd5a45b6ab7d29334da43b863371e53 Mon Sep 17 00:00:00 2001 From: chronolaw Date: Thu, 5 Sep 2024 06:51:54 +0800 Subject: [PATCH] get_dcbp & get_plugins_list --- spec/details/db.lua | 17 +++++++++++++++-- spec/helpers.lua | 11 ++++------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/spec/details/db.lua b/spec/details/db.lua index 860ad026aa15a..06249570e992d 100644 --- a/spec/details/db.lua +++ b/spec/details/db.lua @@ -352,16 +352,29 @@ local function get_cache(db) end +local function get_dcbp() + return dcbp +end + + +local function get_plugins_list() + return PLUGINS_LIST +end + + return { - PLUGINS_LIST = PLUGINS_LIST, + --PLUGINS_LIST = PLUGINS_LIST, db = db, blueprints = blueprints, - dcbp = dcbp, + --dcbp = dcbp, get_cache = get_cache, get_db_utils = get_db_utils, + get_dcbp = get_dcbp, + get_plugins_list = get_plugins_list, + truncate_tables = truncate_tables, bootstrap_database = bootstrap_database, diff --git a/spec/helpers.lua b/spec/helpers.lua index 1c803bd99900b..1e2ac2fb409ea 100644 --- a/spec/helpers.lua +++ b/spec/helpers.lua @@ -103,11 +103,6 @@ end --------------- local config_yml -local PLUGINS_LIST = DB.PLUGINS_LIST -local db = DB.db -local dcbp = DB.dcbp -local truncate_tables = DB.truncate_tables - ----------------- -- Custom helpers ----------------- @@ -3225,7 +3220,7 @@ local function start_kong(env, tables, preserve_prefix, fixtures) local ok, err = prepare_prefix(prefix) if not ok then return nil, err end - truncate_tables(db, tables) + DB.truncate_tables(DB.db, tables) local nginx_conf = "" local nginx_conf_flags = { "test" } @@ -3244,6 +3239,7 @@ local function start_kong(env, tables, preserve_prefix, fixtures) nginx_conf_flags = "" end + local dcbp = DB.get_dcbp() if dcbp and not env.declarative_config and not env.declarative_config_string then if not config_yml then config_yml = prefix .. "/config.yml" @@ -3547,7 +3543,7 @@ local function clustering_client(opts) end local payload = assert(cjson.encode({ type = "basic_info", plugins = opts.node_plugins_list or - PLUGINS_LIST, + DB.get_plugins_list(), labels = opts.node_labels, process_conf = opts.node_process_conf, })) @@ -3885,6 +3881,7 @@ end end, -- returns the plugins and version list that is used by Hybrid mode tests get_plugins_list = function() + local PLUGINS_LIST = DB.get_plugins_list() assert(PLUGINS_LIST, "plugin list has not been initialized yet, " .. "you must call get_db_utils first") return table_clone(PLUGINS_LIST)