Skip to content

Commit

Permalink
Stop stager telemetry test from flaking
Browse files Browse the repository at this point in the history
  • Loading branch information
sorentwo committed Oct 26, 2023
1 parent 6c4cba9 commit d35b5d4
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions test/oban/stager_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@ defmodule Oban.StagerTest do

describe "integration" do
test "descheduling jobs to make them available for execution" do
TelemetryHandler.attach_events()

job_1 = insert!(%{}, state: "scheduled", scheduled_at: seconds_ago(1))
job_2 = insert!(%{}, state: "scheduled", scheduled_at: seconds_from_now(1))
job_1 = insert!(%{}, state: "scheduled", scheduled_at: seconds_ago(10))
job_2 = insert!(%{}, state: "scheduled", scheduled_at: seconds_from_now(10))
job_3 = insert!(%{}, state: "retryable")

start_supervised_oban!(stage_interval: 5, testing: :disabled)

assert_receive {:event, :start, %{system_time: _}, %{conf: _, plugin: Stager}}
assert_receive {:event, :stop, %{duration: _}, %{plugin: Stager} = meta}
with_backoff(fn ->
assert %{state: "available"} = Repo.reload(job_1)
assert %{state: "scheduled"} = Repo.reload(job_2)
assert %{state: "available"} = Repo.reload(job_3)
end)
end

assert %{staged_count: 2, staged_jobs: jobs} = meta
test "emitting telemetry data for staged jobs" do
TelemetryHandler.attach_events()

start_supervised_oban!(stage_interval: 5, testing: :disabled)

assert ~w(retryable scheduled) =
jobs
|> Enum.map(& &1.state)
|> Enum.sort()
assert_receive {:event, :stop, %{duration: _}, %{plugin: Stager} = meta}

assert %{state: "available"} = Repo.reload(job_1)
assert %{state: "scheduled"} = Repo.reload(job_2)
assert %{state: "available"} = Repo.reload(job_3)
assert %{staged_count: _, staged_jobs: []} = meta
end

test "switching to local mode without functional pubsub" do
Expand Down

0 comments on commit d35b5d4

Please sign in to comment.