CI / test (push) Successful in 10m57s
Since 23.11 Slurm runs badly without accounting storage: the main scheduler passes every job by as InvalidAccount. slurmdbd takes MySQL or MariaDB only, so the controller's agent installs MariaDB beside it, answering that machine alone, makes the database and its user (the password made from the munge key, never on a command line), runs slurmdbd and adds the cluster, all before slurmctld. A MariaDB that was on the machine before keeps its settings. slurm.conf accounts the jobs there, with what each used from its cgroup and the cards, and the priority is multifactor again. Port 6819 joins Slurm's in the firewall. ctl slurm status and the console say whether slurmdbd runs; the install screen, server init --slurm and the guide say what is put where. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
93 lines
3.2 KiB
Go
93 lines
3.2 KiB
Go
package cli
|
|
|
|
import (
|
|
"encoding/json"
|
|
"io"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"strings"
|
|
"sync"
|
|
"testing"
|
|
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
|
|
"gitea.mynodes.xyz/ilker/llmgw/internal/control/adminapi"
|
|
"gitea.mynodes.xyz/ilker/llmgw/internal/control/slurmsvc"
|
|
)
|
|
|
|
func TestTheConsoleLendsANodeToSlurmFromItsRow(t *testing.T) {
|
|
var mu sync.Mutex
|
|
var put adminapi.SettingsRequest
|
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
switch {
|
|
case r.Method == http.MethodGet && r.URL.Path == "/api/v1/settings":
|
|
_ = json.NewEncoder(w).Encode(adminapi.SettingsView{Version: 7,
|
|
Body: "slurm:\n enabled: true\n controller: node06\n nodes: [node05, cuda01]\n"})
|
|
case r.Method == http.MethodPut && r.URL.Path == "/api/v1/settings":
|
|
b, _ := io.ReadAll(r.Body)
|
|
mu.Lock()
|
|
_ = json.Unmarshal(b, &put)
|
|
mu.Unlock()
|
|
_ = json.NewEncoder(w).Encode(adminapi.SettingsView{Version: 8})
|
|
default:
|
|
_, _ = w.Write([]byte("[]"))
|
|
}
|
|
}))
|
|
t.Cleanup(srv.Close)
|
|
m := newConsoleModel(srv.URL, "/nonexistent/server.yaml")
|
|
m.loaded, m.menu, m.inPanel = true, cSlurm, true
|
|
m.data.slurm = slurmsvc.Status{Enabled: true, Cluster: "llmgw", Controller: "node06", Partition: "gpu",
|
|
Ctld: &slurmsvc.Reported{SlurmctldRunning: true, SlurmdbdRunning: true, Version: "23.11.4"},
|
|
Nodes: []slurmsvc.NodeStatus{
|
|
{Node: "node05", Phase: slurmsvc.Lent, Connected: true,
|
|
Status: &slurmsvc.Reported{State: "MIXED", Jobs: 2, SlurmdRunning: true}},
|
|
{Node: "cuda01", Phase: slurmsvc.Llmgw, Replicas: 3, Connected: true,
|
|
Status: &slurmsvc.Reported{State: "IDLE+DRAIN", SlurmdRunning: true}},
|
|
}}
|
|
var tm tea.Model = m
|
|
view := tm.View()
|
|
for _, want := range []string{"slurmctld 23.11.4 and slurmdbd running", "node05", "Slurm's", "MIXED", "cuda01", "llmgw's"} {
|
|
if !strings.Contains(view, want) {
|
|
t.Errorf("the Slurm view has no %q:\n%s", want, view)
|
|
}
|
|
}
|
|
|
|
// cuda01, the second row: lent, after saying its replicas move.
|
|
tm = press(tm, "down", "enter")
|
|
if !strings.Contains(tm.View(), "Lend to Slurm") {
|
|
t.Fatalf("no lend in the menu:\n%s", tm.View())
|
|
}
|
|
tm = press(tm, "enter")
|
|
if !strings.Contains(tm.View(), "3 replica(s) move off first") {
|
|
t.Fatalf("the question does not say what moves:\n%s", tm.View())
|
|
}
|
|
tm = pressRun(tm, "y")
|
|
mu.Lock()
|
|
defer mu.Unlock()
|
|
if put.Base != 7 || !strings.Contains(put.Body, "lent:") || !strings.Contains(put.Body, "cuda01") {
|
|
t.Fatalf("the settings put back: %+v", put)
|
|
}
|
|
if !strings.Contains(tm.View(), "cuda01 is being lent to Slurm") {
|
|
t.Errorf("not said:\n%s", tm.View())
|
|
}
|
|
}
|
|
|
|
func TestTheConsoleTakesALentNodeBack(t *testing.T) {
|
|
m, _ := consoleWith(t, cSlurm)
|
|
m.data.slurm = slurmsvc.Status{Enabled: true, Controller: "node06",
|
|
Nodes: []slurmsvc.NodeStatus{{Node: "node05", Phase: slurmsvc.Lent, Connected: true}}}
|
|
var tm tea.Model = m
|
|
tm = press(tm, "enter")
|
|
if v := tm.View(); !strings.Contains(v, "Take back from Slurm") || strings.Contains(v, "Lend to Slurm") {
|
|
t.Fatalf("a lent node's menu:\n%s", v)
|
|
}
|
|
}
|
|
|
|
func TestTheConsoleSaysHowToTurnSlurmOn(t *testing.T) {
|
|
m, _ := consoleWith(t, cSlurm)
|
|
var tm tea.Model = m
|
|
if !strings.Contains(tm.View(), "llmgw ctl slurm setup") {
|
|
t.Fatalf("Slurm off says nothing of turning it on:\n%s", tm.View())
|
|
}
|
|
}
|