- Pass --ignore-inode for sources below /mnt/user and /mnt/user0. shfs hands out new inode numbers after every reboot, which made Restic re-read all data on the first run after a restart. - Add a per-job lowPriority option that starts Restic and Rsync through ionice (idle) and nice 19 via the new internal/procprio package. - Run restic forget with --group-by host,tags. Grouping by paths split a job into a new group whenever its sources changed, and keep-within never expired the old group's snapshots. - Verify the Unraid CSRF token in webgui/api.php for POST, PUT and DELETE and reject other methods; Unraid's own check only covers form posts. - Set $urbmVersion in URBM.page during the package build and fail the build if it does not match, so the page always loads the packaged JS asset. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
50 lines
1.6 KiB
Go
50 lines
1.6 KiB
Go
package procprio
|
|
|
|
import (
|
|
"errors"
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func withTools(t *testing.T, tools map[string]string) {
|
|
t.Helper()
|
|
previous := lookPath
|
|
lookPath = func(name string) (string, error) {
|
|
if path, ok := tools[name]; ok {
|
|
return path, nil
|
|
}
|
|
return "", errors.New("not found")
|
|
}
|
|
t.Cleanup(func() { lookPath = previous })
|
|
}
|
|
|
|
func TestCommandUnchangedWithoutLowPriority(t *testing.T) {
|
|
withTools(t, map[string]string{"ionice": "/usr/bin/ionice", "nice": "/usr/bin/nice"})
|
|
name, args := Command(false, "/bin/restic", []string{"backup", "/src"})
|
|
if name != "/bin/restic" || !reflect.DeepEqual(args, []string{"backup", "/src"}) {
|
|
t.Fatalf("got %q %q", name, args)
|
|
}
|
|
}
|
|
|
|
func TestCommandWrapsWithIoniceAndNice(t *testing.T) {
|
|
withTools(t, map[string]string{"ionice": "/usr/bin/ionice", "nice": "/usr/bin/nice"})
|
|
name, args := Command(true, "/bin/restic", []string{"backup", "/src"})
|
|
want := []string{"-c", "3", "/usr/bin/nice", "-n", "19", "/bin/restic", "backup", "/src"}
|
|
if name != "/usr/bin/ionice" || !reflect.DeepEqual(args, want) {
|
|
t.Fatalf("got %q %q", name, args)
|
|
}
|
|
}
|
|
|
|
func TestCommandSkipsMissingTools(t *testing.T) {
|
|
withTools(t, map[string]string{"nice": "/usr/bin/nice"})
|
|
name, args := Command(true, "/bin/rsync", []string{"-a"})
|
|
if name != "/usr/bin/nice" || !reflect.DeepEqual(args, []string{"-n", "19", "/bin/rsync", "-a"}) {
|
|
t.Fatalf("got %q %q", name, args)
|
|
}
|
|
withTools(t, map[string]string{})
|
|
name, args = Command(true, "/bin/rsync", []string{"-a"})
|
|
if name != "/bin/rsync" || !reflect.DeepEqual(args, []string{"-a"}) {
|
|
t.Fatalf("got %q %q", name, args)
|
|
}
|
|
}
|