fix a few things and fix device discovery

This commit is contained in:
Graham McIntire 2026-01-26 17:17:31 -06:00
parent bb86dec559
commit 6c238c52e5
No known key found for this signature in database
4 changed files with 13 additions and 9 deletions

View file

@ -4,9 +4,8 @@ import Config
config :bcrypt_elixir, :log_rounds, 1
# Suppress log output during tests (tests that need logs use capture_log)
config :logger,
level: :error,
backends: []
config :logger, :default_handler, false
config :logger, level: :error
# Initialize plugs at runtime for faster test compilation
config :phoenix, :plug_init_mode, :runtime

View file

@ -85,7 +85,12 @@ defmodule Towerops.Devices.Device do
:snmp_enabled,
:snmp_version,
:snmp_community,
:snmp_port
:snmp_port,
:status,
:last_checked_at,
:last_status_change_at,
:last_discovery_at,
:last_snmp_poll_at
])
|> validate_required([:ip_address, :site_id])
|> validate_name()

View file

@ -83,15 +83,15 @@ defmodule Towerops.Workers.PollingOffsetTest do
buckets = Enum.group_by(offsets, &div(&1, 30))
# With good distribution, each bucket should have roughly 10 devices (100/10)
# Allow for variance - expect 3-20 devices per bucket (hash functions have natural variance)
# Allow for variance - expect 3-22 devices per bucket (hash functions have natural variance)
for {bucket_num, devices_in_bucket} <- buckets do
count = length(devices_in_bucket)
assert count >= 3,
"bucket #{bucket_num} has only #{count} devices, expected at least 3"
assert count <= 20,
"bucket #{bucket_num} has #{count} devices, expected at most 20"
assert count <= 22,
"bucket #{bucket_num} has #{count} devices, expected at most 22"
end
# Verify we're actually using multiple buckets (good distribution)

View file

@ -69,10 +69,10 @@ defmodule ToweropsWeb.AgentLiveTest do
|> form("#new-agent-form form", %{name: "Test Agent"})
|> render_submit()
# Close modal
# Close modal by clicking the primary button (bg-blue-600 class indicates primary button)
html =
view
|> element("button", "I've Saved the Token")
|> element("button.bg-blue-600[phx-click='close_token_modal']")
|> render_click()
refute html =~ "Agent Created Successfully"