Files
llmgw/internal/control/slurmsvc/shared_test.go
T
Ilker ManapandClaude Opus 5.5 d8ce573bdb
CI / test (push) Failing after 7m1s
Slurm's shared files and users: one path everywhere, accounts as Linux users
slurm.shared mounts the site's NFS export, has an llmgw node export the path
over NFS to the Slurm machines alone (2049 in the firewall), or looks for a
file system the site mounts. slurm.users "llmgw" makes each active account a
Linux user on every Slurm machine: login from its e-mail, a UID from 200000
kept in slurm_users and never reused, its home on the shared path, its SSH
keys from the portal's Profile (or ctl slurm users keys) read by sshd from
/etc/llmgw/ssh-keys. server init --slurm chooses /shared from the first
machine and llmgw's users; --slurm-shared and --slurm-users change that.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 21:34:34 +01:00

86 lines
2.8 KiB
Go

package slurmsvc
import (
"context"
"errors"
"slices"
"testing"
"gitea.mynodes.xyz/ilker/llmgw/internal/config"
)
func TestSharedFilesFromTheController(t *testing.T) {
r := newRig()
r.set.Shared = config.SharedStorage{Path: "/shared", Server: "node06"}
r.tick()
ctl, node := r.agents.last("node06").GetShared(), r.agents.last("cuda01").GetShared()
if !ctl.GetServe() || !slices.Equal(ctl.GetClients(), []string{"10.0.0.147"}) || ctl.GetPath() != "/shared" {
t.Fatalf("server told %v", ctl)
}
if node.GetServe() || node.GetNfs() != "10.0.0.146:/shared" {
t.Fatalf("client told %v", node)
}
// The site's own export: every machine mounts it.
r.set.Shared = config.SharedStorage{Path: "/shared", NFS: "filer:/hpc"}
r.tick()
if r.agents.last("node06").GetShared().GetNfs() != "filer:/hpc" || r.agents.last("cuda01").GetShared().GetServe() {
t.Fatal("the site's export not sent")
}
}
func TestSharedServerNotKnownTellsNothing(t *testing.T) {
r := newRig()
r.set.Shared = config.SharedStorage{Path: "/shared", Server: "node06"}
delete(r.inv.nodes, "node06")
r.svc.known.ControllerAddr, r.svc.known.Controller = "10.0.0.146", "node06"
r.tick()
if r.agents.last("cuda01").GetShared().GetNfs() != "10.0.0.146:/shared" {
t.Fatalf("the kept address not used: %v", r.agents.last("cuda01"))
}
r2 := newRig()
r2.set.Nodes = []string{"cuda01", "site2"}
r2.agents.conn = append(r2.agents.conn, "site2")
r2.set.Shared = config.SharedStorage{Path: "/shared", Server: "site2"}
r2.tick()
if r2.agents.last("cuda01") != nil {
t.Fatal("told with no address for the server: its mount would go")
}
}
func TestUsersSentOnceRead(t *testing.T) {
r := newRig()
r.set.Users = config.UsersLlmgw
r.set.Shared = config.SharedStorage{Path: "/shared", Server: "node06"}
fail := true
r.svc.SetUsers(func(context.Context) ([]User, error) {
if fail {
return nil, errors.New("store down")
}
return []User{{Login: "ayse", UID: 200000, Name: "Ayşe", SSHKeys: []string{"ssh-ed25519 AAAA"}}}, nil
})
r.tick()
if len(r.agents.got["cuda01"]) != 0 {
t.Fatal("told before the users were read: every user would go")
}
fail = false
r.svc.UsersChanged()
r.tick()
ctl, node := r.agents.last("node06"), r.agents.last("cuda01")
if !ctl.GetManageUsers() || !ctl.GetMakeHomes() || node.GetMakeHomes() || len(node.GetUsers()) != 1 {
t.Fatalf("controller %v\nnode %v", ctl, node)
}
if u := node.GetUsers()[0]; u.GetHome() != "/shared/home/ayse" || u.GetUid() != 200000 || len(u.GetSshKeys()) != 1 {
t.Fatalf("user %v", u)
}
// The store down later: the last users are kept.
fail = true
r.svc.UsersChanged()
r.tick()
if len(r.agents.last("cuda01").GetUsers()) != 1 {
t.Fatal("users lost when the store could not be read")
}
if st := r.svc.Status(); st.UserCount != 1 || st.Shared.Server != "node06" {
t.Fatalf("status %+v", st)
}
}