test(nodes): give the DistributedBackendManager fixtures a system state (#12877)

The disable-backend-install switch (#12754) makes InstallBackend and
UpgradeBackend read d.systemState.DisableBackendInstall. The test
fixtures build the manager as a struct literal or through
NewDistributedBackendManager with an empty ApplicationConfig, so
systemState is nil and every install and upgrade spec panics with a nil
pointer dereference.

Set a zero-value SystemState in each fixture. That keeps installs
allowed, which is what these specs expect.

Assisted-by: Claude Code:claude-haiku-5-5

Co-authored-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
mudler-agentandEttore Di Giacinto authored and GitHub committed 2026-10-24 15:34:21 +02:00
1 parent 7c74d26555
commit 840fa3cc00
3 files changed
+16 -10

No files matched your search

@@ -11,6 +11,7 @@ import (
"github.com/mudler/LocalAI/core/services/messaging"
"github.com/mudler/LocalAI/core/services/testutil"
"github.com/mudler/LocalAI/pkg/system"
)
// Agent workers do not subscribe to the backend.* subjects, so asking one to
@@ -38,9 +39,10 @@ var _ = Describe("Backend listing across mixed node types", func() {
Expect(err).ToNot(HaveOccurred())
mc = newScriptedMessagingClient()
mgr = &DistributedBackendManager{
local: stubLocalBackendManager{},
adapter: NewRemoteUnloaderAdapter(nil, mc, 3*time.Minute, 15*time.Minute),
registry: registry,
local: stubLocalBackendManager{},
adapter: NewRemoteUnloaderAdapter(nil, mc, 3*time.Minute, 15*time.Minute),
registry: registry,
systemState: &system.SystemState{},
}
ctx = context.Background()
})
@@ -19,6 +19,7 @@ import (
"github.com/mudler/LocalAI/core/services/messaging"
"github.com/mudler/LocalAI/core/services/testutil"
"github.com/mudler/LocalAI/core/services/workerctl"
"github.com/mudler/LocalAI/pkg/system"
)
// scriptedMessagingClient maps a NATS subject to a canned reply payload
@@ -311,9 +312,10 @@ var _ = Describe("DistributedBackendManager", func() {
mc = newScriptedMessagingClient()
adapter = NewRemoteUnloaderAdapter(nil, mc, 3*time.Minute, 15*time.Minute)
mgr = &DistributedBackendManager{
local: stubLocalBackendManager{},
adapter: adapter,
registry: registry,
local: stubLocalBackendManager{},
adapter: adapter,
registry: registry,
systemState: &system.SystemState{},
}
ctx = context.Background()
})
@@ -655,7 +657,7 @@ var _ = Describe("DistributedBackendManager", func() {
// mgr in the outer BeforeEach has progressSink=nil so the
// pre-existing specs keep verifying the no-sink behavior.
sink = &recordingProgressSink{}
appCfg := &config.ApplicationConfig{}
appCfg := &config.ApplicationConfig{SystemState: &system.SystemState{}}
mgr = NewDistributedBackendManager(appCfg, nil, adapter, registry, sink)
// stubLocalBackendManager mirrors the production behaviour
// where the frontend node rarely has the backend installed
@@ -13,6 +13,7 @@ import (
"github.com/mudler/LocalAI/core/services/messaging"
"github.com/mudler/LocalAI/core/services/testutil"
"github.com/mudler/LocalAI/core/services/workerctl"
"github.com/mudler/LocalAI/pkg/system"
)
// These specs pin the reactions the seams contract allows on ErrNoRoute: the
@@ -139,9 +140,10 @@ var _ = Describe("ErrNoRoute reactions", func() {
BeforeEach(func() {
mgr = &DistributedBackendManager{
local: stubLocalBackendManager{},
adapter: adapter,
registry: registry,
local: stubLocalBackendManager{},
adapter: adapter,
registry: registry,
systemState: &system.SystemState{},
}
})