CI / test (push) Failing after 7m1s
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>
58 lines
1.7 KiB
Go
58 lines
1.7 KiB
Go
package store
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestSlurmUsersGetLoginsAndUIDsOnce(t *testing.T) {
|
|
ctx := context.Background()
|
|
db := openDB(t)
|
|
for i, e := range []string{"ayse@a.test", "Ayse@b.test", "root@c.test", "9lives@d.test", "ali.veli@e.test"} {
|
|
id := "u" + string(rune('0'+i))
|
|
if err := db.CreateUser(ctx, User{ID: id, Email: e, Name: e, PasswordHash: "x", State: UserActive,
|
|
CreatedAt: time.Unix(int64(i), 0)}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
if err := db.CreateUser(ctx, User{ID: "p", Email: "pending@x.test", PasswordHash: "x", State: UserPending,
|
|
CreatedAt: time.Unix(9, 0)}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
us, err := db.SlurmUsers(ctx)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
want := []struct {
|
|
login string
|
|
uid int
|
|
}{{"ayse", 200000}, {"ayse2", 200001}, {"root2", 200002}, {"u9lives", 200003}, {"ali_veli", 200004}}
|
|
if len(us) != len(want) {
|
|
t.Fatalf("%d users: %+v", len(us), us)
|
|
}
|
|
for i, w := range want {
|
|
if us[i].Login != w.login || us[i].UID != w.uid {
|
|
t.Errorf("%s: %s %d, want %s %d", us[i].Email, us[i].Login, us[i].UID, w.login, w.uid)
|
|
}
|
|
}
|
|
if err := db.SetSlurmSSHKeys(ctx, "u0", []string{"ssh-ed25519 AAAA a", "ssh-ed25519 BBBB b"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
again, _ := db.SlurmUsers(ctx)
|
|
if again[0].UID != 200000 || len(again[0].SSHKeys) != 2 {
|
|
t.Fatalf("asked again: %+v", again[0])
|
|
}
|
|
// A deleted account's UID is not given again.
|
|
if _, err := db.raw.ExecContext(ctx, `DELETE FROM users WHERE id = 'u4'`); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := db.ApproveUser(ctx, "p", "", "admin", time.Now()); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
u, err := db.SlurmUserByID(ctx, "p")
|
|
if err != nil || u.UID != 200005 || u.Login != "pending" {
|
|
t.Fatalf("%+v %v", u, err)
|
|
}
|
|
}
|