Skip to content

Commit e8f9a67

Browse files
committed
update. lsshfs debug now
1 parent e7f9d9b commit e8f9a67

File tree

4 files changed

+4
-83
lines changed

4 files changed

+4
-83
lines changed

demo/e2e_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,9 @@ func testDemoProxyAndForwarding(t *testing.T, demoDir string) {
219219
if err == nil {
220220
t.Fatalf("expected lsshfs missing path mount to fail\noutput:\n%s", output)
221221
}
222-
if strings.Contains(output, "/home/demo/mnt/lsshfs-missing") {
223-
t.Fatalf("unexpected mount record/output for missing path\noutput:\n%s", output)
222+
records, listErr := runClientCommand(demoDir, "lsshfs --list-mounts")
223+
if listErr == nil && strings.Contains(records, "/home/demo/mnt/lsshfs-missing") {
224+
t.Fatalf("unexpected mount record for missing path\ncommand output:\n%s\nlist-mounts:\n%s", output, records)
224225
}
225226
})
226227

@@ -449,7 +450,7 @@ func startDemoLsshfsMount(t *testing.T, demoDir, remotePath, mountPoint, logPath
449450
deadline := time.Now().Add(20 * time.Second)
450451
for time.Now().Before(deadline) {
451452
output, err := runClientCommand(demoDir,
452-
fmt.Sprintf("grep -F %q /proc/mounts && lsshfs --list-mounts", mountPoint),
453+
fmt.Sprintf("grep -F %q /proc/mounts && lsshfs --list-mounts | grep -F %q", mountPoint, mountPoint),
453454
)
454455
if err == nil && strings.Contains(output, mountPoint) {
455456
return

internal/lsshfs/backend.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -158,28 +158,6 @@ func waitForMountActive(goos, mountpoint string, timeout time.Duration) error {
158158
return fmt.Errorf("mount did not become active: %s", mountpoint)
159159
}
160160

161-
func probeMountedFS(goos, mountpoint string, timeout time.Duration) error {
162-
if goos != "linux" {
163-
return nil
164-
}
165-
166-
done := make(chan error, 1)
167-
go func() {
168-
_, err := os.ReadDir(mountpoint)
169-
done <- err
170-
}()
171-
172-
select {
173-
case err := <-done:
174-
if err != nil {
175-
return fmt.Errorf("mounted filesystem is not responding: %s: %w", mountpoint, err)
176-
}
177-
return nil
178-
case <-time.After(timeout):
179-
return fmt.Errorf("mounted filesystem is not responding: %s", mountpoint)
180-
}
181-
}
182-
183161
func isMountActive(goos, mountpoint string) (bool, error) {
184162
switch goos {
185163
case "linux":

internal/lsshfs/runner.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ type Runner struct {
4141
execCommand func(name string, args ...string) *exec.Cmd
4242
createConnect func(*Runner) (mountConn, error)
4343
waitForMountActive func(goos, mountpoint string, timeout time.Duration) error
44-
probeMountedFS func(goos, mountpoint string, timeout time.Duration) error
4544
aliveCheckInterval time.Duration
4645
aliveFailureLimit int
4746
signalCh <-chan os.Signal
@@ -71,9 +70,6 @@ func (r *Runner) Run() error {
7170
if r.waitForMountActive == nil {
7271
r.waitForMountActive = waitForMountActive
7372
}
74-
if r.probeMountedFS == nil {
75-
r.probeMountedFS = probeMountedFS
76-
}
7773
if r.GOOS == "" {
7874
r.GOOS = currentGOOS
7975
}
@@ -184,12 +180,6 @@ func (r *Runner) Run() error {
184180
cleanup()
185181
return err
186182
}
187-
if backend == BackendFUSE {
188-
if err := r.probeMountedFS(r.GOOS, r.MountPoint, defaultMountActiveTimeout); err != nil {
189-
cleanup()
190-
return err
191-
}
192-
}
193183

194184
if r.ReadyNotifier != nil {
195185
r.ReadyNotifier()

internal/lsshfs/runner_behavior_test.go

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,6 @@ func TestRunnerRunWaitsForMountBeforeReady(t *testing.T) {
9090
}
9191
return nil
9292
},
93-
probeMountedFS: func(goos, mountpoint string, timeout time.Duration) error {
94-
if readyCalled {
95-
t.Fatal("ready notifier called before mounted filesystem probe")
96-
}
97-
return nil
98-
},
9993
ReadyNotifier: func() {
10094
readyCalled = true
10195
close(done)
@@ -165,9 +159,6 @@ func TestRunnerRunUnmountsOnDisconnect(t *testing.T) {
165159
waitForMountActive: func(goos, mountpoint string, timeout time.Duration) error {
166160
return nil
167161
},
168-
probeMountedFS: func(goos, mountpoint string, timeout time.Duration) error {
169-
return nil
170-
},
171162
execCommand: func(name string, args ...string) *exec.Cmd {
172163
commands = append(commands, name+" "+strings.Join(args, " "))
173164
return exec.Command("sh", "-c", "true")
@@ -227,9 +218,6 @@ func TestRunnerRunDoesNotUnmountOnSingleAliveFailure(t *testing.T) {
227218
waitForMountActive: func(goos, mountpoint string, timeout time.Duration) error {
228219
return nil
229220
},
230-
probeMountedFS: func(goos, mountpoint string, timeout time.Duration) error {
231-
return nil
232-
},
233221
execCommand: func(name string, args ...string) *exec.Cmd {
234222
return exec.Command("sh", "-c", "true")
235223
},
@@ -263,39 +251,3 @@ func TestRunnerRunDoesNotUnmountOnSingleAliveFailure(t *testing.T) {
263251
t.Fatalf("stderr = %q", stderr.String())
264252
}
265253
}
266-
267-
func TestRunnerRunReturnsErrorWhenMountedFilesystemProbeFails(t *testing.T) {
268-
t.Setenv("XDG_CACHE_HOME", t.TempDir())
269-
270-
done := make(chan struct{})
271-
var commands []string
272-
runner := &Runner{
273-
Host: "web01",
274-
RemotePath: "/srv/data",
275-
MountPoint: t.TempDir(),
276-
ReadWrite: true,
277-
GOOS: "linux",
278-
createConnect: func(r *Runner) (mountConn, error) {
279-
return &fakeMountConn{fuseBlock: done}, nil
280-
},
281-
waitForMountActive: func(goos, mountpoint string, timeout time.Duration) error {
282-
return nil
283-
},
284-
probeMountedFS: func(goos, mountpoint string, timeout time.Duration) error {
285-
close(done)
286-
return errors.New("probe timeout")
287-
},
288-
execCommand: func(name string, args ...string) *exec.Cmd {
289-
commands = append(commands, name+" "+strings.Join(args, " "))
290-
return exec.Command("sh", "-c", "true")
291-
},
292-
}
293-
294-
err := runner.Run()
295-
if err == nil || !strings.Contains(err.Error(), "probe timeout") {
296-
t.Fatalf("Run() error = %v", err)
297-
}
298-
if len(commands) == 0 {
299-
t.Fatalf("expected cleanup command on probe failure")
300-
}
301-
}

0 commit comments

Comments
 (0)