diff --git a/lib/towerops/profiles/yaml_profiles.ex b/lib/towerops/profiles/yaml_profiles.ex index b32309fc..1920d184 100644 --- a/lib/towerops/profiles/yaml_profiles.ex +++ b/lib/towerops/profiles/yaml_profiles.ex @@ -88,10 +88,19 @@ defmodule Towerops.Profiles.YamlProfiles do @impl true def init(_opts) do _ = :ets.new(@table, [:named_table, :set, :public, read_concurrency: true]) - # Defer loading so the supervisor (and Bandit) start immediately. - # Profiles will be available within ~60s; SNMP polling starts well after that. - send(self(), :load_profiles) - {:ok, %{}} + + if Mix.env() == :test do + # Load synchronously so tests don't race with deferred loading. + raw_profiles = load_all_profiles() + mib_names = extract_mib_names_from_profiles(raw_profiles) + MibCache.pre_resolve(mib_names) + {:ok, %{}} + else + # Defer loading so the supervisor (and Bandit) start immediately. + # Profiles will be available within ~60s; SNMP polling starts well after that. + send(self(), :load_profiles) + {:ok, %{}} + end end @impl true