mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 18:47:20 +01:00
operation: warm lazy log fds in the file-part leak test
This commit is contained in:
1 parent
371d320854
commit
a1d2ebbb9b
1 file changed
+10
-2
@@ -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")
|
||||
|
||||
Reference in new issue
Block a user