towerops/test/snmpkit/snmpkit_test.exs
Graham McIntire 07336fefff
perf(test): optimize slow tests - 68% faster
- Add timeout: 100 to SNMP tests to avoid 5s default timeout on unreachable IPs
- Reduce retry delays in error handler tests from 50-100ms to 1ms
- Fix Splynx rate limit test to stub auth immediately without extra calls
- Use localhost instead of device.local to avoid DNS timeout
- Use temp empty dir for ImportProfiles test instead of scanning 788 real files

Results:
- Top 10 slowest: 45.6s → 14.6s (68% reduction)
- Overall suite: ~80s → 39.9s (50% faster)
- Specific improvements:
  * Splynx sync: 7010ms → 134ms (98% faster)
  * ImportProfiles: 5502ms → 33ms (99% faster)
  * get_bulk!: 5043ms → 125ms (97% faster)
  * Walk hostname: 5005ms → 119ms (97% faster)
  * Error retries: 3103ms → 6ms (99% faster)
2026-03-05 14:35:58 -06:00

39 lines
1.2 KiB
Elixir

defmodule SnmpKitTest do
use ExUnit.Case, async: true
doctest SnmpKit
# Simple test to verify module loads
test "module loads correctly" do
assert is_atom(SnmpKit)
assert is_atom(SnmpKit.SNMP)
assert is_atom(SnmpKit.MIB)
end
describe "SnmpKit.SNMP bang methods" do
test "get_bulk!/2 raises on error" do
# Bang method should raise when underlying function returns error
assert_raise RuntimeError, ~r/get_bulk! failed/, fn ->
SnmpKit.SNMP.get_bulk!("192.0.2.1", "1.3.6.1.2.1.1", timeout: 100)
end
end
test "get_bulk!/3 raises on error with options" do
assert_raise RuntimeError, ~r/get_bulk! failed/, fn ->
SnmpKit.SNMP.get_bulk!("192.0.2.1", "1.3.6.1.2.1.1", timeout: 100)
end
end
test "bulk_walk!/2 raises on error" do
assert_raise RuntimeError, ~r/bulk_walk! failed/, fn ->
SnmpKit.SNMP.bulk_walk!("192.0.2.1", "1.3.6.1.2.1.1", timeout: 100)
end
end
test "bulk_walk!/3 raises on error with options" do
assert_raise RuntimeError, ~r/bulk_walk! failed/, fn ->
SnmpKit.SNMP.bulk_walk!("192.0.2.1", "1.3.6.1.2.1.1", timeout: 100)
end
end
end
end