You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

16 KiB

SeaweedFS FUSE POSIX Compliance Testing

Overview

This comprehensive test suite provides full POSIX compliance testing for SeaweedFS FUSE mounts. It includes basic POSIX operations, extended features, external test suite integration, and performance benchmarking to ensure SeaweedFS meets filesystem standards.

๐ŸŽฏ Key Features

โœ… Comprehensive Test Coverage

  • Basic POSIX Operations: File/directory create, read, write, delete, rename
  • Advanced Features: Extended attributes, file locking, memory mapping (see roadmap)
  • I/O Operations: Synchronous/asynchronous I/O, direct I/O, vectored I/O (see roadmap)
  • Error Handling: Comprehensive error condition testing
  • Concurrent Operations: Multi-threaded stress testing
  • External Integration: pjdfstest, nfstest, FIO integration

๐Ÿ“‹ Implementation Status: Some advanced features are currently skipped pending platform-specific implementations. See POSIX_IMPLEMENTATION_ROADMAP.md for a detailed implementation plan and current status.

๐Ÿ“Š Performance Analysis

  • Benchmarking: Built-in performance benchmarks
  • Profiling: CPU and memory profiling support
  • Coverage Analysis: Code coverage reporting
  • Stress Testing: High-load concurrent operation testing

๐Ÿ”ง External Tool Integration

  • pjdfstest: Industry-standard POSIX filesystem test suite
  • nfstest_posix: Network filesystem POSIX API verification
  • FIO: Flexible I/O performance testing
  • Custom Litmus Tests: Focused edge case testing

๐Ÿ“‹ Test Categories

1. Basic POSIX Compliance (posix_compliance_test.go)

File Operations

  • โœ… File creation with O_CREAT, O_EXCL flags
  • โœ… File truncation and size management
  • โœ… File deletion and unlinking
  • โœ… Atomic rename operations
  • โœ… File permission management

Directory Operations

  • โœ… Directory creation and removal
  • โœ… Directory listing and traversal
  • โœ… Directory rename operations
  • โœ… Non-empty directory handling
  • โœ… Symbolic link creation and resolution
  • โœ… Broken symlink handling
  • โœ… Symlink target verification
  • โœ… Symlink permission handling

Permission Tests

  • โœ… File permission setting and verification
  • โœ… Directory permission enforcement
  • โœ… Permission inheritance
  • โœ… Access control validation

Timestamp Tests

  • โœ… Access time (atime) updates
  • โœ… Modification time (mtime) tracking
  • โœ… Change time (ctime) management
  • โœ… Timestamp precision and setting

I/O Operations

  • โœ… Read/write operations
  • โœ… File seeking and positioning
  • โœ… Append mode operations
  • โœ… Buffer management

File Descriptors

  • โœ… File descriptor duplication
  • โœ… File descriptor flags
  • โœ… Close-on-exec handling
  • โœ… File descriptor limits

Atomic Operations

  • โœ… Atomic file operations
  • โœ… Rename atomicity
  • โœ… Link/unlink atomicity

Concurrent Access

  • โœ… Multi-reader scenarios
  • โœ… Concurrent write handling
  • โœ… Reader-writer coordination
  • โœ… Race condition prevention

Error Handling

  • โœ… ENOENT (file not found) handling
  • โœ… EACCES (permission denied) handling
  • โœ… EBADF (bad file descriptor) handling
  • โœ… ENOTEMPTY (directory not empty) handling
  • โœ… Error code compliance

2. Extended POSIX Features (posix_extended_test.go)

Extended Attributes

  • โœ… Setting extended attributes (setxattr)
  • โœ… Getting extended attributes (getxattr)
  • โœ… Listing extended attributes (listxattr)
  • โœ… Removing extended attributes (removexattr)
  • โœ… Extended attribute namespaces

File Locking

  • โœ… Advisory locking (fcntl)
  • โœ… Exclusive locks (F_WRLCK)
  • โœ… Shared locks (F_RDLCK)
  • โœ… Lock conflict detection
  • โœ… Lock release and cleanup

Advanced I/O

  • โœ… Vectored I/O (readv/writev)
  • โœ… Positioned I/O (pread/pwrite)
  • โœ… Asynchronous I/O patterns
  • โœ… Scatter-gather operations

Sparse Files

  • โœ… Sparse file creation
  • โœ… Hole detection and handling
  • โœ… Sparse file efficiency
  • โœ… Seek beyond EOF

Large Files (>2GB)

  • โœ… Large file operations
  • โœ… 64-bit offset handling
  • โœ… Large file seeking
  • โœ… Large file truncation

Memory Mapping

  • โœ… File memory mapping (mmap)
  • โœ… Memory-mapped I/O
  • โœ… Memory synchronization (msync)
  • โœ… Memory unmapping (munmap)
  • โœ… Shared/private mappings

Direct I/O

  • โœ… Direct I/O operations (O_DIRECT)
  • โœ… Buffer alignment requirements
  • โœ… Direct I/O performance
  • โœ… Bypass buffer cache

File Preallocation

  • โœ… Space preallocation (fallocate)
  • โœ… File hole punching
  • โœ… Space reservation
  • โœ… Allocation efficiency

Zero-Copy Operations

  • โœ… Zero-copy file transfer (sendfile)
  • โœ… Efficient data movement
  • โœ… Cross-filesystem transfers

3. External Test Suite Integration (posix_external_test.go)

pjdfstest Integration

  • โœ… Comprehensive POSIX filesystem test suite
  • โœ… Industry-standard compliance verification
  • โœ… Automated test execution
  • โœ… Result analysis and reporting

nfstest_posix Integration

  • โœ… POSIX API verification
  • โœ… Network filesystem compliance
  • โœ… API behavior validation
  • โœ… Comprehensive coverage

Custom Litmus Tests

  • โœ… Atomic rename verification
  • โœ… Link count accuracy
  • โœ… Symlink cycle detection
  • โœ… Concurrent operation safety
  • โœ… Directory consistency

Stress Testing

  • โœ… High-frequency operations
  • โœ… Concurrent access patterns
  • โœ… Resource exhaustion scenarios
  • โœ… Error recovery testing

Edge Case Testing

  • โœ… Empty filenames
  • โœ… Very long filenames
  • โœ… Special characters
  • โœ… Deep directory nesting
  • โœ… Path length limits

๐Ÿš€ Quick Start

Prerequisites

# Install required tools
sudo apt-get install fuse           # Linux
brew install macfuse               # macOS

# Install Go 1.21+
go version

# Build SeaweedFS
cd /path/to/seaweedfs
make

Basic Usage

# Navigate to test directory
cd test/fuse_integration

# Check prerequisites
make -f posix_Makefile check-prereqs

# Run basic POSIX compliance tests
make -f posix_Makefile test-posix-basic

# Run complete test suite
make -f posix_Makefile test-posix-full

# Generate compliance report
make -f posix_Makefile generate-report

๐Ÿ”ง Advanced Usage

Test Categories

Critical Tests Only

# Run only critical POSIX compliance tests (faster)
make -f posix_Makefile test-posix-critical

Extended Feature Tests

# Test advanced POSIX features
make -f posix_Makefile test-posix-extended

External Tool Integration

# Setup and run external test suites
make -f posix_Makefile setup-external-tools
make -f posix_Makefile test-posix-external

Stress Testing

# Run stress tests for concurrent operations
make -f posix_Makefile test-posix-stress

Performance Analysis

Benchmarking

# Run performance benchmarks
make -f posix_Makefile benchmark-posix

Profiling

# Profile CPU and memory usage
make -f posix_Makefile profile-posix

# View CPU profile
go tool pprof reports/posix.cpu.prof

Coverage Analysis

# Generate test coverage report
make -f posix_Makefile coverage-posix
# View: reports/posix_coverage.html

FIO Performance Testing

# Run FIO-based I/O performance tests
make -f posix_Makefile test-fio-posix

External Test Suites

pjdfstest

# Setup and run pjdfstest
make -f posix_Makefile setup-pjdfstest
make -f posix_Makefile test-pjdfstest

nfstest_posix

# Install and run nfstest_posix
make -f posix_Makefile setup-nfstest
make -f posix_Makefile test-nfstest-posix

๐Ÿ“Š Understanding Results

Test Status Indicators

  • โœ… PASS: Test completed successfully
  • โŒ FAIL: Test failed - indicates non-compliance
  • โš ๏ธ SKIP: Test skipped - feature not supported
  • ๐Ÿ”„ RETRY: Test retried due to transient failure

Report Formats

HTML Report (reports/posix_compliance_report.html)

  • Interactive web-based report
  • Test category breakdown
  • Detailed results with navigation
  • Visual status indicators

Text Summary (reports/posix_compliance_summary.txt)

  • Concise text-based summary
  • Key findings and recommendations
  • Command-line friendly format

JSON Report (reports/posix_compliance_report.json)

  • Machine-readable results
  • Integration with CI/CD pipelines
  • Automated result processing

Log Files

  • posix_basic_results.log: Basic POSIX test detailed output
  • posix_extended_results.log: Extended feature test output
  • posix_external_results.log: External test suite output
  • posix_benchmark_results.log: Performance benchmark results

๐Ÿ› Debugging Failed Tests

Common Issues

Permission Denied Errors

# Ensure proper FUSE permissions
sudo usermod -a -G fuse $USER
# Re-login or run: newgrp fuse

# Check mount options
make -f posix_Makefile test-posix-basic MOUNT_OPTIONS="-allowOthers"

Extended Attributes Not Supported

# Check if xattr is supported by underlying filesystem
getfattr --version
# May need to skip xattr tests on certain filesystems

File Locking Issues

# Verify file locking support
# Some network filesystems may not support full locking

Memory Issues

# Increase available memory for tests
# Large file tests may require significant RAM

Debug Mode

# Run tests with verbose output
make -f posix_Makefile test-posix-basic VERBOSE=1

# Keep test files for inspection
make -f posix_Makefile test-posix-basic CLEANUP=false

# Enable debug logging
make -f posix_Makefile test-posix-basic DEBUG=true

Manual Test Execution

# Run specific test
cd test/fuse_integration
go test -v -run TestPOSIXCompliance/FileOperations posix_compliance_test.go

# Run with custom timeout
go test -v -timeout 30m -run TestPOSIXExtended posix_extended_test.go

๐Ÿ”„ CI/CD Integration

GitHub Actions

name: POSIX Compliance Tests

on: [push, pull_request]

jobs:
  posix-compliance:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-go@v4
      with:
        go-version: '1.21'
    
    - name: Install FUSE
      run: sudo apt-get update && sudo apt-get install -y fuse
    
    - name: Build SeaweedFS
      run: make
    
    - name: Run POSIX Compliance Tests
      run: |
        cd test/fuse_integration
        make -f posix_Makefile ci-posix-tests        
    
    - name: Upload Test Results
      uses: actions/upload-artifact@v4
      if: always()
      with:
        name: posix-test-results
        path: test/fuse_integration/reports/

Jenkins Pipeline

pipeline {
    agent any
    stages {
        stage('Setup') {
            steps {
                sh 'make'
            }
        }
        stage('POSIX Compliance') {
            steps {
                dir('test/fuse_integration') {
                    sh 'make -f posix_Makefile ci-posix-tests'
                }
            }
            post {
                always {
                    archiveArtifacts 'test/fuse_integration/reports/**'
                    publishHTML([
                        allowMissing: false,
                        alwaysLinkToLastBuild: true,
                        keepAll: true,
                        reportDir: 'test/fuse_integration/reports',
                        reportFiles: 'posix_compliance_report.html',
                        reportName: 'POSIX Compliance Report'
                    ])
                }
            }
        }
    }
}

Docker-based Testing

# Build Docker image for testing
cd test/fuse_integration
make -f posix_Makefile docker-test-posix

๐ŸŽฏ POSIX Compliance Checklist

Critical POSIX Features

  • File creation, reading, writing, deletion
  • Directory operations (create, remove, list)
  • File permissions and ownership
  • Symbolic links
  • Hard links
  • File timestamps
  • Error handling compliance
  • Atomic operations

Advanced POSIX Features

  • Extended attributes
  • File locking (advisory)
  • Memory-mapped I/O
  • Vectored I/O (readv/writev)
  • Positioned I/O (pread/pwrite)
  • Direct I/O
  • File preallocation
  • Sparse files

Performance Requirements

  • Reasonable performance under load
  • Concurrent access handling
  • Memory usage optimization
  • CPU efficiency
  • I/O throughput

Reliability Requirements

  • Data consistency
  • Error recovery
  • Race condition prevention
  • Resource cleanup
  • Crash recovery

๐Ÿ“ˆ Performance Benchmarks

Expected Performance Characteristics

Operation Expected Range Notes
File Create 1000-10000 ops/sec Depends on chunk size
File Read 100-1000 MB/sec Network limited
File Write 50-500 MB/sec Depends on replication
Directory Ops 500-5000 ops/sec Metadata operations
Concurrent Ops Scales with cores Up to hardware limits

Benchmarking Commands

# Basic I/O performance
make -f posix_Makefile benchmark-posix

# FIO comprehensive testing
make -f posix_Makefile test-fio-posix

# Custom benchmark with specific parameters
go test -v -bench=. -benchtime=30s posix_compliance_test.go

๐Ÿ” Troubleshooting

Common Test Failures

1. Mount Permission Issues

# Error: Permission denied mounting
# Solution: Check FUSE permissions
sudo chmod 666 /dev/fuse
sudo usermod -a -G fuse $USER

2. Extended Attribute Tests Fail

# Error: Operation not supported (ENOTSUP)
# Solution: Check filesystem xattr support
mount | grep $(df . | tail -1 | awk '{print $1}')
# May need to remount with xattr support

3. File Locking Tests Fail

# Error: Function not implemented (ENOSYS)
# Solution: Some network filesystems don't support locking
# This may be expected behavior

4. Large File Tests Fail

# Error: No space left on device
# Solution: Ensure sufficient disk space
df -h /tmp  # Check temp directory space
# May need to clean up or use different temp directory

5. Performance Tests Timeout

# Error: Test timeout exceeded
# Solution: Increase timeout or reduce test scope
go test -timeout 60m -run TestPOSIXCompliance

Debug Information Collection

# Collect system information
uname -a > debug_info.txt
mount >> debug_info.txt
df -h >> debug_info.txt
free -h >> debug_info.txt

# Collect SeaweedFS information
./weed version >> debug_info.txt
ps aux | grep weed >> debug_info.txt

# Collect test logs
cp reports/*.log debug_logs/

๐Ÿ“š Additional Resources

POSIX Standards

External Test Suites

  • pjdfstest - Comprehensive POSIX filesystem tests
  • nfstest - Network filesystem testing
  • FIO - Flexible I/O tester

SeaweedFS Documentation

๐Ÿค Contributing

Adding New Tests

  1. Basic Tests: Add to posix_compliance_test.go
  2. Extended Tests: Add to posix_extended_test.go
  3. External Integration: Add to posix_external_test.go

Test Guidelines

func (s *POSIXTestSuite) TestNewFeature(t *testing.T) {
    mountPoint := s.framework.GetMountPoint()
    
    t.Run("SubTestName", func(t *testing.T) {
        // Test setup
        testFile := filepath.Join(mountPoint, "test.txt")
        
        // Test execution
        err := someOperation(testFile)
        
        // Assertions
        require.NoError(t, err)
        
        // Cleanup (if needed)
        defer os.Remove(testFile)
    })
}

Submitting Improvements

  1. Fork the repository
  2. Create a feature branch
  3. Add comprehensive tests
  4. Ensure all existing tests pass
  5. Submit a pull request with detailed description

๐Ÿ“ž Support

For questions, issues, or contributions:


This comprehensive POSIX compliance test suite ensures SeaweedFS FUSE mounts meet industry standards for filesystem behavior, performance, and reliability.