Skip to content

Commit 8903cd4

Browse files
committed
✅ Use alt ID for flaky health test
1 parent 4a9a579 commit 8903cd4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

test/sequin/postgres_replication_test.exs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,8 @@ defmodule Sequin.PostgresReplicationTest do
11121112

11131113
test "emits heartbeat messages" do
11141114
# Attempt to start replication with the non-existent slot
1115-
start_replication!(heartbeat_interval: 5)
1115+
id = Faker.UUID.v4()
1116+
start_replication!(heartbeat_interval: 5, id: id)
11161117

11171118
stub(SlotMessageHandlerMock, :before_handle_messages, fn _ctx, _msgs -> :ok end)
11181119

@@ -1124,7 +1125,7 @@ defmodule Sequin.PostgresReplicationTest do
11241125
assert_receive {SlotProcessorServer, :heartbeat_received}, 1000
11251126

11261127
# Verify that the Health status was updated
1127-
{:ok, health} = Sequin.Health.health(%PostgresReplicationSlot{id: "test_slot_id", inserted_at: DateTime.utc_now()})
1128+
{:ok, health} = Sequin.Health.health(%PostgresReplicationSlot{id: id, inserted_at: DateTime.utc_now()})
11281129

11291130
check = Enum.find(health.checks, &(&1.slug == :replication_messages))
11301131
assert check.status == :healthy
@@ -1792,6 +1793,7 @@ defmodule Sequin.PostgresReplicationTest do
17921793
end
17931794

17941795
defp start_replication!(opts) do
1796+
id = Keyword.get(opts, :id, "test_slot_id")
17951797
db = DatabasesFactory.postgres_database()
17961798
ConnectionCache.cache_connection(db, UnboxedRepo)
17971799

@@ -1807,12 +1809,12 @@ defmodule Sequin.PostgresReplicationTest do
18071809
message_handler_ctx: %MessageHandler.Context{
18081810
consumers: [],
18091811
wal_pipelines: [],
1810-
replication_slot_id: "test_slot_id",
1812+
replication_slot_id: id,
18111813
postgres_database: db,
18121814
table_reader_mod: TableReaderServer
18131815
},
18141816
postgres_database: db,
1815-
replication_slot: %PostgresReplicationSlot{id: "test_slot_id"}
1817+
replication_slot: %PostgresReplicationSlot{id: id}
18161818
],
18171819
opts
18181820
)

0 commit comments

Comments
 (0)