diff --git a/test/microwaveprop/workers/contact_weather_enqueue_worker_test.exs b/test/microwaveprop/workers/contact_weather_enqueue_worker_test.exs index b3e674f8..6a89ef20 100644 --- a/test/microwaveprop/workers/contact_weather_enqueue_worker_test.exs +++ b/test/microwaveprop/workers/contact_weather_enqueue_worker_test.exs @@ -1,5 +1,9 @@ defmodule Microwaveprop.Workers.ContactWeatherEnqueueWorkerTest do - use Microwaveprop.DataCase, async: true + # async: false — perform/1 runs inline Oban child jobs that upsert + # rows (iemre_observations, terrain_profiles) with a shared conflict + # target. Running concurrently with sibling DataCase tests produced + # intermittent "ShareLock deadlock_detected" failures in Postgres. + use Microwaveprop.DataCase, async: false alias Microwaveprop.Radio.Contact alias Microwaveprop.Terrain.ElevationClient diff --git a/test/microwaveprop/workers/propagation_prune_worker_test.exs b/test/microwaveprop/workers/propagation_prune_worker_test.exs index f856747d..98cb3e79 100644 --- a/test/microwaveprop/workers/propagation_prune_worker_test.exs +++ b/test/microwaveprop/workers/propagation_prune_worker_test.exs @@ -5,9 +5,13 @@ defmodule Microwaveprop.Workers.PropagationPruneWorkerTest do alias Microwaveprop.Workers.PropagationPruneWorker describe "perform/1" do - test "deletes ScoresFile binaries with valid_time older than 2 hours" do + test "deletes ScoresFile binaries with valid_time older than 3 hours" do + # `old` needs to sit strictly before the worker's computed cutoff + # (`now - 3h`). Both are truncated to the second when compared, so + # picking exactly -3h flakes whenever the test + worker wall-clock + # land in the same second. -3h - 1s gives unconditional ordering. now = DateTime.utc_now() - old = now |> DateTime.add(-3, :hour) |> DateTime.truncate(:second) + old = now |> DateTime.add(-3, :hour) |> DateTime.add(-1, :second) |> DateTime.truncate(:second) fresh = now |> DateTime.add(-30, :minute) |> DateTime.truncate(:second) future = now |> DateTime.add(6, :hour) |> DateTime.truncate(:second) diff --git a/test/microwaveprop_web/live/map_live_test.exs b/test/microwaveprop_web/live/map_live_test.exs index 63eecb09..a7c12273 100644 --- a/test/microwaveprop_web/live/map_live_test.exs +++ b/test/microwaveprop_web/live/map_live_test.exs @@ -120,6 +120,17 @@ defmodule MicrowavepropWeb.MapLiveTest do end describe "data timestamp indicator" do + setup do + # Earlier tests in the suite may have written score files into the + # shared `:propagation_scores_dir` and warmed the 5 s + # `list_valid_times` cache. Reset both so this test starts from the + # "no data" state its assertion describes. + scores_dir = Application.fetch_env!(:microwaveprop, :propagation_scores_dir) + _ = File.rm_rf(scores_dir) + :ets.match_delete(:microwaveprop_cache, {{Microwaveprop.Propagation.ScoresFile, :list_valid_times, :_, :_}, :_, :_}) + :ok + end + test "renders a 'Data from …' line on both mobile and desktop sidebars", %{conn: conn} do {:ok, _lv, html} = live(conn, ~p"/map") assert html =~ ~s(id="data-timestamp-mobile")