Skip to content

Commit

Permalink
tests(db): reset the schema before bootstrapping when get_db_utils (#…
Browse files Browse the repository at this point in the history
…13808)

We have some tests that polluted schema after run.
This is to guarantee no leftover dirty schema for the follow-up tests which may not tolerate that.

KAG-5040
  • Loading branch information
Oyami-Srk authored Oct 30, 2024
1 parent 0aaa4e0 commit 13fb553
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 0 additions & 5 deletions spec/02-integration/03-db/08-declarative_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ for _, strategy in helpers.each_strategy() do
local _
_, db = helpers.get_db_utils(strategy)

-- This is a special case, where some DB states could be corrupted by DB truncation in `lazy_teardown()`.
-- We manually bootstrap the DB here to ensure the creation of a table is done correctly
db:schema_reset()
helpers.bootstrap_database(db)

_G.kong.db = db
assert(helpers.start_kong({
database = strategy,
Expand Down
4 changes: 4 additions & 0 deletions spec/internal/db.lua
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,10 @@ end

local function bootstrap_database(db)
local schema_state = assert(db:schema_state())

if schema_state.needs_bootstrap then
assert(db:schema_bootstrap())
schema_state = assert(db:schema_state())
end

if schema_state.new_migrations then
Expand Down Expand Up @@ -313,6 +315,8 @@ local function get_db_utils(strategy, tables, plugins, vaults, skip_migrations)
assert(db:init_connector())

if not skip_migrations then
-- Drop all schema and data
assert(db:schema_reset())
bootstrap_database(db)
end

Expand Down

1 comment on commit 13fb553

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bazel Build

Docker image available kong/kong:13fb5539ad5c3732cc1ce903a21e67d271646ada
Artifacts available https://github.com/Kong/kong/actions/runs/11589782801

Please sign in to comment.