Skip to content

Commit

Permalink
fix: Add test coverage to repo; delete cdc stream
Browse files Browse the repository at this point in the history
* Attempt to send coverage to coveralls - https://coveralls.io/github/supabase/realtime
* Removes CDC Stream code
* Fix small compilation error with Gettext deprecation warnings
* Renamed Realtime.Tenants.BroadcastChanges.Handler to Realtime.Tenants.ReplicationConnection
* Reverses PID monitoring so Realtime.Tenants.ReplicationConnection and Realtime.Tenants.Listen are the ones tracking Realtime.Connect and die accordingly, reducing probability of process linking issues
* Fixed Realtime.Tenants.Connect.shutdown/1 that was killing the Postgrex connection instead of killing Realtime.Tenants.Connect potentially leading to issues in the state of the connection
  • Loading branch information
filipecabaco committed Jan 14, 2025
1 parent 5bb08a5 commit 3d04303
Show file tree
Hide file tree
Showing 28 changed files with 259 additions and 828 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Staging Formatting Checks
name: Tests
on:
pull_request:
branches:
- main
jobs:
format:
name: Formatting Checks
name: Tests
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -52,4 +52,6 @@ jobs:
- name: Start epmd
run: epmd -daemon
- name: Run tests
run: mix test --trace --max-cases 1
run: MIX_ENV=test mix coveralls.github --trace
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7 changes: 0 additions & 7 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ config :realtime, :extensions,
driver: Extensions.PostgresCdcRls,
supervisor: Extensions.PostgresCdcRls.Supervisor,
db_settings: Extensions.PostgresCdcRls.DbSettings
},
postgres_cdc_stream: %{
type: :postgres_cdc,
key: "postgres_cdc_stream",
driver: Extensions.PostgresCdcStream,
supervisor: Extensions.PostgresCdcStream.Supervisor,
db_settings: Extensions.PostgresCdcStream.DbSettings
}

config :esbuild,
Expand Down
26 changes: 26 additions & 0 deletions coveralls.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"skip_files": [
"lib/realtime_web/api_spec.ex",
"lib/realtime_web/channels/presence.ex",
"lib/realtime_web/controllers/page_controller.ex",
"lib/realtime_web/dashboard/",
"lib/realtime_web/endpoint.ex",
"lib/realtime_web/gettext.ex",
"lib/realtime_web/live/",
"lib/realtime_web/open_api_schemas.ex",
"lib/realtime_web/telemetry.ex",
"lib/realtime_web/views/",
"lib/realtime.ex",
"lib/realtime/adapters/changes.ex",
"lib/realtime/adapters/postgres/decoder.ex",
"lib/realtime/adapters/postgres/oid_database.ex",
"lib/realtime/adapters/postgres/protocol/",
"lib/realtime/application.ex",
"lib/realtime/operations.ex",
"lib/realtime/release.ex",
"lib/realtime/tenants/authorization/policies/broadcast_policies.ex",
"lib/realtime/tenants/authorization/policies/presence_policies.ex",
"lib/realtime/tenants/repo/migrations/",
"test/"
]
}
28 changes: 6 additions & 22 deletions lib/extensions/postgres_cdc_rls/cdc_rls.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,7 @@ defmodule Extensions.PostgresCdcRls do
conn_node = node(conn)

if conn_node !== node() do
Rpc.call(
conn_node,
Subscriptions,
:create,
opts,
timeout: 15_000
)
Rpc.call(conn_node, Subscriptions, :create, opts, timeout: 15_000)
else
apply(Subscriptions, :create, opts)
end
Expand Down Expand Up @@ -113,26 +107,16 @@ defmodule Extensions.PostgresCdcRls do

@spec get_manager_conn(String.t()) :: {:error, nil | :wait} | {:ok, pid(), pid()}
def get_manager_conn(id) do
:syn.lookup(__MODULE__, id)
|> case do
{_, %{manager: nil, subs_pool: nil}} ->
{:error, :wait}

{_, %{manager: manager, subs_pool: conn}} ->
{:ok, manager, conn}

_ ->
{:error, nil}
case :syn.lookup(__MODULE__, id) do
{_, %{manager: nil, subs_pool: nil}} -> {:error, :wait}
{_, %{manager: manager, subs_pool: conn}} -> {:ok, manager, conn}
_ -> {:error, nil}
end
end

@spec supervisor_id(String.t(), String.t()) :: {atom(), String.t(), map()}
def supervisor_id(tenant, region) do
{
__MODULE__,
tenant,
%{region: region, manager: nil, subs_pool: nil}
}
{__MODULE__, tenant, %{region: region, manager: nil, subs_pool: nil}}
end

@spec update_meta(String.t(), pid(), pid()) :: {:ok, {pid(), term()}} | {:error, term()}
Expand Down
118 changes: 0 additions & 118 deletions lib/extensions/postgres_cdc_stream/cdc_stream.ex

This file was deleted.

26 changes: 0 additions & 26 deletions lib/extensions/postgres_cdc_stream/db_settings.ex

This file was deleted.

56 changes: 0 additions & 56 deletions lib/extensions/postgres_cdc_stream/message_dispatcher.ex

This file was deleted.

Loading

0 comments on commit 3d04303

Please sign in to comment.