Skip to content

Commit

Permalink
Remove jacobsa/fuse dependency from goofys_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalif committed Jun 13, 2023
1 parent 9a7b0e3 commit 1f1be5d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 30 deletions.
30 changes: 17 additions & 13 deletions internal/goofys_fuse.go
Original file line number Diff line number Diff line change
Expand Up @@ -928,46 +928,50 @@ func MountFuse(
ctx context.Context,
bucketName string,
flags *FlagStorage) (fs *Goofys, mfs MountedFS, err error) {
fs, err = NewGoofys(ctx, bucketName, flags)
if fs == nil {
if err == nil {
err = fmt.Errorf("Mount: initialization failed")
}
return
}
mfs, err = mountFuseFS(fs)
return
}

func mountFuseFS(fs *Goofys) (mfs MountedFS, err error) {
// Mount the file system.
mountCfg := &fuse.MountConfig{
FSName: bucketName,
FSName: fs.bucket,
Subtype: "geesefs",
Options: convertFuseOptions(flags),
Options: convertFuseOptions(fs.flags),
ErrorLogger: GetStdLogger(NewLogger("fuse"), logrus.ErrorLevel),
DisableWritebackCaching: true,
UseVectoredRead: true,
}

if flags.DebugFuse {
if fs.flags.DebugFuse {
fuseLog := GetLogger("fuse")
fuseLog.Level = logrus.DebugLevel
mountCfg.DebugLogger = GetStdLogger(fuseLog, logrus.DebugLevel)
}

if flags.DebugFuse || flags.DebugMain {
if fs.flags.DebugFuse || fs.flags.DebugMain {
log.Level = logrus.DebugLevel
}

fs, err = NewGoofys(ctx, bucketName, flags)
if fs == nil {
if err == nil {
err = fmt.Errorf("Mount: initialization failed")
}
return
}
fsint := NewGoofysFuse(fs)
server := fuseutil.NewFileSystemServer(fsint)

fuseMfs, err := fuse.Mount(flags.MountPoint, server, mountCfg)
fuseMfs, err := fuse.Mount(fs.flags.MountPoint, server, mountCfg)
if err != nil {
err = fmt.Errorf("Mount: %v", err)
return
}

mfs = &FuseMfsWrapper{
MountedFileSystem: fuseMfs,
mountPoint: flags.MountPoint,
mountPoint: fs.flags.MountPoint,
}

return
Expand Down
20 changes: 3 additions & 17 deletions internal/goofys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ import (

"golang.org/x/sys/unix"

"github.com/jacobsa/fuse"
"github.com/jacobsa/fuse/fuseops"
"github.com/jacobsa/fuse/fuseutil"

"github.com/pkg/xattr"

Expand Down Expand Up @@ -124,6 +122,7 @@ func currentGid() uint32 {

type GoofysTest struct {
fs *GoofysFuse
mfs MountedFS
ctx context.Context
awsConfig *aws.Config
cloud StorageBackend
Expand Down Expand Up @@ -1964,28 +1963,15 @@ func (s *GoofysTest) mountSame(t *C, mountPoint string, sameProc bool) {
t.Assert(err, IsNil)

} else {
server := fuseutil.NewFileSystemServer(s.fs)

// Mount the file system.
mountCfg := &fuse.MountConfig{
FSName: s.fs.bucket,
Subtype: "geesefs",
Options: convertFuseOptions(s.fs.flags),
ErrorLogger: GetStdLogger(NewLogger("fuse"), logrus.ErrorLevel),
DisableWritebackCaching: true,
UseVectoredRead: true,
}
mountCfg.DebugLogger = GetStdLogger(fuseLog, logrus.DebugLevel)

_, err = fuse.Mount(mountPoint, server, mountCfg)
s.mfs, err = mountFuseFS(s.fs.Goofys)
t.Assert(err, IsNil)
}
}

func (s *GoofysTest) umount(t *C, mountPoint string) {
var err error
for i := 0; i < 10; i++ {
err = fuse.Unmount(mountPoint)
err = TryUnmount(mountPoint)
if err != nil {
time.Sleep(100 * time.Millisecond)
} else {
Expand Down

0 comments on commit 1f1be5d

Please sign in to comment.