-
-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: On tenant delete, remove replication slots (#781)
- Loading branch information
1 parent
11c512a
commit 387e25b
Showing
5 changed files
with
72 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,31 @@ | ||
defmodule Realtime.HelpersTest do | ||
use Realtime.DataCase, async: true | ||
use Realtime.DataCase, async: false | ||
# async: false due to the deletion of the replication slot potentially affecting other tests | ||
doctest Realtime.Helpers | ||
alias Realtime.Helpers | ||
|
||
describe "replication_slot_teardown/1" do | ||
setup do | ||
%{tenant: tenant_fixture()} | ||
end | ||
|
||
test "removes replication slots with the realtime prefix", %{tenant: tenant} do | ||
[extension] = tenant.extensions | ||
args = Map.put(extension.settings, "id", random_string()) | ||
{:ok, pid} = start_supervised({Extensions.PostgresCdcStream.Replication, args}) | ||
|
||
{:ok, conn} = Helpers.check_tenant_connection(tenant, "realtime_test") | ||
# Check replication slot was created | ||
assert %{rows: [["supabase_realtime_replication_slot"]]} = | ||
Postgrex.query!(conn, "SELECT slot_name FROM pg_replication_slots", []) | ||
|
||
# Kill connections to database | ||
Process.exit(pid, :normal) | ||
Process.exit(conn, :normal) | ||
|
||
Helpers.replication_slot_teardown(tenant) | ||
|
||
assert %{rows: []} = Postgrex.query!(conn, "SELECT slot_name FROM pg_replication_slots", []) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters