Files
seaweedfs/test/fuse_integration
Chris LuandDevin 7c980774e7 FUSE mount: add posix compliance reports (#7183)
* fuse integration: add POSIX compliance test suite

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* ci: add posix-compliance workflow

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fuse integration: skip non-executable weed path candidates

* fuse integration: size readv buffer to the written segment

* fuse integration: reference posix_Makefile explicitly in recursive make calls

GNU make does not propagate -f through MAKEFLAGS, so bare $(MAKE) re-read the default Makefile in this directory.

* fuse integration: fail posix test targets when go test fails

Every suite pipes go test through tee under /bin/sh, so the recipe status was tee's and test failures stayed green. Run recipes under bash -o pipefail and emit the color escapes with printf since bash echo does not expand them.

* fuse integration: run only benchmarks in benchmark-posix

go test -bench=. without -run also executes the whole suite, mixing compliance output into the benchmark log.

* fuse integration: emit single-number test counts in reports

grep -c prints 0 and exits nonzero when nothing matches, so '|| echo 0' produced two lines that broke the expr arithmetic and JSON fields. awk prints exactly one count either way.

* fuse integration: skip the sendfile test on macOS

macOS sendfile(2) only accepts a socket destination; the test copies into a regular file and always gets ENOTSOCK.

* 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>

* fuse integration: pass the debug flag before the subcommand

-v is a weed global flag; appended after master/volume/filer/mount it lands
on the subcommand flagset, which rejects it and the process dies at flag
parsing whenever EnableDebug is on.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fuse integration: require a real mount before running tests

Setup creates the mount point before weed mount starts, so statting and
listing it succeeded on the plain directory and tests ran against local
disk whenever the mount was slow or died. waitForMount now waits until the
mount point's device id differs from its parent's.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fuse integration: resolve the weed binary to an absolute path

The started processes run with cmd.Dir at the framework's temp dir, so a
relative candidate like ../weed no longer resolves. Prefer PATH, then probe
the usual build outputs and return absolute paths only.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fuse integration: build the external test work dir with MkdirTemp

The suite staged cloned tools and generated scripts under a predictable
/tmp path another user could pre-create and swap mid-run.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fuse integration: use the pjdfstest tree setup-pjdfstest installs

The test gated on a pjdfstest binary in PATH but then proved a suite it
cloned itself, so a tree installed by make setup-pjdfstest was never found.
Look for the built suite under external_tools first, then clone into the
work dir as before.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* ci: require a real mount before posix tests

The wait loop fell back to listing the mount point, which passes on the
directory created before weed mount runs — a dead or slow mount meant the
suite exercised local disk. Only mountpoint counts now, and a dead mount
process fails fast instead of timing out.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* ci: collect failure logs before cleanup deletes them

The always-on cleanup step removed /tmp/seaweedfs before the failure-only
debug step could copy the service logs, so failed runs uploaded nothing.
Run cleanup after log collection.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fuse integration: point MOUNT_POINT at TEST_MOUNT_POINT

Targets that work against MOUNT_POINT (pjdfstest, nfstest, fio configs)
ignored TEST_MOUNT_POINT and ran against the local-disk default while the
go tests used the external mount.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fuse integration: skip the permission-denied check as root

Root bypasses mode-bit checks, so writing the read-only file succeeded and
the assertion failed in root-run environments like containers.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fuse integration: align the posix docs with the suite

The doc listed a docker-test-posix target and make variables that do not
exist, and ran go test against single files that cannot compile alone. The
roadmap also still claimed the platform-specific tests this suite now
implements were all skipped.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fuse integration: honor SkipCleanup in the mini-based framework too

Same gap as the fuse-package framework: Cleanup read a fresh
DefaultTestConfig, so a test's SkipCleanup setting was ignored.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fuse integration: normalize config in Setup and clean the work dir too

Setup(nil) panicked on config.EnableDebug and external-mount Cleanup left
the temp dir behind; use the stored config for the start* calls and remove
tempDir alongside the external work dir.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* ci: point external posix suites at the workflow FUSE mount

* fuse integration: create the fio target directory before running

* fuse integration: use unix.O_DIRECT instead of a hard-coded x86 value

0x4000 is O_DIRECT only on x86 and amd64; on arm64 it is O_DIRECTORY.
The test module already depends on golang.org/x/sys.

* fuse integration: run autoreconf and configure before building pjdfstest

A fresh pjdfstest clone is autotools-based and has no Makefile, so the
Go-side setup fallback always failed and the suite silently skipped.

* ci: require external posix tools only when setup installed them

setup-external-tools always exits 0 because each sub-target tolerates
failure, so POSIX_REQUIRE_EXTERNAL_TOOLS was set even with no tools
installed and the suite then hard-failed on the missing suites.

* ci: fail the posix workflow when the mount point is not a FUSE mount

The file write/read check passes on the plain directory created before
weed mount, so a dead mount let the whole suite grade the local disk.

* fuse integration: skip when the host has no FUSE device node

Setup failed the test outright on machines without /dev/fuse instead of
skipping; cover every suite entry point by skipping inside Setup.

* fuse integration: drop the chmod 666 /dev/fuse troubleshooting tip

World-writable device access is a security risk; the fuse group
membership on the line below is the safe fix.

* fuse integration: require go 1.21+ in check-go, not 1.20+

* fuse integration: refuse external suites on an unmounted path

* fuse integration: verify TEST_MOUNT_POINT is a real mount

* fuse integration: clean TEST_MOUNT_POINT before the parent-device check

filepath.Dir of a trailing-slash path returns the mount itself, so a mounted TEST_MOUNT_POINT ending in / was refused.

* fuse integration: detect WinFsp mounts on Windows in mountedAt

A directory mount is a reparse point and a drive mount is a volume root; a plain directory is now refused instead of accepted.

* fuse integration: strip a trailing slash off MOUNT_POINT in require-mounted

The mount-table grep fallback on hosts without mountpoint(8) would not match a slash-suffixed entry.

* fuse integration: require an external mount to be a FUSE filesystem

A device-ID boundary alone does not prove FUSE: a tmpfs mount would pass mountedAt and report its results as FUSE compliance. Check the filesystem type (statfs magic on linux, fstypename on the BSDs); platforms without a check keep the mount and write verification.

---------

Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-22 14:37:03 -07:00
..
2026-08-17 15:39:20 -07:00
2026-08-17 15:39:20 -07:00
2025-07-16 12:43:08 -07:00
2025-10-13 18:05:17 -07:00

SeaweedFS FUSE Integration Testing Framework

Overview

This directory contains a comprehensive integration testing framework for SeaweedFS FUSE operations. The current SeaweedFS FUSE tests are primarily performance-focused (using FIO) but lack comprehensive functional testing. This framework addresses those gaps.

⚠️ Current Status

Note: Due to Go module conflicts between this test framework and the parent SeaweedFS module, the full test suite currently requires manual setup. The framework files are provided as a foundation for comprehensive FUSE testing once the module structure is resolved.

Working Components

  • ✅ Framework design and architecture (framework.go)
  • ✅ Individual test file structure and compilation
  • ✅ Test methodology and comprehensive coverage
  • ✅ Documentation and usage examples
  • ⚠️ Full test suite execution (requires Go module isolation)

Verified Working Test

cd test/fuse_integration
go test -v simple_test.go

Current Testing Gaps Addressed

1. Limited Functional Coverage

  • Current: Only basic FIO performance tests
  • New: Comprehensive testing of all FUSE operations (create, read, write, delete, mkdir, rmdir, permissions, etc.)

2. No Concurrency Testing

  • Current: Single-threaded performance tests
  • New: Extensive concurrent operation tests, race condition detection, thread safety validation

3. Insufficient Error Handling

  • Current: Basic error scenarios
  • New: Comprehensive error condition testing, edge cases, failure recovery

4. Missing Edge Cases

  • Current: Simple file operations
  • New: Large files, sparse files, deep directory nesting, many small files, permission variations

Framework Architecture

Core Components

  1. framework.go - Test infrastructure and utilities

    • FuseTestFramework - Main test management struct
    • Automated SeaweedFS cluster setup/teardown
    • FUSE mount/unmount management
    • Helper functions for file operations and assertions
  2. basic_operations_test.go - Fundamental FUSE operations

    • File create, read, write, delete
    • File attributes and permissions
    • Large file handling
    • Sparse file operations
  3. directory_operations_test.go - Directory-specific tests

    • Directory creation, deletion, listing
    • Nested directory structures
    • Directory permissions and rename operations
    • Complex directory scenarios
  4. concurrent_operations_test.go - Concurrency and stress testing

    • Concurrent file and directory operations
    • Race condition detection
    • High-frequency operations
    • Stress testing scenarios

Key Features

Automated Test Environment

framework := NewFuseTestFramework(t, DefaultTestConfig())
defer framework.Cleanup()
require.NoError(t, framework.Setup(DefaultTestConfig()))
  • Automatic cluster setup: Master, Volume, Filer servers
  • FUSE mounting: Proper mount point management
  • Cleanup: Automatic teardown of all resources

Configurable Test Parameters

config := &TestConfig{
    Collection:   "test",
    Replication:  "001", 
    ChunkSizeMB:  8,
    CacheSizeMB:  200,
    NumVolumes:   5,
    EnableDebug:  true,
    MountOptions: []string{"-allowOthers"},
}

Rich Assertion Helpers

framework.AssertFileExists("path/to/file")
framework.AssertFileContent("file.txt", expectedContent)
framework.AssertFileMode("script.sh", 0755)
framework.CreateTestFile("test.txt", []byte("content"))

Test Categories

1. Basic File Operations

  • Create/Read/Write/Delete: Fundamental file operations
  • File Attributes: Size, timestamps, permissions
  • Append Operations: File appending behavior
  • Large Files: Files exceeding chunk size limits
  • Sparse Files: Non-contiguous file data

2. Directory Operations

  • Directory Lifecycle: Create, list, remove directories
  • Nested Structures: Deep directory hierarchies
  • Directory Permissions: Access control testing
  • Directory Rename: Move operations
  • Complex Scenarios: Many files, deep nesting

3. Concurrent Operations

  • Multi-threaded Access: Simultaneous file operations
  • Race Condition Detection: Concurrent read/write scenarios
  • Directory Concurrency: Parallel directory operations
  • Stress Testing: High-frequency operations

4. Error Handling & Edge Cases

  • Permission Denied: Access control violations
  • Disk Full: Storage limit scenarios
  • Network Issues: Filer/Volume server failures
  • Invalid Operations: Malformed requests
  • Recovery Testing: Error recovery scenarios

Usage Examples

Basic Test Run

# Build SeaweedFS binary
make

# Run all FUSE tests
cd test/fuse_integration
go test -v

# Run specific test category
go test -v -run TestBasicFileOperations
go test -v -run TestConcurrentFileOperations

Custom Configuration

func TestCustomFUSE(t *testing.T) {
    config := &TestConfig{
        ChunkSizeMB:  16,           // Larger chunks
        CacheSizeMB:  500,          // More cache
        EnableDebug:  true,         // Debug output
        SkipCleanup:  true,         // Keep files for inspection
    }
    
    framework := NewFuseTestFramework(t, config)
    defer framework.Cleanup()
    require.NoError(t, framework.Setup(config))
    
    // Your tests here...
}

Debugging Failed Tests

config := &TestConfig{
    EnableDebug:  true,     // Enable verbose logging
    SkipCleanup:  true,     // Keep temp files for inspection
}

Advanced Features

Performance Benchmarking

func BenchmarkLargeFileWrite(b *testing.B) {
    framework := NewFuseTestFramework(t, DefaultTestConfig())
    defer framework.Cleanup()
    require.NoError(t, framework.Setup(DefaultTestConfig()))
    
    b.ResetTimer()
    for i := 0; i < b.N; i++ {
        // Benchmark file operations
    }
}

Custom Test Scenarios

func TestCustomWorkload(t *testing.T) {
    framework := NewFuseTestFramework(t, DefaultTestConfig())
    defer framework.Cleanup()
    require.NoError(t, framework.Setup(DefaultTestConfig()))
    
    // Simulate specific application workload
    simulateWebServerWorkload(t, framework)
    simulateDatabaseWorkload(t, framework)
    simulateBackupWorkload(t, framework)
}

Integration with CI/CD

GitHub Actions Example

name: FUSE Integration Tests
on: [push, pull_request]

jobs:
  fuse-tests:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - uses: actions/setup-go@v3
      with:
        go-version: '1.26'
    
    - name: Install FUSE
      run: sudo apt-get install -y fuse
    
    - name: Build SeaweedFS
      run: make
    
    - name: Run FUSE Tests
      run: |
        cd test/fuse_integration
        go test -v -timeout 30m

Docker Testing

FROM golang:1.26
RUN apt-get update && apt-get install -y fuse
COPY . /seaweedfs
WORKDIR /seaweedfs
RUN make
CMD ["go", "test", "-v", "./test/fuse_integration/..."]

Comparison with Current Testing

Aspect Current Tests New Framework
Operations Covered Basic FIO read/write All FUSE operations
Concurrency Single-threaded Multi-threaded stress tests
Error Scenarios Limited Comprehensive error handling
File Types Regular files only Large, sparse, many small files
Directory Testing None Complete directory operations
Setup Complexity Manual Docker setup Automated cluster management
Test Isolation Shared environment Isolated per-test environments
Debugging Limited Rich debugging and inspection

Benefits

1. Comprehensive Coverage

  • Tests all FUSE operations supported by SeaweedFS
  • Covers edge cases and error conditions
  • Validates behavior under concurrent access

2. Reliable Testing

  • Isolated test environments prevent test interference
  • Automatic cleanup ensures consistent state
  • Deterministic test execution

3. Easy Maintenance

  • Clear test organization and naming
  • Rich helper functions reduce code duplication
  • Configurable test parameters for different scenarios

4. Real-world Validation

  • Tests actual FUSE filesystem behavior
  • Validates integration between all SeaweedFS components
  • Catches issues that unit tests might miss

Future Enhancements

1. Extended FUSE Features

  • Extended attributes (xattr) testing
  • Symbolic link operations
  • Hard link behavior
  • File locking mechanisms

2. Performance Profiling

  • Built-in performance measurement
  • Memory usage tracking
  • Latency distribution analysis
  • Throughput benchmarking

3. Fault Injection

  • Network partition simulation
  • Server failure scenarios
  • Disk full conditions
  • Memory pressure testing

4. Integration Testing

  • Multi-filer configurations
  • Cross-datacenter replication
  • S3 API compatibility while mounted
  • Backup/restore operations

Getting Started

  1. Prerequisites

    # Install FUSE
    sudo apt-get install fuse  # Ubuntu/Debian
    brew install macfuse       # macOS
    
    # Build SeaweedFS
    make
    
  2. Run Tests

    cd test/fuse_integration
    go test -v
    
  3. View Results

    • Test output shows detailed operation results
    • Failed tests include specific error information
    • Debug mode provides verbose logging

This framework represents a significant improvement in SeaweedFS FUSE testing capabilities, providing comprehensive coverage, real-world validation, and reliable automation that will help ensure the robustness and reliability of the FUSE implementation.