mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-10-24 15:00:43 +02:00
* 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>
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.mdfor 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
# Mount with -allowOthers if other users need access (test config MountOptions)
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
# Test targets already run go test -v and keep logs under reports/
make -f posix_Makefile test-posix-basic
# Run against an existing external mount instead of a fresh cluster
make -f posix_Makefile test-posix-basic TEST_MOUNT_POINT=/path/to/mount
# Extend the 45-minute per-suite timeout
make -f posix_Makefile test-posix-full TEST_TIMEOUT=90m
Manual Test Execution
# Run specific test
cd test/fuse_integration
go test -v -run 'TestPOSIXCompliance/FileOperations' .
# Run with custom timeout
go test -v -timeout 30m -run TestPOSIXExtended .
🔄 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'
])
}
}
}
}
}
🎯 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 — add the user to the fuse group and
# re-login rather than widening permissions on the device node
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.