mirror of
https://github.com/langgenius/dify.git
synced 2026-11-12 22:31:24 +08:00
Track backend integration, Ruff cleanup and migration reconciliation in ENG-1271. Retain required copy contracts without implementing frontend interactions.
50 lines
1.5 KiB
Go
50 lines
1.5 KiB
Go
//go:build linux
|
|
|
|
package testscope
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestDelegationRequiresRealCgroupFilesystem(t *testing.T) {
|
|
d := t.TempDir()
|
|
for _, name := range []string{"cgroup.controllers", "cgroup.subtree_control", "cgroup.kill"} {
|
|
if err := os.WriteFile(filepath.Join(d, name), []byte("cpu memory pids"), 0600); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
if err := ValidateDelegation(d); err == nil {
|
|
t.Fatal("ordinary directory advertised as delegated cgroup")
|
|
}
|
|
}
|
|
func TestLimitValidationRequiresEveryFiniteBound(t *testing.T) {
|
|
l := validSpec().Limits
|
|
for _, bad := range []Limits{{}, {CPUQuota: l.CPUQuota, MemoryBytes: l.MemoryBytes, PIDs: l.PIDs, FDs: l.FDs, WallSeconds: l.WallSeconds, InputBytes: l.InputBytes, OutputBytes: l.OutputBytes}} {
|
|
if bad.Validate() == nil {
|
|
t.Fatal("accepted omitted resource limit")
|
|
}
|
|
}
|
|
}
|
|
func TestOutputSpoolBoundCountsBothStreamsAcrossJobs(t *testing.T) {
|
|
dir := t.TempDir()
|
|
for _, job := range []string{"a", "b"} {
|
|
if err := os.Mkdir(filepath.Join(dir, job), 0700); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.WriteFile(filepath.Join(dir, job, "output.log"), make([]byte, 80), 0600); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
if CheckOutputSpool(dir, 200) != nil {
|
|
t.Fatal("bounded spool refused")
|
|
}
|
|
if err := os.WriteFile(filepath.Join(dir, "a", "stderr.log"), make([]byte, 80), 0600); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if CheckOutputSpool(dir, 200) == nil {
|
|
t.Fatal("accepted aggregate output overflow")
|
|
}
|
|
}
|