From fe65e8ceb8c7fd5fc2d87bc1252c0fe4bbd91b0d Mon Sep 17 00:00:00 2001 From: Robin Xiang Date: Thu, 27 Apr 2023 16:08:57 +0800 Subject: [PATCH] chore(compatibility): This PR is to add a config compatibility test that should have been added in [#10400](https://github.com/Kong/kong/pull/10400) --- spec/01-unit/19-hybrid/03-compat_spec.lua | 56 +++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/spec/01-unit/19-hybrid/03-compat_spec.lua b/spec/01-unit/19-hybrid/03-compat_spec.lua index a0d98882631f..9dccf98f0bed 100644 --- a/spec/01-unit/19-hybrid/03-compat_spec.lua +++ b/spec/01-unit/19-hybrid/03-compat_spec.lua @@ -342,6 +342,62 @@ describe("kong.clustering.compat", function() end) end) + for _, strategy in helpers.each_strategy() do + describe("check compat for entities those have `updated_at` field", function() + local bp, db, entity_names + + setup(function() + -- excludes entities are not exported: clustering_data_planes, document_objects, files, + -- group_rbac_roles, groups, legacy_files, login_attempts, rbac_role_endpoints, + -- rbac_role_entities, rbac_roles, rbac_users + entity_names = { + "services", + "routes", + "ca_certificates", + "certificates", + "consumers", + "targets", + "upstreams", + "plugins", + "workspaces", + "snis", + } + + local plugins_enabled = { "key-auth" } + bp, db = helpers.get_db_utils(strategy, entity_names, plugins_enabled) + + for _, name in ipairs(entity_names) do + if name == "plugins" then + local plugin = { + name = "key-auth", + config = { + -- key_names has default value so we don't have to provide it + -- key_names = {} + } + } + bp[name]:insert(plugin) + elseif name == "routes" then + bp[name]:insert({ hosts = { "test1.test" }, }) + else + bp[name]:insert() + end + end + end) + + teardown(function() + for _, entity_name in ipairs(entity_names) do + db[entity_name]:truncate() + end + end) + + it(function() + local config = { config_table = declarative.export_config() } + local has_update = compat.update_compatible_payload(config, "3.0.0", "test_") + assert.truthy(has_update) + end) + end) + end + describe("core entities compatible changes", function() local config, db