Skip to content

Commit ca0a9bc

Browse files
authored
chore: fix flaky tests (#1930)
1 parent cd952f2 commit ca0a9bc

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

test/realtime/extensions/cdc_rls/subscriptions_test.exs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,11 @@ defmodule Realtime.Extensions.PostgresCdcRls.SubscriptionsTest do
177177
assert {:ok, [%Postgrex.Result{}]} =
178178
Subscriptions.create(conn, "supabase_realtime_test", params_list, self(), self())
179179

180-
%Postgrex.Result{rows: [[[], "*"]]} =
181-
Postgrex.query!(conn, "select filters, action_filter from realtime.subscription", [])
180+
assert %Postgrex.Result{rows: rows} =
181+
Postgrex.query!(conn, "select filters, action_filter from realtime.subscription", [])
182+
183+
assert rows != []
184+
assert Enum.all?(rows, &match?([[], "*"], &1))
182185
end
183186

184187
test "user can subscribe to only INSERT events", %{conn: conn} do
@@ -192,8 +195,11 @@ defmodule Realtime.Extensions.PostgresCdcRls.SubscriptionsTest do
192195
assert {:ok, [%Postgrex.Result{}]} =
193196
Subscriptions.create(conn, "supabase_realtime_test", params_list, self(), self())
194197

195-
%Postgrex.Result{rows: [[[], "INSERT"]]} =
196-
Postgrex.query!(conn, "select filters, action_filter from realtime.subscription", [])
198+
assert %Postgrex.Result{rows: rows} =
199+
Postgrex.query!(conn, "select filters, action_filter from realtime.subscription", [])
200+
201+
assert rows != []
202+
assert Enum.all?(rows, &match?([[], "INSERT"], &1))
197203
end
198204

199205
test "user can subscribe to a specific table", %{conn: conn} do

test/realtime/tenants/connect_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ defmodule Realtime.Tenants.ConnectTest do
507507
Process.exit(replication_connection_pid, :kill)
508508
assert_receive {:DOWN, _, :process, ^replication_connection_pid, _}
509509

510-
Process.sleep(100)
510+
Process.sleep(1000)
511511
assert {:error, :not_connected} = Connect.replication_status(tenant.external_id)
512512

513513
new_replication_connection_pid = assert_pid(fn -> ReplicationConnection.whereis(tenant.external_id) end)
@@ -516,7 +516,7 @@ defmodule Realtime.Tenants.ConnectTest do
516516
assert Process.alive?(new_replication_connection_pid)
517517
assert Process.alive?(pid)
518518

519-
assert {:ok, replication_conn_after} = assert_replication_status(tenant.external_id)
519+
assert {:ok, replication_conn_after} = assert_replication_status(tenant.external_id, 60)
520520
assert replication_conn_before != replication_conn_after
521521
end
522522

0 commit comments

Comments
 (0)