|
|
3 месяцев назад | |
|---|---|---|
| .. | ||
| Makefile | 3 месяцев назад | |
| README.md | 3 месяцев назад | |
| object_lock_reproduce_test.go | 3 месяцев назад | |
| object_lock_validation_test.go | 3 месяцев назад | |
| s3_bucket_object_lock_test.go | 3 месяцев назад | |
| s3_object_lock_headers_test.go | 3 месяцев назад | |
| s3_retention_test.go | 3 месяцев назад | |
| s3_worm_integration_test.go | 3 месяцев назад | |
| test_config.json | 3 месяцев назад | |
This directory contains comprehensive tests for SeaweedFS S3 Object Retention functionality, including Object Lock, Legal Hold, and WORM (Write Once Read Many) capabilities.
The test suite validates AWS S3-compatible object retention features including:
s3_retention_test.go - Core retention functionality testss3_worm_integration_test.go - WORM integration and advanced scenariostest_config.json - Test configuration (endpoints, credentials)Makefile - Comprehensive test automationgo.mod - Go module dependenciesmake build-weed)# Build SeaweedFS and start test server
make start-server
# Run core retention tests
make test-retention-quick
# Run all retention tests
make test-retention
# Run WORM integration tests
make test-retention-worm
# Run all tests with managed server
make test-with-server
make clean
TestBasicRetentionWorkflow - Basic GOVERNANCE mode retentionTestRetentionModeCompliance - COMPLIANCE mode (immutable)TestLegalHoldWorkflow - Legal hold on/off functionalityTestObjectLockConfiguration - Bucket object lock settingsTestRetentionWithVersions - Version-specific retention policiesTestRetentionAndLegalHoldCombination - Multiple protection typesTestExpiredRetention - Post-expiration behaviorTestRetentionErrorCases - Error handling and edge casesTestWORMRetentionIntegration - New retention + legacy WORMTestWORMLegacyCompatibility - Backward compatibilityTestRetentionOverwriteProtection - Prevent overwritesTestRetentionBulkOperations - Bulk delete with retentionTestRetentionWithMultipartUpload - Multipart upload retentionTestRetentionExtendedAttributes - Extended attribute storageTestRetentionBucketDefaults - Default retention applicationTestRetentionConcurrentOperations - Concurrent operation safetyRun specific test categories:
# Basic functionality
make test-basic-retention
make test-compliance-retention
make test-legal-hold
# Advanced features
make test-retention-versions
make test-retention-combination
make test-expired-retention
# WORM integration
make test-worm-integration
make test-worm-legacy
make test-retention-bulk
The tests use these default settings:
./test-volume-datatest_config.json){
"endpoint": "http://localhost:8333",
"access_key": "some_access_key1",
"secret_key": "some_secret_key1",
"region": "us-east-1",
"bucket_prefix": "test-retention-",
"use_ssl": false,
"skip_verify_ssl": true
}
x-amz-bypass-governance-retention header# Start server for development
make dev-start
# Run quick test
make dev-test
# Format code
make fmt
# Run linter
make lint
# Generate coverage report
make coverage
# Run benchmarks
make benchmark-retention
# Check if port is in use
netstat -tlnp | grep 8333
# View server logs
make logs
# Force cleanup
make clean
# Run with verbose output
go test -v -timeout=15m .
# Run specific test
go test -v -run TestBasicRetentionWorkflow .
# Check server health
make health-check
# Install/update dependencies
make install-deps
# Check dependency status
make check-deps
These tests validate the retention implementation in:
weed/s3api/s3api_object_retention.go - Core retention logicweed/s3api/s3api_object_handlers_retention.go - HTTP handlersweed/s3api/s3_constants/extend_key.go - Extended attribute keysweed/s3api/s3err/s3api_errors.go - Error definitionsweed/s3api/s3api_object_handlers_delete.go - Deletion enforcementweed/s3api/s3api_object_handlers_put.go - Upload enforcementThe retention implementation supports standard AWS CLI commands:
# Set object retention
aws s3api put-object-retention \
--bucket mybucket \
--key myobject \
--retention Mode=GOVERNANCE,RetainUntilDate=2024-12-31T23:59:59Z
# Get object retention
aws s3api get-object-retention \
--bucket mybucket \
--key myobject
# Set legal hold
aws s3api put-object-legal-hold \
--bucket mybucket \
--key myobject \
--legal-hold Status=ON
# Configure bucket object lock
aws s3api put-object-lock-configuration \
--bucket mybucket \
--object-lock-configuration ObjectLockEnabled=Enabled,Rule='{DefaultRetention={Mode=GOVERNANCE,Days=30}}'
When adding new retention tests: