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
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
Symlink Operations
- โ 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 outputposix_extended_results.log
: Extended feature test outputposix_external_results.log
: External test suite outputposix_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
- Basic Tests: Add to
posix_compliance_test.go
- Extended Tests: Add to
posix_extended_test.go
- 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
- Fork the repository
- Create a feature branch
- Add comprehensive tests
- Ensure all existing tests pass
- Submit a pull request with detailed description
๐ Support
For questions, issues, or contributions:
- GitHub Issues: SeaweedFS Issues
- Discussions: SeaweedFS Discussions
- Documentation: SeaweedFS Wiki
This comprehensive POSIX compliance test suite ensures SeaweedFS FUSE mounts meet industry standards for filesystem behavior, performance, and reliability.