package web import ( "net/url" "strings" "testing" "time" "gitea.mynodes.xyz/ilker/llmgw/internal/control/adminapi" "gitea.mynodes.xyz/ilker/llmgw/internal/hf" ) // strataFleet is one node with an RTX 6000, 251 GB and Strata installed. type strataFleet struct{ fakeFleet } func (strataFleet) Nodes() []adminapi.NodeView { return []adminapi.NodeView{{ID: "cuda01", State: "ready", GPUTotal: 1, GPUFree: 1, MemoryGB: 251, Classes: []string{"6000-24g"}, Engines: []string{"llamacpp", "strata"}, ComputeCapabilities: []string{"7.5"}}} } func TestTheStrataTabListsWhatRunsHereAndFetchesASize(t *testing.T) { reg := &fakeRegistry{repo: hf.Repo{ID: "ISTA-DASLab/Qwen3.8-Flash-Next-GSQ-RCO-GGUF", Revision: "0123456789abcdef0123456789abcdef01234567", Files: []hf.File{ {Path: "IQ2_XS/Qwen3.8-Flash-Next-GSQ-RCO-IQ2_XS-00001-of-00002.gguf", SHA256: "aa"}, {Path: "IQ2_XS/Qwen3.8-Flash-Next-GSQ-RCO-IQ2_XS-00002-of-00002.gguf", SHA256: "bb"}, {Path: "IQ3_S/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S-00001-of-00002.gguf"}, {Path: "mmproj-Qwen3.8-Flash-Next-BF16.gguf"}, }}} m := &fakeMirror{} mux := mirrorPageDeps(t, MirrorDeps{Mirror: m, Registry: reg, Fleet: strataFleet{}}, true) body := mirrorGet(t, mux, "/admin/mirror?tab=strata").Body.String() for _, want := range []string{"Strata is installed on: cuda01", "Qwen3.8-Flash-Next", "IQ2_XS", "1× 6000-24g with Strata, 52 GB of RAM", `name="size" value="IQ2_XS"`, "Strata fetches these onto the node itself", "compute capability 8.6 or newer"} { if !strings.Contains(body, want) { t.Errorf("the tab lacks %q", want) } } // Unsloth's Q8_0 keeps 140 GB: it runs here; nothing past the node's RAM does. if strings.Contains(body, `value="UD-Q8_K_XL"`) || strings.Contains(body, `value="IST-DAS-1.75bpw"`) { t.Error("offered DeepSeek's 306 GB size, which no node holds, and which Strata fetches itself") } mirrorPost(t, mux, "/admin/mirror/strata", url.Values{"csrf": {"tok"}, "family": {"qwen"}, "size": {"IQ2_XS"}}) if len(m.all) != 2 { t.Fatalf("fetched %+v", m.all) } f := m.all[0] if f.Model != "qwen3.8-flash-next-iq2_xs" || f.Version != "01234567" || f.SHA256 != "aa" || !strings.Contains(f.Source, "/resolve/0123456789abcdef0123456789abcdef01234567/IQ2_XS/") { t.Errorf("%+v", f) } } // A ready-made pack is served at once, its repository the source, Strata // fetching it onto the node. func TestAReadyMadeStrataPackIsServedFromTheTab(t *testing.T) { cat := &fakeCatalog{} mux := mirrorPageDeps(t, MirrorDeps{Mirror: &fakeMirror{}, Registry: &fakeRegistry{}, Catalog: cat, Fleet: strataFleet{}}, true) if body := mirrorGet(t, mux, "/admin/mirror?tab=strata").Body.String(); !strings.Contains(body, `name="action" value="serve"`) { t.Fatal("no serve button for a pack") } mirrorPost(t, mux, "/admin/mirror/strata", url.Values{"csrf": {"tok"}, "action": {"serve"}, "family": {"nvfp4"}, "size": {"NVFP4"}}) if len(cat.added) != 1 { t.Fatalf("added %+v", cat.added) } m := cat.added[0] p := m.Profiles[0] if m.Name != "qwen3.8-flash-next-nvfp4-nvfp4" || m.Source != "Maximilian228/Qwen3.8-Flash-Next-NVFP4-GPTQ-Strata" || p.Engine != "strata" || p.GPUClass != "6000-24g" || p.MinMemoryGB != 84 || p.StartupTimeout < time.Hour || strings.Join(p.Args, " ") != "--family nvfp4 --size NVFP4 --context 32768 --vision no" { t.Errorf("%+v", m) } } func TestAStrataPacksFilesAreNamedForWhatTheyAre(t *testing.T) { for repo, want := range map[string]string{ "Maximilian228/Qwen3.8-Flash-Next-NVFP4-GPTQ-Strata": "ready-made Qwen3.8-Flash-Next (NVFP4) NVFP4 pack", "trymirai/Qwen3.8-Flash-Next-S-strata-experimental": "Strata 0.2.7 does not know", } { reg := &fakeRegistry{repo: hf.Repo{ID: repo, Architecture: "strata-ple", Revision: "abc", Files: []hf.File{{Path: "ple-fp8.gguf", Bytes: 51e9}}}} mux := mirrorPageDeps(t, MirrorDeps{Mirror: &fakeMirror{}, Registry: reg, Fleet: strataFleet{}}, true) if body := mirrorGet(t, mux, "/admin/mirror?repo="+repo).Body.String(); !strings.Contains(body, want) { t.Errorf("%s: no %q", repo, want) } } }