CI / test (push) Successful in 9m30s
The choices screen has a Slurm part, and --slurm writes slurmctld on this machine's node and slurmd on every node, those that join later too, into server.yaml. slurm.all_nodes (ctl slurm setup --all-nodes) takes the nodes from the leader's inventory. No node is lent at install. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
54 lines
1.8 KiB
Go
54 lines
1.8 KiB
Go
package config
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestSlurmCheck(t *testing.T) {
|
|
ok := SlurmSettings{Enabled: true, Controller: "node06", Nodes: []string{"cuda01", "site2"}, Lent: []string{"cuda01"}}
|
|
if err := ok.Check(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !ok.IsLent("cuda01") || ok.IsLent("site2") || ok.IsLent("node06") {
|
|
t.Error("IsLent is wrong")
|
|
}
|
|
if ok.Cluster() != "llmgw" || ok.PartitionName() != "gpu" {
|
|
t.Error("defaults are wrong")
|
|
}
|
|
if (SlurmSettings{Lent: []string{"x"}}).Check() != nil {
|
|
t.Error("settings that are off were checked")
|
|
}
|
|
for want, s := range map[string]SlurmSettings{
|
|
"controller is empty": {Enabled: true},
|
|
"not a name": {Enabled: true, Controller: "bad name"},
|
|
"twice": {Enabled: true, Controller: "c", Nodes: []string{"a", "a"}},
|
|
"not in slurm.nodes": {Enabled: true, Controller: "c", Nodes: []string{"a"}, Lent: []string{"b"}},
|
|
"slurm.partition": {Enabled: true, Controller: "c", Partition: "a b"},
|
|
} {
|
|
if err := s.Check(); err == nil || !strings.Contains(err.Error(), want) {
|
|
t.Errorf("%+v: got %v, want %q", s, err, want)
|
|
}
|
|
}
|
|
if (SlurmSettings{Enabled: false, Lent: []string{"a"}}).IsLent("a") {
|
|
t.Error("a node is lent with Slurm off")
|
|
}
|
|
}
|
|
|
|
func TestSlurmAllNodes(t *testing.T) {
|
|
s := SlurmSettings{Enabled: true, Controller: "c", AllNodes: true, Lent: []string{"joined"}}
|
|
if err := s.Check(); err != nil {
|
|
t.Fatalf("a node lent with all_nodes refused: %v", err)
|
|
}
|
|
if !s.IsLent("joined") {
|
|
t.Fatal("not lent with all_nodes")
|
|
}
|
|
if got := s.WithNodes([]string{"a", "joined"}).Nodes; len(got) != 2 {
|
|
t.Fatalf("nodes %v", got)
|
|
}
|
|
s.AllNodes = false
|
|
if s.Check() == nil || len(s.WithNodes([]string{"a"}).Nodes) != 0 {
|
|
t.Fatal("all_nodes off still takes the inventory's nodes")
|
|
}
|
|
}
|