operation: warm lazy log fds in the file-part leak test

This commit is contained in:
Devin committed 2026-10-21 15:15:01 -07:00
1 parent 371d320854
commit a1d2ebbb9b
1 file changed
+10 -2
+10 -2
View File
@@ -4,19 +4,27 @@ import (
"os"
"path/filepath"
"testing"
"github.com/seaweedfs/seaweedfs/weed/glog"
)
func TestNewFilePartsClosesOnError(t *testing.T) {
dir := t.TempDir()
missing := filepath.Join(dir, "missing.txt")
if _, err := NewFileParts([]string{missing}); err == nil {
t.Skip("missing file unexpectedly opened")
}
glog.Flush()
fdsBefore, err := os.ReadDir("/proc/self/fd")
if err != nil {
t.Skip("fd counting requires /proc")
}
dir := t.TempDir()
good := filepath.Join(dir, "good.txt")
if err := os.WriteFile(good, []byte("x"), 0644); err != nil {
t.Fatal(err)
}
if _, err := NewFileParts([]string{good, filepath.Join(dir, "missing.txt")}); err == nil {
if _, err := NewFileParts([]string{good, missing}); err == nil {
t.Fatal("expected error for missing file")
}
fdsAfter, err := os.ReadDir("/proc/self/fd")