Back to Seaweedfs

SeaweedFS S3 Java SDK Compatibility Tests

other/java/s3copier/README.md

4.233.4 KB
Original Source

SeaweedFS S3 Java SDK Compatibility Tests

This project contains Java-based integration tests for SeaweedFS S3 API compatibility.

Overview

Tests are provided for both AWS SDK v1 and v2 to ensure compatibility with the various SDK versions commonly used in production.

SDK Versions

SDKVersionNotes
AWS SDK v1 for Java1.12.600Legacy SDK, less strict ETag validation
AWS SDK v2 for Java2.20.127Modern SDK with strict checksum validation

Running Tests

Prerequisites

  1. SeaweedFS running with S3 API enabled:

    bash
    weed server -s3
    
  2. Java 18+ and Maven

Run All Tests

bash
mvn test

Run Specific Tests

bash
# Run only ETag validation tests (AWS SDK v2)
mvn test -Dtest=ETagValidationTest

# Run with custom endpoint
mvn test -Dtest=ETagValidationTest -DS3_ENDPOINT=http://localhost:8333

Environment Variables

VariableDefaultDescription
S3_ENDPOINThttp://127.0.0.1:8333S3 API endpoint URL
S3_ACCESS_KEYsome_access_key1Access key ID
S3_SECRET_KEYsome_secret_key1Secret access key
S3_REGIONus-east-1AWS region

Test Coverage

ETagValidationTest (AWS SDK v2)

Tests for GitHub Issue #7768 - ETag format validation.

TestDescription
testSmallFilePutObjectVerify small files return pure MD5 ETag
testLargeFilePutObject_Issue7768Critical: Verify large files (>8MB) return pure MD5 ETag
testExtraLargeFilePutObjectVerify very large files (>24MB) return pure MD5 ETag
testMultipartUploadETagVerify multipart uploads return composite ETag
testETagConsistencyVerify ETag consistency across PUT/HEAD/GET
testMultipleLargeFileUploadsStress test multiple large uploads

Background: Issue #7768

AWS SDK v2 for Java includes checksum validation that decodes the ETag as hexadecimal. When SeaweedFS returned composite ETags (<md5>-<count>) for regular PutObject with internally auto-chunked files, the SDK failed with:

java.lang.IllegalArgumentException: Invalid base 16 character: '-'

Per AWS S3 specification:

  • PutObject: ETag is always a pure MD5 hex string (32 chars)
  • CompleteMultipartUpload: ETag is composite format (<md5>-<partcount>)

The fix ensures SeaweedFS follows this specification.

Project Structure

src/
├── main/java/com/seaweedfs/s3/
│   ├── PutObject.java           # Example PutObject with SDK v1
│   └── HighLevelMultipartUpload.java
└── test/java/com/seaweedfs/s3/
    ├── PutObjectTest.java       # Basic SDK v1 test
    └── ETagValidationTest.java  # Comprehensive SDK v2 ETag tests

Validated SDK Versions

This Java test project validates:

  • ✅ AWS SDK v2 for Java 2.20.127+
  • ✅ AWS SDK v1 for Java 1.12.600+

Go SDK validation is performed by separate test suites: