A model can be stopped and kept, or removed with its files from the mirror and the nodes
CI / test (push) Successful in 10m37s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-10-29 20:45:48 +01:00
1 parent 5726ceb84e
commit 59187cdae5
19 files changed
+760 -14

No files matched your search

@@ -400,3 +400,41 @@ func TestAddNewLeavesAModelAddedMeanwhile(t *testing.T) {
t.Errorf("a new model: %v", err)
}
}
func TestAStoppedModelRunsNoneAndStartsAsItWas(t *testing.T) {
s, _, rec := newService(t)
if err := s.Add(t.Context(), model("added"), "ilker"); err != nil {
t.Fatal(err)
}
if _, err := s.Scale(t.Context(), "added", catalog.Scaling{Min: 2, Max: 4, IdleTimeout: 20 * time.Minute}, "ilker"); err != nil {
t.Fatal(err)
}
got, err := s.Stop(t.Context(), "added", "ilker")
if err != nil {
t.Fatal(err)
}
if got.Scaling.Min != 0 || got.Scaling.Max != 0 || got.Stopped == nil || got.Stopped.Min != 2 {
t.Fatalf("stopped: %+v %+v", got.Scaling, got.Stopped)
}
if m, _ := rec.last.Resolve("added"); m.Scaling.Max != 0 || m.Scaling.OnDemand() {
t.Errorf("the catalog in force runs it: %+v", m.Scaling)
}
if _, err := s.Stop(t.Context(), "added", "ilker"); err == nil {
t.Error("stopped twice")
}
got, err = s.Start(t.Context(), "added", "ilker")
if err != nil {
t.Fatal(err)
}
if got.Scaling.Min != 2 || got.Scaling.Max != 4 || got.Scaling.IdleTimeout != 20*time.Minute || got.Stopped != nil {
t.Errorf("started: %+v %+v", got.Scaling, got.Stopped)
}
if _, err := s.Start(t.Context(), "added", "ilker"); err == nil {
t.Error("started what was not stopped")
}
// A scale while stopped starts it at that number.
_, _ = s.Stop(t.Context(), "added", "ilker")
if got, _ := s.Scale(t.Context(), "added", catalog.Scaling{Min: 1}, "ilker"); got.Stopped != nil {
t.Error("still stopped after a scale")
}
}