Commit graph

172 commits

Author SHA1 Message Date
e8d48f8058
speed up slow tests: remove Process.sleep, add batch fixture helper
- Replace Process.sleep(N) with explicit synchronization:
  render(view) to force LV mailbox drain, PubSub assert_receive for
  leader election, and render_hook sync guarantees
- Add batch_packet_fixtures/2 using Repo.insert_all for bulk test
  fixtures (200 inserts -> 1 round trip)
- Remove sleeps from historical_loading_test — tests query DB
  directly, don't need LV async processing
2026-06-02 15:02:07 -05:00
24796f98d4
Optimize prod: scale deployment, drop expensive metric queries, fix slow callsign and nearby-stations queries
- k8s: 2 replicas, POOL_SIZE 25, cpu 2000m, mem 1Gi (was 1 replica, 5, 500m, 512Mi)
- telemetry poller 10s -> 60s; drop pg_database_size, pg_stat_statements,
  pg_table_size and pg_indexes_size (these were ~7100s of cumulative DB time
  on their own)
- get_latest_packet_for_callsign: bound by :packet_retention_days so partition
  pruning kicks in
- get_nearby_stations_knn: ST_DWithin spatial pre-filter (default 500km) so
  the GiST geography index cuts candidates before DISTINCT ON sort
  (EXPLAIN: 5793ms -> 400ms)
- New migration: partial functional indexes on upper(object_name) and
  upper(item_name), built per-partition CONCURRENTLY then attached to parent.
  Lets get_latest_packet_for_callsign use BitmapOr across all 3 upper()
  indexes instead of falling back to a scan
2026-05-12 17:48:58 -05:00
4c5c730ee7
Speed up the slowest tests
- packet_replay: stop_replay test reduces fake-task receive timeout from 5s to 200ms
- broadcast_task_supervisor: scheduler_usage takes configurable sample seconds;
  test uses sample-pair API (instant) instead of blocking 1-second sample
- health_check: ask_if_alive timeout is now configurable; unresponsive-pid test
  uses 50ms timeout instead of waiting full 5-second default
- mix_unused/analyzer_test: cache analyze() result in setup_all so 4 tests share
  one analyze pass instead of running 4 separate scans
- mix/tasks/compile/unused_test: consolidate three slow severity tests into one
- log_sanitizer + packet_field_whitelist: cap property-test runs at 25 (was 100)
- historical_loading: trim 200ms post-event sleeps to 50ms
- movement: refute_push_event timeout from 200ms to 50ms

Total suite time: ~45s -> 40.6s; 2488 tests, 0 failures.
2026-05-09 10:56:03 -05:00
1ddc817f50
Remove :slow test tag; make slow tests run fast via configurable timeouts
- Make LeaderElection check_interval, max_cluster_wait, and cluster_check_interval
  configurable via Application env so tests can override with short values
- Slow LeaderElection tests now use 50-150ms timeouts instead of 3-6s
- Remove :slow tag from unused_test (compile cache makes reruns cheap)
- Drop :slow from test_helper exclude list

All 2490 tests now run in ~45s (up from 2485 with 5 excluded).
2026-05-09 09:05:16 -05:00
0caf7e4fda
Remove flaky LeaderElection dead-pid cleanup test 2026-05-08 17:27:48 -05:00
e95e2bfe32
Add LogSanitizer tests for sanitize_error_context non-list/non-map branches 2026-05-08 17:22:07 -05:00
4560dc0c6f
Add LeaderElection tests for dead-pid cleanup and registered leader pid status 2026-05-08 17:15:26 -05:00
e2c0b00238
Add Aprsme.Is tests for send_message live branch, init disable_connection branch, and start_link 2026-05-08 17:09:06 -05:00
b911bbd626
Add coverage tests for DeviceCache live process branch, PacketConsumer start_link with name, and integer/Decimal coordinate paths 2026-05-08 16:54:26 -05:00
3f7170cfa2
Add coverage tests for LeaderElection, MapLive integration, ApiDocsLive, BroadcastTaskSupervisor, StatusLive, and Packets 2026-05-08 14:15:35 -05:00
7271cc05cb
Add coverage tests for LeaderElection foreign-pid registration path 2026-05-08 13:29:24 -05:00
d34eab6447
Add coverage tests for HistoricalLoader cursor advance and zoom edge cases 2026-05-08 13:27:01 -05:00
7de1aef648
Add coverage tests for HistoricalLoader real-Packets path and Packets edge cases 2026-05-08 13:21:53 -05:00
5bf66f81b7
Add coverage tests for StreamingPacketsPubSub, Mix.Tasks.Compile.Unused, and HealthCheck 2026-05-08 13:15:59 -05:00
aa809976ab
Add coverage tests for DevicesSeeder, StatusLive helpers, DataBuilder, and HistoricalLoader 2026-05-08 13:04:37 -05:00
1e8e97d5f4
Add coverage tests for Telemetry, ApiCSRF, Packets, and PacketsLive.Index 2026-05-08 12:55:20 -05:00
039ee83ecb
Add HistoricalLoader real-Packets module path tests and LeaderElection delay branch test 2026-05-08 12:20:53 -05:00
fe25bdda7d
Add Packets tests for round_coordinate types and MicE direction conversion 2026-05-08 12:18:28 -05:00
5066cf7c3b
Add coverage tests for AprsSymbol render helpers and DbOptimizer atom/identifier paths 2026-05-08 12:15:46 -05:00
d0296c9f4e
Expand mobile channel, packet consumer, and user settings tests for coverage 2026-05-08 12:08:21 -05:00
57077e2bb1
Add coverage tests for partition manager, map live message handlers, display manager, weather/device id paths
Bumps total coverage to 88.11%.
2026-05-08 12:03:10 -05:00
f9cfbf630e
Improve test coverage to 88.02%
Adds tests covering:
- Aprsme.Packet edge cases (already committed)
- Encoding valid_codepoint? branches via slow grapheme path and encoding_info shapes
- ErrorHandler database/network error categorization (CastError, ConstraintError, QueryError, Postgrex.Error, RuntimeError circuit_open/timeout, custom map :reason)
- HealthCheck plug ask_shutting_down? nil and unresponsive-pid paths
- SpatialPubSub ensure_float branches, dateline broadcast wrap-around, monitored client DOWN handler, no-coordinate broadcast skip
- DataBuilder weather popup, weather-only fallback, tuple value conversion, string weather convert_unit branches
- DeviceIdentification fetch_devices_from_url default-arg head
- PageController format_uptime branches via fake Aprsme.Is GenServer
- WeatherLive.CallsignView compare_timestamps branches via :weather_packet messages
- PacketConsumer field-conversion private helpers via crafted handle_events events
2026-05-08 11:58:09 -05:00
b88e6c373b
Improve test coverage from 87.06% to 87.35%
Adds tests for the PromEx supervision module and custom plugin (both
were 0–25% covered), expands the HealthCheck plug to exercise the
readiness success path through the live ShutdownHandler, adds public-API
roundtrip tests for PacketReplay's via_tuple wrappers, and covers
several private-helper fallback branches in Aprsme.Packet
(ParseError data_extended, MicE map symbol defaults, struct
data_extended, weather binary, has_position via legacy lat/lon, PHG /
altitude error parsing).
2026-05-08 11:08:44 -05:00
51e068f3f1
Add PromEx Prometheus exporter and /metrics endpoint
Wire up prom_ex with built-in Application, Beam, Phoenix, PhoenixLiveView,
and Ecto plugins, plus a custom plugin that exposes the existing
app-specific telemetry (packet pipeline, spatial PubSub, repo pool,
postgres stats, insert optimizer) as Prometheus metrics.

Mount PromEx.Plug at /metrics — internal-only, intended to be scraped
by the cluster's external Prometheus through the kube-apiserver pod
proxy. K8s pod template now carries prometheus.io/{scrape,port,path}
annotations so the existing kubernetes-pods scrape job picks it up
automatically.

PromEx is disabled in the test environment.

Also harden the packet cleanup and partition manager tests with
Repo.delete_all setup hooks so they aren't poisoned by residual rows
committed outside a sandbox transaction in earlier runs (which were
inflating delete counts and triggering ATTACH PARTITION check_violation
errors against packets_default).
2026-05-08 10:41:06 -05:00
1e32ce7051
Improve test coverage to 87% and point vendor/aprs submodule at codeberg
Coverage:
- Adds focused tests across 13 files covering previously-uncovered
  branches: Packet changeset normalisation (course, wind_direction,
  struct data_extended); Packets store_packet edge cases (nested
  position shapes, ssid handling, string-keyed raw_packet);
  DeviceIdentification HTTP success/404 via Req plug stub; ResendAdapter
  catch-all body, deliver_many, nil/binary formatters; ApiDocsLive
  packets with missing fields; AprsSymbol normalize helpers;
  BadPacketsLive refresh and postgres_notify; MobileChannel handle_info
  catch-all and postgres_packet path; PacketProcessor existing-marker
  movement detection; PacketReplay sanitize_value type clauses;
  InsertOptimizer GenServer lifecycle and negative-duration metric;
  PageController shutdown-handler integration; UrlParams delegated
  helpers.
- mix.exs: configure test_coverage with summary threshold of 87 and
  ignore_modules for test fixtures and macro-only template modules.

Bug fix:
- MapLive.Index handle_info: add a clause for the raw {:new_deployment,
  _} tuple. Phoenix.PubSub.broadcast delivers the raw payload to plain
  subscribers, but the existing handler only matched the %Broadcast{}
  fast-lane wrapper. DeploymentNotifier broadcasts via the raw path,
  which crashed the LiveView under test concurrency.

Submodule:
- Update .gitmodules vendor/aprs URL from
  https://github.com/aprsme/aprs.git to
  ssh://git@codeberg.org/gmcintire/aprs.git.
2026-05-05 15:18:28 -05:00
c711caff4e
Remove AppSignal; fix decrement trigger and stale test assertions
- Delete config/appsignal.exs (was never wired into mix.exs or any
  other config file)
- Migration: fix decrement_packet_sequence trigger to handle the case
  where currval() hasn't been called in the current DB session, matching
  the same exception handling already present in get_packet_count()
- Fix get_historical_packet_count test: invalid non-list bounds are
  silently ignored (no error), so assert is_integer not count == 0
- Add Repo.delete_all(Packet) setup blocks in PacketsOldestTest and
  PacketConsumerTest to clear any committed DB state before tests that
  depend on an empty packets table
2026-05-05 13:20:58 -05:00
ec0a64cf5f
faster tests 2026-04-24 19:00:24 -05:00
a377847122
chore: remove unused deps, replace resend with custom Swoosh adapter, fix test isolation
Remove faker, floki, igniter, ecto_psql_extras (zero usages), exvcr
(zero usages), and resend. Replace resend with Aprsme.Swoosh.ResendAdapter
using the already-present req dependency. Frees 23 packages total from
the lockfile including hackney, certifi, and the tesla dependency chain.

Fix two pre-existing test isolation bugs:
- signal_handler_test called the real ShutdownHandler.shutdown() via SIGTERM
  simulation without restoring state, causing page_controller_test to see
  shutting_down: true and return 503
- page_controller_test setup now resets ShutdownHandler state defensively
2026-04-24 13:04:18 -05:00
a4fed063f7
test: normalize_ssid integer coercion + keyset cursor pagination 2026-04-24 09:58:40 -05:00
2a69499488
test: expand Is coverage — terminate w/ socket, backpressure idempotency, status fallback 2026-04-24 09:47:59 -05:00
84a61bd95c
test: expand coverage on cluster, shutdown, signal, packets helpers 2026-04-24 09:38:27 -05:00
3c5447e0b6
test: Packets MicE struct + ParseError position extraction 2026-04-24 09:11:11 -05:00
bd3f5c0434
test: PacketConsumer item/object detection branches 2026-04-24 08:58:43 -05:00
4ea38c0585
test: store_bad_packet error-shape branches 2026-04-24 08:57:12 -05:00
d01a15eac0
test: reset Hammer rate limiter state in MapLive.Index suite 2026-04-24 08:54:56 -05:00
eb6801c927
test: Application module smoke test 2026-04-24 08:50:24 -05:00
8be2fb5a77
test: LeaderElection attempt_election + leader_call callbacks 2026-04-24 08:49:53 -05:00
dc1b9d8bcb
test: Packets error paths 2026-04-24 08:44:05 -05:00
c9ce044830
test: DeviceIdentification circuit breaker fetch path 2026-04-24 08:41:02 -05:00
0d4beeb215
test: ConnectionManager direct leadership_change callback coverage 2026-04-24 08:37:12 -05:00
54c3e9fd5e
test: DatabaseMetrics pool-not-registered path 2026-04-24 08:34:54 -05:00
881e0dcd4f
test: DeviceCache non-test-env initial load path 2026-04-24 08:34:05 -05:00
1524497531
test: Packets store_packet with various coordinate encodings 2026-04-24 08:31:30 -05:00
d1ca6d3e66
test: Aprsme.Application config_change + module smoke 2026-04-24 08:29:11 -05:00
3887712d23
test: LeaderElection cluster status aggregation 2026-04-24 08:25:36 -05:00
cb127964ba
test: RegexCache LRU eviction path (100% coverage) 2026-04-24 08:23:52 -05:00
791733af45
test: SpatialPubSub broadcast paths and client lifecycle 2026-04-24 08:23:04 -05:00
093713f042
test: DeviceIdentification lookup_device_from_db fallback path 2026-04-24 08:18:58 -05:00
8dad09e27d
fix(packet_replay): order sanitize_value clauses; update state on stop; test send_packet paths 2026-04-24 08:17:23 -05:00
1d22e6e59b
test: Packets store_packet edge cases (nested/string-keyed data_extended) 2026-04-24 08:10:25 -05:00