snapshot of https://github.com/seaweedfs/seaweedfs.git (master, 2026-09-16; blobs > 131072B omitted)
Some checks failed
go: build dev binaries / cleanup (push) Successful in 4s
Codespell / Check for spelling errors (push) Failing after 3s
docker: build dev containers / build-rust-binaries (amd64, x86_64-unknown-linux-musl) (push) Failing after 3s
docker: build dev containers / build-dev-containers (push) Has been skipped
docker: build dev containers / build-rust-binaries (arm64, true, aarch64-unknown-linux-musl) (push) Failing after 3s
End to End / FUSE Mount (push) Failing after 2s
EC Integration Tests / EC Integration Tests (push) Failing after 30s
FUSE DLM Integration Tests / FUSE DLM Integration Tests (push) Failing after 3s
FUSE Volume Server Failover Tests / FUSE Volume Server Failover (push) Failing after 3s
FUSE Integration Tests / FUSE Integration Testing (push) Failing after 2s
FUSE P2P Peer Chunk Sharing Integration Tests / FUSE P2P Peer Chunk Sharing (push) Failing after 3s
go: build binary / Go Vet (push) Failing after 2s
go: build binary / Go Vet 32-bit (push) Failing after 3s
go: build binary / Build (push) Failing after 4s
go: build binary / Build cross-platform (freebsd/amd64) (push) Failing after 3s
go: build binary / Build cross-platform (windows/amd64) (push) Failing after 3s
go: build binary / Build cross-platform (darwin/arm64) (push) Failing after 3s
go: build binary / Build cross-platform (windows/arm64) (push) Failing after 3s
go: build binary / Test (push) Failing after 2s
go: build binary / Test 32-bit (push) Failing after 3s
helm: lint and test charts / lint-test (push) Failing after 3s
Java Client Integration Tests / Java Integration Tests (11) (push) Failing after 3s
Java Client Integration Tests / Java Integration Tests (17) (push) Failing after 3s
go: build dev binaries / build_dev_linux_windows (amd64, linux) (push) Failing after 2s
go: build dev binaries / build_dev_linux_windows (amd64, windows) (push) Failing after 3s
go: build dev binaries / build_dev_darwin (amd64, darwin) (push) Has been skipped
go: build dev binaries / build_dev_darwin (arm64, darwin) (push) Has been skipped
Java Client Unit Tests / Java Unit Tests (11) (push) Failing after 3s
Java Client Unit Tests / Java Unit Tests (17) (push) Failing after 2s
Java Client Unit Tests / Java Unit Tests (21) (push) Failing after 3s
Java Client Unit Tests / Java Unit Tests (8) (push) Failing after 3s
Kafka Quick Test (Load Test with Schema Registry) / Kafka Client Load Test (Quick) (push) Failing after 3s
Kafka Gateway Tests / Kafka Unit Tests (unit-tests-1) (push) Failing after 11s
Kafka Gateway Tests / Kafka Integration Tests (Critical) (integration-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka End-to-End Tests (with SMQ) (e2e-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka Consumer Group Tests (Highly Isolated) (consumer-group-1) (push) Failing after 2s
Kafka Gateway Tests / Kafka Client Compatibility (with SMQ) (client-compat-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka SMQ Integration Tests (Full Stack) (smq-integration-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka Protocol Tests (Isolated) (protocol-1) (push) Failing after 3s
KMS Tests / KMS Provider Integration Tests (push) Failing after 2s
KMS Tests / S3 KMS End-to-End Tests (push) Failing after 3s
Master Cold Start Tests / Master Cold Start Tests (push) Failing after 4s
Metadata Subscribe Integration Tests / Metadata Subscribe Integration Tests (push) Failing after 3s
Multi-Master Tests / Multi-Master Failover Tests (push) Failing after 3s
Performance / CPU and Heap Profile (push) Failing after 2s
Performance / S3 Read/Write Benchmark (rust volume) (push) Failing after 3s
pjdfstest POSIX Compliance / pjdfstest (push) Failing after 2s
Plugin Worker Integration Tests / Plugin Worker: erasure_coding (push) Failing after 3s
Plugin Worker Integration Tests / Plugin Worker: vacuum (push) Failing after 3s
Rust Volume Server Tests / Rust Integration Tests (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (grpc - Shard 1) (push) Failing after 2s
Rust Volume Server Tests / Go Tests with Rust Volume (http - Shard 1) (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (grpc - Shard 2) (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (http - Shard 2) (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (grpc - Shard 3) (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Distributed Tests (push) Failing after 2s
S3 IAM Integration Tests / S3 IAM Performance Tests (push) Failing after 3s
Performance / Throughput Benchmark (go volume) (push) Failing after 3s
Performance / Throughput Benchmark (rust volume) (push) Failing after 2s
Performance / S3 Read/Write Benchmark (go volume) (push) Failing after 3s
Plugin Worker Integration Tests / Plugin Worker: volume_balance (push) Failing after 3s
PostgreSQL Gateway Tests / PostgreSQL Basic Tests (push) Failing after 3s
Rust Volume Server Tests / Rust Unit Tests (push) Failing after 2s
Rust Volume Server Tests / Go Tests with Rust Volume (http - Shard 3) (push) Failing after 3s
Rust Plugin Worker Tests / Rust Plugin Worker Build and Unit Tests (push) Failing after 3s
rust: build dev volume server binaries / cleanup (push) Successful in 3s
S3 ETag and ACL Tests / S3 ETag + ACL Integration Tests (push) Failing after 3s
S3 IAM Integration Tests / IAM Unit Tests (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Integration Tests (advanced) (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Integration Tests (basic) (push) Failing after 2s
S3 IAM Integration Tests / S3 IAM Integration Tests (group) (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Integration Tests (policy-enforcement) (push) Failing after 2s
S3 IAM Integration Tests / S3 IAM Integration Tests (sts) (push) Failing after 4s
S3 Keycloak Integration Tests / S3 Keycloak Integration Tests (push) Failing after 3s
S3 PyArrow Parquet Tests / PyArrow Parquet Tests (Python 3.11) (push) Failing after 3s
S3 PyArrow Parquet Tests / Go Unit Tests (Implicit Directory) (push) Has been cancelled
S3 PyArrow Parquet Tests / PyArrow Parquet Tests (Python 3.12) (push) Has been cancelled
rust: build dev volume server binaries / build-rust-volume-dev-darwin (darwin-amd64, x86_64-apple-darwin) (push) Has been cancelled
rust: build dev volume server binaries / build-rust-volume-dev-darwin (darwin-arm64, aarch64-apple-darwin) (push) Has been cancelled
rust: build dev volume server binaries / build-rust-volume-dev-linux (linux-amd64, x86_64-unknown-linux-gnu) (push) Has been cancelled
S3 PyArrow Parquet Tests / PyArrow Parquet Tests (Python 3.9) (push) Has been cancelled
S3 Proxy Signature Tests / S3 Proxy Signature Verification Tests (push) Has been cancelled
S3 SDK V2 Route Disambiguation Tests / S3 SDK V2 Routing Tests (push) Has been cancelled
S3 SSE Tests / S3 SSE Integration Tests (quick) (push) Has been cancelled
S3 SSE Tests / S3 SSE Compatibility Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Metadata Persistence Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Copy Operations Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Multipart Upload Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Performance Test (push) Has been cancelled
S3 SSE Tests / S3 Volume Encryption Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Integration Tests (comprehensive) (push) Has been cancelled
Spark Integration Tests / Spark Integration Tests (push) Failing after 2s
Telemetry Integration Tests / telemetry-integration-test (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (grpc - Shard 1) (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (http - Shard 1) (push) Failing after 3s
Ceph S3 tests / Basic S3 tests (KV store) (push) Has been cancelled
Ceph S3 tests / S3 Versioning & Object Lock tests (push) Has been cancelled
S3 Policy Integration Tests / S3 Policy Unit Tests (push) Failing after 3s
Ceph S3 tests / S3 CORS tests (push) Has been cancelled
Ceph S3 tests / SeaweedFS Custom S3 Copy tests (push) Has been cancelled
Ceph S3 tests / Basic S3 tests (SQL store) (push) Has been cancelled
test s3 over https using aws-cli / awscli-tests (push) Has been cancelled
TLS Rotation Integration Tests / TLS Rotation Integration Tests (push) Has been cancelled
Vacuum Integration Tests / Vacuum Integration Tests (push) Has been cancelled
S3 Policy Integration Tests / S3 Policy Variables Integration Tests (push) Failing after 3s
S3 Policy Integration Tests / S3 Policy Enforcement Integration Tests (advanced-policy) (push) Failing after 3s
S3 Policy Integration Tests / S3 Policy Enforcement Integration Tests (basic-policy) (push) Failing after 2s
S3 Policy Integration Tests / S3 Policy Enforcement Integration Tests (contextual-policy) (push) Failing after 4s
S3 Policy Integration Tests / Trusted Proxy Detection Tests (push) Failing after 2s
S3 Policy Integration Tests / S3 Policy Shell Integration Tests (push) Failing after 3s
Samba on FUSE Integration / samba-integration (push) Failing after 2s
SFTP Integration Tests / SFTP Integration Testing (push) Failing after 3s
terraform: validate and test modules / fmt, validate, plan-level tests (push) Failing after 3s
terraform: validate and test modules / local cluster smoke test (real weed) (push) Failing after 2s
Volume Server Integration Tests / Volume Server Integration Tests (grpc - Shard 3) (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (grpc - Shard 2) (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (http - Shard 2) (push) Failing after 2s
Volume Server Integration Tests / Volume Server Integration Tests (http - Shard 3) (push) Failing after 5s
mount: windows conformance / WinFsp conformance (push) Has been cancelled
mount: windows / Mount on Windows (push) Has been cancelled

This commit is contained in:
upstream-mirror
2026-09-16 03:23:42 +05:00
commit 89f5be005d
3997 changed files with 961970 additions and 0 deletions

View File

@@ -0,0 +1,395 @@
package s3api
import (
"math"
"testing"
"time"
)
// TestVersionIdFormatDetection tests that old and new format version IDs are correctly identified
func TestVersionIdFormatDetection(t *testing.T) {
tests := []struct {
name string
versionId string
expectNew bool
}{
// New format (inverted timestamps) - values > 0x4000000000000000
{
name: "new format - inverted timestamp",
versionId: "68a1b2c3d4e5f6780000000000000000", // > 0x4000...
expectNew: true,
},
{
name: "new format - high value",
versionId: "7fffffffffffffff0000000000000000", // near max
expectNew: true,
},
// Old format (raw timestamps) - values < 0x4000000000000000
{
name: "old format - raw timestamp",
versionId: "179a1b2c3d4e5f670000000000000000", // ~2024-2025
expectNew: false,
},
{
name: "old format - low value",
versionId: "10000000000000000000000000000000",
expectNew: false,
},
// Edge cases
{
name: "null version",
versionId: "null",
expectNew: false,
},
{
name: "short version ID",
versionId: "abc123",
expectNew: false,
},
{
name: "empty version ID",
versionId: "",
expectNew: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := isNewFormatVersionId(tt.versionId)
if got != tt.expectNew {
t.Errorf("isNewFormatVersionId(%s) = %v, want %v", tt.versionId, got, tt.expectNew)
}
})
}
}
func TestIsValidVersionID(t *testing.T) {
tests := []struct {
versionID string
want bool
}{
{"", true},
{"null", true},
{"opaque-version_123", true},
{"v1/../../../victim", false},
{`v1\..\victim`, false},
{"bad\x00version", false},
}
for _, tt := range tests {
t.Run(tt.versionID, func(t *testing.T) {
if got := isValidVersionID(tt.versionID); got != tt.want {
t.Errorf("isValidVersionID(%q) = %v, want %v", tt.versionID, got, tt.want)
}
})
}
}
// TestGenerateVersionIdFormats tests that generateVersionId produces correct format based on parameter
func TestGenerateVersionIdFormats(t *testing.T) {
// Generate old format version ID
oldFormatId := generateVersionId(false)
if len(oldFormatId) != 32 {
t.Errorf("old format version ID length = %d, want 32", len(oldFormatId))
}
if isNewFormatVersionId(oldFormatId) {
t.Errorf("generateVersionId(false) produced new format ID: %s", oldFormatId)
}
// Generate new format version ID
newFormatId := generateVersionId(true)
if len(newFormatId) != 32 {
t.Errorf("new format version ID length = %d, want 32", len(newFormatId))
}
if !isNewFormatVersionId(newFormatId) {
t.Errorf("generateVersionId(true) produced old format ID: %s", newFormatId)
}
}
// TestGetVersionTimestamp tests timestamp extraction from both formats
func TestGetVersionTimestamp(t *testing.T) {
now := time.Now().UnixNano()
// Generate old and new format IDs
oldId := generateVersionId(false)
newId := generateVersionId(true)
oldTs := getVersionTimestamp(oldId)
newTs := getVersionTimestamp(newId)
// Both should be close to current time (within 1 second)
tolerance := int64(time.Second)
if abs(oldTs-now) > tolerance {
t.Errorf("old format timestamp diff too large: got %d, want ~%d", oldTs, now)
}
if abs(newTs-now) > tolerance {
t.Errorf("new format timestamp diff too large: got %d, want ~%d", newTs, now)
}
// null should return 0
if ts := getVersionTimestamp("null"); ts != 0 {
t.Errorf("getVersionTimestamp(null) = %d, want 0", ts)
}
}
func abs(x int64) int64 {
if x < 0 {
return -x
}
return x
}
// TestCompareVersionIdsSameFormatOld tests sorting of old format version IDs (newest first)
func TestCompareVersionIdsSameFormatOld(t *testing.T) {
// Old format: larger hex value = newer (raw timestamp)
older := "1700000000000000" + "0000000000000000" // older timestamp
newer := "1800000000000000" + "0000000000000000" // newer timestamp
// Verify both are old format
if isNewFormatVersionId(older) || isNewFormatVersionId(newer) {
t.Fatal("test setup error: expected old format IDs")
}
// compareVersionIds should return negative if first arg is newer
result := compareVersionIds(newer, older)
if result >= 0 {
t.Errorf("compareVersionIds(newer, older) = %d, want negative", result)
}
result = compareVersionIds(older, newer)
if result <= 0 {
t.Errorf("compareVersionIds(older, newer) = %d, want positive", result)
}
result = compareVersionIds(older, older)
if result != 0 {
t.Errorf("compareVersionIds(same, same) = %d, want 0", result)
}
}
// TestCompareVersionIdsSameFormatNew tests sorting of new format version IDs (newest first)
func TestCompareVersionIdsSameFormatNew(t *testing.T) {
// New format: smaller hex value = newer (inverted timestamp)
// MaxInt64 - newer_ts < MaxInt64 - older_ts
newer := "6800000000000000" + "0000000000000000" // smaller = newer
older := "6900000000000000" + "0000000000000000" // larger = older
// Verify both are new format
if !isNewFormatVersionId(older) || !isNewFormatVersionId(newer) {
t.Fatal("test setup error: expected new format IDs")
}
// compareVersionIds should return negative if first arg is newer
result := compareVersionIds(newer, older)
if result >= 0 {
t.Errorf("compareVersionIds(newer, older) = %d, want negative", result)
}
result = compareVersionIds(older, newer)
if result <= 0 {
t.Errorf("compareVersionIds(older, newer) = %d, want positive", result)
}
}
// TestCompareVersionIdsMixedFormats tests sorting when comparing old and new format IDs
func TestCompareVersionIdsMixedFormats(t *testing.T) {
// Create IDs where we know the actual timestamps
// Old format: raw timestamp
oldFormatTs := int64(1700000000000000000) // some timestamp
oldFormatId := createOldFormatVersionId(oldFormatTs)
// New format: inverted timestamp (created 1 second later)
newFormatTs := oldFormatTs + int64(time.Second)
newFormatId := createNewFormatVersionId(newFormatTs)
// Verify formats
if isNewFormatVersionId(oldFormatId) {
t.Fatalf("expected old format for %s", oldFormatId)
}
if !isNewFormatVersionId(newFormatId) {
t.Fatalf("expected new format for %s", newFormatId)
}
// New format ID is newer (created 1 second later)
result := compareVersionIds(newFormatId, oldFormatId)
if result >= 0 {
t.Errorf("compareVersionIds(newer_new_format, older_old_format) = %d, want negative", result)
}
result = compareVersionIds(oldFormatId, newFormatId)
if result <= 0 {
t.Errorf("compareVersionIds(older_old_format, newer_new_format) = %d, want positive", result)
}
}
// TestCompareVersionIdsNullHandling tests that null versions sort last
func TestCompareVersionIdsNullHandling(t *testing.T) {
regular := generateVersionId(true)
// null should sort after regular versions
if result := compareVersionIds("null", regular); result <= 0 {
t.Errorf("compareVersionIds(null, regular) = %d, want positive (null sorts last)", result)
}
if result := compareVersionIds(regular, "null"); result >= 0 {
t.Errorf("compareVersionIds(regular, null) = %d, want negative (null sorts last)", result)
}
}
// Helper to create old format version ID from timestamp
func createOldFormatVersionId(ts int64) string {
return sprintf16x(uint64(ts)) + "0000000000000000"
}
// Helper to create new format version ID from timestamp
func createNewFormatVersionId(ts int64) string {
inverted := uint64(math.MaxInt64 - ts)
return sprintf16x(inverted) + "0000000000000000"
}
func sprintf16x(v uint64) string {
return sprintf("%016x", v)
}
func sprintf(format string, v uint64) string {
result := make([]byte, 16)
for i := 15; i >= 0; i-- {
digit := v & 0xf
if digit < 10 {
result[i] = byte('0' + digit)
} else {
result[i] = byte('a' + digit - 10)
}
v >>= 4
}
return string(result)
}
// TestOldFormatBackwardCompatibility ensures old format versions work correctly in sorting
func TestOldFormatBackwardCompatibility(t *testing.T) {
// Simulate a bucket that was created before the inverted format was introduced
// All versions should be old format and should sort correctly (newest first)
// Create 5 old format version IDs with known timestamps
baseTs := int64(1700000000000000000)
versions := make([]string, 5)
for i := 0; i < 5; i++ {
ts := baseTs + int64(i)*int64(time.Minute) // each 1 minute apart
versions[i] = createOldFormatVersionId(ts)
}
// Verify all are old format
for i, v := range versions {
if isNewFormatVersionId(v) {
t.Fatalf("version %d should be old format: %s", i, v)
}
}
// Verify sorting: versions[4] is newest, versions[0] is oldest
// compareVersionIds(newer, older) should return negative
for i := 0; i < 4; i++ {
newer := versions[i+1]
older := versions[i]
result := compareVersionIds(newer, older)
if result >= 0 {
t.Errorf("compareVersionIds(versions[%d], versions[%d]) = %d, want negative (newer first)", i+1, i, result)
}
}
// Verify extracted timestamps are correct
for i, v := range versions {
expectedTs := baseTs + int64(i)*int64(time.Minute)
gotTs := getVersionTimestamp(v)
if gotTs != expectedTs {
t.Errorf("getVersionTimestamp(versions[%d]) = %d, want %d", i, gotTs, expectedTs)
}
}
}
// TestNewFormatSorting ensures new format versions sort correctly (newest first)
func TestNewFormatSorting(t *testing.T) {
// Create 5 new format version IDs with known timestamps
baseTs := int64(1700000000000000000)
versions := make([]string, 5)
for i := 0; i < 5; i++ {
ts := baseTs + int64(i)*int64(time.Minute) // each 1 minute apart
versions[i] = createNewFormatVersionId(ts)
}
// Verify all are new format
for i, v := range versions {
if !isNewFormatVersionId(v) {
t.Fatalf("version %d should be new format: %s", i, v)
}
}
// Verify sorting: versions[4] is newest, versions[0] is oldest
for i := 0; i < 4; i++ {
newer := versions[i+1]
older := versions[i]
result := compareVersionIds(newer, older)
if result >= 0 {
t.Errorf("compareVersionIds(versions[%d], versions[%d]) = %d, want negative (newer first)", i+1, i, result)
}
}
// Verify extracted timestamps are correct
for i, v := range versions {
expectedTs := baseTs + int64(i)*int64(time.Minute)
gotTs := getVersionTimestamp(v)
if gotTs != expectedTs {
t.Errorf("getVersionTimestamp(versions[%d]) = %d, want %d", i, gotTs, expectedTs)
}
}
}
// TestMixedFormatTransition simulates a bucket transitioning from old to new format
func TestMixedFormatTransition(t *testing.T) {
baseTs := int64(1700000000000000000)
// First 3 versions created with old format (before upgrade)
oldVersions := make([]string, 3)
for i := 0; i < 3; i++ {
ts := baseTs + int64(i)*int64(time.Minute)
oldVersions[i] = createOldFormatVersionId(ts)
}
// Next 3 versions created with new format (after upgrade)
newVersions := make([]string, 3)
for i := 0; i < 3; i++ {
ts := baseTs + int64(3+i)*int64(time.Minute) // continue from where old left off
newVersions[i] = createNewFormatVersionId(ts)
}
// All versions in chronological order (oldest to newest)
allVersions := append(oldVersions, newVersions...)
// Verify mixed formats
for i := 0; i < 3; i++ {
if isNewFormatVersionId(allVersions[i]) {
t.Errorf("allVersions[%d] should be old format", i)
}
}
for i := 3; i < 6; i++ {
if !isNewFormatVersionId(allVersions[i]) {
t.Errorf("allVersions[%d] should be new format", i)
}
}
// Verify sorting works correctly across the format boundary
for i := 0; i < 5; i++ {
newer := allVersions[i+1]
older := allVersions[i]
result := compareVersionIds(newer, older)
if result >= 0 {
t.Errorf("compareVersionIds(allVersions[%d], allVersions[%d]) = %d, want negative (newer first)", i+1, i, result)
}
}
// Verify the newest (new format) version sorts before oldest (old format) when comparing directly
newest := allVersions[5] // newest, new format
oldest := allVersions[0] // oldest, old format
if result := compareVersionIds(newest, oldest); result >= 0 {
t.Errorf("compareVersionIds(newest_new_format, oldest_old_format) = %d, want negative", result)
}
}