From f92275481d44744d6d9baee513f87dbdbdf192c6 Mon Sep 17 00:00:00 2001 From: chronolaw Date: Fri, 10 May 2024 11:34:51 +0800 Subject: [PATCH] tests(db/declarative): fix corrupted parameters table --- .../03-db/08-declarative_spec.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/spec/02-integration/03-db/08-declarative_spec.lua b/spec/02-integration/03-db/08-declarative_spec.lua index 8e7480af5ef..cb83ef64e99 100644 --- a/spec/02-integration/03-db/08-declarative_spec.lua +++ b/spec/02-integration/03-db/08-declarative_spec.lua @@ -195,6 +195,22 @@ for _, strategy in helpers.each_strategy() do password = crypto.hash(consumer_def.id, "MI6"), } + local function ensure_cluster_id_exists() + local res = db.parameters:select({ key = "cluster_id", }) + + -- table is broken for some unknown reason + if not res then + db.connector:query( + "BEGIN;\n" .. + "INSERT INTO parameters (key, value) VALUES('cluster_id', 'fake-cluster-id');" .. + "COMMIT;\n" + ) + end + + res = db.parameters:select({ key = "cluster_id", }) + assert(res and res.value) + end + before_each(function() db.acls:truncate() db.basicauth_credentials:truncate() @@ -205,6 +221,8 @@ for _, strategy in helpers.each_strategy() do db.certificates:truncate() db.consumers:truncate() + ensure_cluster_id_exists() + assert(declarative.load_into_db({ snis = { [sni_def.id] = sni_def }, certificates = { [certificate_def.id] = certificate_def },