require Logger

ExUnit.start()

# Configure logging level for tests
Logger.configure(level: :warning)

# Configure ExUnit
ExUnit.configure(
  # 10 seconds default timeout
  timeout: 10_000,
  # Increase parallelism
  max_cases: System.schedulers_online() * 2,
  exclude: [
    # Performance tests
    :performance,
    # SNMPv3 cryptographic tests (CPU-intensive, ~15-20 seconds)
    :snmpv3,
    # Memory-intensive tests
    :memory,
    # Shell integration tests
    :shell_integration,
    # Optional tests
    :optional,
    # Tests that require simulator (no longer available)
    :needs_simulator,
    # Manual tests requiring real devices
    :manual,
    :real_device,
    # Tests requiring yecc/parsetools (MIB compiler)
    :yecc_required
  ]
)

# Start SnmpMgr.Config for snmp_mgr tests
case SnmpKit.SnmpMgr.Config.start_link([]) do
  {:ok, _pid} ->
    Logger.debug("SnmpMgr.Config started for test suite")

  {:error, {:already_started, _pid}} ->
    Logger.debug("SnmpMgr.Config already running")

  {:error, reason} ->
    Logger.warning("Failed to start SnmpMgr.Config: #{inspect(reason)}")
end

# Start SnmpMgr.MIB for MIB resolution tests
case SnmpKit.SnmpMgr.MIB.start_link([]) do
  {:ok, _pid} ->
    Logger.debug("SnmpMgr.MIB started for test suite")

  {:error, {:already_started, _pid}} ->
    Logger.debug("SnmpMgr.MIB already running")

  {:error, reason} ->
    Logger.warning("Failed to start SnmpMgr.MIB: #{inspect(reason)}")
end
