mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-10-22 22:11:39 +02:00
fuse integration: honor TestConfig and own only self-started resources
NewFuseTestFramework dropped its config argument and Cleanup read a fresh DefaultTestConfig, so SkipCleanup never did anything. Cleanup also skipped teardown whenever TEST_SKIP_CLUSTER_SETUP was set, even when TEST_MOUNT_POINT was empty and Setup had started the cluster itself. The framework now keeps the config it was built with, runs external-mount tests inside a per-run work dir under the mount, and only skips teardown when an external mount was actually used. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
2431c20e55
commit
9e62367e1a
1 file changed
+25
-7
@@ -29,6 +29,8 @@ type FuseTestFramework struct {
|
||||
filerAddr string
|
||||
weedBinary string
|
||||
isSetup bool
|
||||
config *TestConfig
|
||||
externalMount bool
|
||||
}
|
||||
|
||||
// TestConfig holds configuration for FUSE tests
|
||||
@@ -76,6 +78,7 @@ func NewFuseTestFramework(t *testing.T, config *TestConfig) *FuseTestFramework {
|
||||
filerAddr: "127.0.0.1:18888",
|
||||
weedBinary: findWeedBinary(),
|
||||
isSetup: false,
|
||||
config: config,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,19 +87,30 @@ func (f *FuseTestFramework) Setup(config *TestConfig) error {
|
||||
if f.isSetup {
|
||||
return fmt.Errorf("framework already setup")
|
||||
}
|
||||
if config != nil {
|
||||
f.config = config
|
||||
}
|
||||
|
||||
// Check if we should skip cluster setup and use existing mount
|
||||
if os.Getenv("TEST_SKIP_CLUSTER_SETUP") == "true" {
|
||||
// Use existing mount point from environment
|
||||
if existingMount := os.Getenv("TEST_MOUNT_POINT"); existingMount != "" {
|
||||
f.mountPoint = existingMount
|
||||
f.t.Logf("Using existing mount point: %s", f.mountPoint)
|
||||
f.externalMount = true
|
||||
|
||||
// Verify mount point is accessible
|
||||
if _, err := os.Stat(f.mountPoint); err != nil {
|
||||
if _, err := os.Stat(existingMount); err != nil {
|
||||
return fmt.Errorf("existing mount point not accessible: %v", err)
|
||||
}
|
||||
|
||||
// Run inside a private work dir so test files do not pile up in
|
||||
// the shared mount root and cleanup can remove only what it made
|
||||
workDir, err := os.MkdirTemp(existingMount, ".fuse_test_")
|
||||
if err != nil {
|
||||
return fmt.Errorf("creating work dir under existing mount: %v", err)
|
||||
}
|
||||
f.mountPoint = workDir
|
||||
f.t.Logf("Using existing mount point: %s (work dir %s)", existingMount, f.mountPoint)
|
||||
|
||||
// Test basic functionality
|
||||
testFile := filepath.Join(f.mountPoint, ".framework_test")
|
||||
if err := os.WriteFile(testFile, []byte("test"), 0644); err != nil {
|
||||
@@ -186,9 +200,13 @@ func (f *FuseTestFramework) Setup(config *TestConfig) error {
|
||||
|
||||
// Cleanup stops all processes and removes temporary files
|
||||
func (f *FuseTestFramework) Cleanup() {
|
||||
// Skip cleanup if using external cluster
|
||||
if os.Getenv("TEST_SKIP_CLUSTER_SETUP") == "true" {
|
||||
f.t.Logf("Skipping cleanup - using external SeaweedFS cluster")
|
||||
// An external mount needs no teardown; only this run's work dir is ours.
|
||||
// A TEST_SKIP_CLUSTER_SETUP that fell through to a self-started cluster
|
||||
// still owns its processes and must not skip stopping them.
|
||||
if f.externalMount {
|
||||
if !f.config.SkipCleanup {
|
||||
os.RemoveAll(f.mountPoint)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -206,7 +224,7 @@ func (f *FuseTestFramework) Cleanup() {
|
||||
}
|
||||
|
||||
// Remove temp directory
|
||||
if !DefaultTestConfig().SkipCleanup {
|
||||
if !f.config.SkipCleanup {
|
||||
os.RemoveAll(f.tempDir)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user