Skip to content

Commit

Permalink
fix: keep failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rhblind committed Dec 7, 2023
1 parent 85b6662 commit 29173b4
Showing 1 changed file with 61 additions and 61 deletions.
122 changes: 61 additions & 61 deletions test/off_broadway/splunk/producer_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -354,24 +354,24 @@ defmodule OffBroadway.Splunk.ProducerTest do
end

# FIXME This test fails, and I cannot understand why.
# test "keep trying to receive new messages when the queue is empty" do
# {:ok, message_server} = MessageServer.start_link()
# {:ok, pid} = start_broadway(message_server)
test "keep trying to receive new messages when the queue is empty" do
{:ok, message_server} = MessageServer.start_link()
{:ok, pid} = start_broadway(message_server)

# MessageServer.push_messages(message_server, [13])
# assert_receive {:messages_received, 1}
# assert_receive {:message_handled, 13, _}
MessageServer.push_messages(message_server, [13])
assert_receive {:messages_received, 1}
assert_receive {:message_handled, 13, _}

# assert_receive {:messages_received, 0}
# refute_receive {:message_handled, _, _}
assert_receive {:messages_received, 0}
refute_receive {:message_handled, _, _}

# MessageServer.push_messages(message_server, [14, 15])
# assert_receive {:messages_received, 2}
# assert_receive {:message_handled, 14, _}
# assert_receive {:message_handled, 15, _}
MessageServer.push_messages(message_server, [14, 15])
assert_receive {:messages_received, 2}
assert_receive {:message_handled, 14, _}
assert_receive {:message_handled, 15, _}

# stop_broadway(pid)
# end
stop_broadway(pid)
end

test "keep trying to receive new messages after endpoint error" do
broadway_name = new_unique_name()
Expand Down Expand Up @@ -414,53 +414,53 @@ defmodule OffBroadway.Splunk.ProducerTest do
end

# FIXME These tests are randomly failing, and I cannot understand why.
# test "emit a telemetry start event with demand" do
# self = self()
# {:ok, message_server} = MessageServer.start_link()
# {:ok, pid} = start_broadway(message_server)

# capture_log(fn ->
# :ok =
# :telemetry.attach(
# "start_test",
# [:off_broadway_splunk, :receive_messages, :start],
# fn name, measurements, metadata, _ ->
# send(self, {:telemetry_event, name, measurements, metadata})
# end,
# nil
# )
# end)

# MessageServer.push_messages(message_server, [2])

# assert_receive {:telemetry_event, [:off_broadway_splunk, :receive_messages, :start],
# %{system_time: _}, %{sid: _, demand: 10}}

# stop_broadway(pid)
# end

# test "emit a telemetry stop event with received count" do
# self = self()
# {:ok, message_server} = MessageServer.start_link()
# {:ok, pid} = start_broadway(message_server)

# capture_log(fn ->
# :ok =
# :telemetry.attach(
# "stop_test",
# [:off_broadway_splunk, :receive_messages, :stop],
# fn name, measurements, metadata, _ ->
# send(self, {:telemetry_event, name, measurements, metadata})
# end,
# nil
# )
# end)

# assert_receive {:telemetry_event, [:off_broadway_splunk, :receive_messages, :stop],
# %{duration: _}, %{sid: _, received: _, demand: 10}}

# stop_broadway(pid)
# end
test "emit a telemetry start event with demand" do
self = self()
{:ok, message_server} = MessageServer.start_link()
{:ok, pid} = start_broadway(message_server)

capture_log(fn ->
:ok =
:telemetry.attach(
"start_test",
[:off_broadway_splunk, :receive_messages, :start],
fn name, measurements, metadata, _ ->
send(self, {:telemetry_event, name, measurements, metadata})
end,
nil
)
end)

MessageServer.push_messages(message_server, [2])

assert_receive {:telemetry_event, [:off_broadway_splunk, :receive_messages, :start],
%{system_time: _}, %{sid: _, demand: 10}}

stop_broadway(pid)
end

test "emit a telemetry stop event with received count" do
self = self()
{:ok, message_server} = MessageServer.start_link()
{:ok, pid} = start_broadway(message_server)

capture_log(fn ->
:ok =
:telemetry.attach(
"stop_test",
[:off_broadway_splunk, :receive_messages, :stop],
fn name, measurements, metadata, _ ->
send(self, {:telemetry_event, name, measurements, metadata})
end,
nil
)
end)

assert_receive {:telemetry_event, [:off_broadway_splunk, :receive_messages, :stop],
%{duration: _}, %{sid: _, received: _, demand: 10}}

stop_broadway(pid)
end
end

defp start_broadway(message_server, broadway_name \\ new_unique_name(), opts \\ []) do
Expand Down

0 comments on commit 29173b4

Please sign in to comment.