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
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:
327
weed/s3api/s3lifecycle/evaluate_test.go
Normal file
327
weed/s3api/s3lifecycle/evaluate_test.go
Normal file
@@ -0,0 +1,327 @@
|
||||
package s3lifecycle
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// idx is a small helper for tests that need to express NoncurrentIndex as
|
||||
// *int (production callers either compute it or leave it nil for current
|
||||
// versions; tests want a one-liner).
|
||||
func idx(i int) *int { return &i }
|
||||
|
||||
func mustTime(t *testing.T, s string) time.Time {
|
||||
t.Helper()
|
||||
tm, err := time.Parse(time.RFC3339, s)
|
||||
if err != nil {
|
||||
t.Fatalf("parse %s: %v", s, err)
|
||||
}
|
||||
return tm
|
||||
}
|
||||
|
||||
func TestEvaluateAction_DisabledRuleNeverFires(t *testing.T) {
|
||||
rule := &Rule{Status: StatusDisabled, ExpirationDays: 1}
|
||||
info := &ObjectInfo{Key: "a", IsLatest: true, ModTime: mustTime(t, "2024-01-01T00:00:00Z")}
|
||||
if got := EvaluateAction(rule, ActionKindExpirationDays, info, mustTime(t, "2030-01-01T00:00:00Z")); got.Action != ActionNone {
|
||||
t.Fatalf("disabled rule should be no-op, got %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvaluateAction_NilInputs(t *testing.T) {
|
||||
if EvaluateAction(nil, ActionKindExpirationDays, &ObjectInfo{}, time.Now()).Action != ActionNone {
|
||||
t.Fatalf("nil rule should be no-op")
|
||||
}
|
||||
if EvaluateAction(&Rule{Status: StatusEnabled}, ActionKindExpirationDays, nil, time.Now()).Action != ActionNone {
|
||||
t.Fatalf("nil info should be no-op")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvaluateAction_ExpirationDaysBoundary(t *testing.T) {
|
||||
rule := &Rule{Status: StatusEnabled, ID: "r", ExpirationDays: 30}
|
||||
mod := mustTime(t, "2024-01-01T00:00:00Z")
|
||||
info := &ObjectInfo{Key: "a", IsLatest: true, ModTime: mod}
|
||||
|
||||
if got := EvaluateAction(rule, ActionKindExpirationDays, info, mod.Add(DaysToDuration(30)).Add(-time.Nanosecond)); got.Action != ActionNone {
|
||||
t.Fatalf("not yet due, got %v", got)
|
||||
}
|
||||
if got := EvaluateAction(rule, ActionKindExpirationDays, info, mod.Add(DaysToDuration(30))); got.Action != ActionDeleteObject || got.RuleID != "r" {
|
||||
t.Fatalf("at boundary, got %v", got)
|
||||
}
|
||||
if got := EvaluateAction(rule, ActionKindExpirationDays, info, mod.Add(DaysToDuration(31))); got.Action != ActionDeleteObject {
|
||||
t.Fatalf("past due, got %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvaluateAction_KindFiltersByDeclaredAction(t *testing.T) {
|
||||
// Asking the wrong kind of a rule that doesn't declare that action returns
|
||||
// ActionNone — even when the object would otherwise match.
|
||||
rule := &Rule{Status: StatusEnabled, ExpirationDays: 30}
|
||||
mod := mustTime(t, "2024-01-01T00:00:00Z")
|
||||
info := &ObjectInfo{Key: "a", IsLatest: true, ModTime: mod}
|
||||
now := mod.Add(DaysToDuration(31))
|
||||
if got := EvaluateAction(rule, ActionKindAbortMPU, info, now); got.Action != ActionNone {
|
||||
t.Fatalf("AbortMPU not declared, got %v", got)
|
||||
}
|
||||
if got := EvaluateAction(rule, ActionKindNoncurrentDays, info, now); got.Action != ActionNone {
|
||||
t.Fatalf("NoncurrentDays not declared, got %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvaluateAction_MultiActionRule_SiblingsIndependent(t *testing.T) {
|
||||
// The bug this fixes: a rule with both ExpirationDays=90 and AbortMPU=7
|
||||
// is evaluated per-action; the 7d MPU window not being "due" for an
|
||||
// object event has no effect on the 90d expiration's eligibility.
|
||||
rule := &Rule{Status: StatusEnabled, ExpirationDays: 90, AbortMPUDaysAfterInitiation: 7}
|
||||
mod := mustTime(t, "2024-01-01T00:00:00Z")
|
||||
info := &ObjectInfo{Key: "a", IsLatest: true, ModTime: mod}
|
||||
|
||||
// Past the 90d threshold: ExpirationDays fires.
|
||||
now := mod.Add(DaysToDuration(91))
|
||||
if got := EvaluateAction(rule, ActionKindExpirationDays, info, now); got.Action != ActionDeleteObject {
|
||||
t.Fatalf("90d action should fire, got %v", got)
|
||||
}
|
||||
// AbortMPU asked against a non-MPU entry: no-op.
|
||||
if got := EvaluateAction(rule, ActionKindAbortMPU, info, now); got.Action != ActionNone {
|
||||
t.Fatalf("AbortMPU on non-MPU entry should be no-op, got %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvaluateAction_ExpirationDate(t *testing.T) {
|
||||
date := mustTime(t, "2025-06-15T00:00:00Z")
|
||||
rule := &Rule{Status: StatusEnabled, ExpirationDate: date}
|
||||
info := &ObjectInfo{Key: "a", IsLatest: true, ModTime: mustTime(t, "2024-01-01T00:00:00Z")}
|
||||
|
||||
if got := EvaluateAction(rule, ActionKindExpirationDate, info, date.Add(-time.Second)); got.Action != ActionNone {
|
||||
t.Fatalf("before date, got %v", got)
|
||||
}
|
||||
if got := EvaluateAction(rule, ActionKindExpirationDate, info, date); got.Action != ActionDeleteObject {
|
||||
t.Fatalf("at date, got %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvaluateAction_ExpiredObjectDeleteMarker(t *testing.T) {
|
||||
rule := &Rule{Status: StatusEnabled, ExpiredObjectDeleteMarker: true}
|
||||
now := mustTime(t, "2025-01-01T00:00:00Z")
|
||||
mod := mustTime(t, "2024-12-01T00:00:00Z")
|
||||
|
||||
// Current sole-survivor delete marker: fires.
|
||||
info := &ObjectInfo{Key: "a", IsLatest: true, IsDeleteMarker: true, NumVersions: 1, ModTime: mod}
|
||||
if got := EvaluateAction(rule, ActionKindExpiredDeleteMarker, info, now); got.Action != ActionExpireDeleteMarker {
|
||||
t.Fatalf("sole-survivor marker, got %v", got)
|
||||
}
|
||||
// Non-sole-survivor: not eligible for EXPIRED_DELETE_MARKER.
|
||||
info.NumVersions = 2
|
||||
if got := EvaluateAction(rule, ActionKindExpiredDeleteMarker, info, now); got.Action != ActionNone {
|
||||
t.Fatalf("non-sole marker, got %v", got)
|
||||
}
|
||||
// Latest non-marker: not in scope of this kind.
|
||||
info = &ObjectInfo{Key: "a", IsLatest: true, IsDeleteMarker: false, NumVersions: 1, ModTime: mod}
|
||||
if got := EvaluateAction(rule, ActionKindExpiredDeleteMarker, info, now); got.Action != ActionNone {
|
||||
t.Fatalf("non-marker, got %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvaluateAction_NoncurrentDeleteMarkerExpiresViaNoncurrentDays(t *testing.T) {
|
||||
// A non-current delete marker is just a version. NoncurrentVersionExpirationDays
|
||||
// must apply to it.
|
||||
rule := &Rule{Status: StatusEnabled, NoncurrentVersionExpirationDays: 7}
|
||||
successor := mustTime(t, "2024-01-01T00:00:00Z")
|
||||
info := &ObjectInfo{
|
||||
Key: "a",
|
||||
IsLatest: false,
|
||||
IsDeleteMarker: true,
|
||||
NumVersions: 3,
|
||||
SuccessorModTime: successor,
|
||||
ModTime: successor.Add(DaysToDuration(-1)),
|
||||
}
|
||||
if got := EvaluateAction(rule, ActionKindNoncurrentDays, info, successor.Add(DaysToDuration(7))); got.Action != ActionDeleteVersion {
|
||||
t.Fatalf("noncurrent delete marker should be eligible under NoncurrentDays, got %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvaluateAction_NoncurrentVersionDays(t *testing.T) {
|
||||
rule := &Rule{Status: StatusEnabled, NoncurrentVersionExpirationDays: 30}
|
||||
successor := mustTime(t, "2024-01-01T00:00:00Z")
|
||||
info := &ObjectInfo{
|
||||
Key: "a",
|
||||
IsLatest: false,
|
||||
ModTime: mustTime(t, "2023-01-01T00:00:00Z"),
|
||||
SuccessorModTime: successor,
|
||||
NoncurrentIndex: idx(0),
|
||||
}
|
||||
if got := EvaluateAction(rule, ActionKindNoncurrentDays, info, successor.Add(DaysToDuration(29))); got.Action != ActionNone {
|
||||
t.Fatalf("not due, got %v", got)
|
||||
}
|
||||
if got := EvaluateAction(rule, ActionKindNoncurrentDays, info, successor.Add(DaysToDuration(30))); got.Action != ActionDeleteVersion {
|
||||
t.Fatalf("due, got %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvaluateAction_NoncurrentDaysFallsBackToModTime(t *testing.T) {
|
||||
rule := &Rule{Status: StatusEnabled, NoncurrentVersionExpirationDays: 30}
|
||||
mod := mustTime(t, "2024-01-01T00:00:00Z")
|
||||
info := &ObjectInfo{Key: "a", IsLatest: false, ModTime: mod, NoncurrentIndex: idx(0)}
|
||||
if got := EvaluateAction(rule, ActionKindNoncurrentDays, info, mod.Add(DaysToDuration(30))); got.Action != ActionDeleteVersion {
|
||||
t.Fatalf("expected fallback to ModTime, got %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvaluateAction_NoncurrentDays_WithKeepN_NilIndexIsNoOp(t *testing.T) {
|
||||
// Pointer-migration safety: a nil NoncurrentIndex paired with a
|
||||
// keep-N retention threshold must short-circuit to ActionNone rather
|
||||
// than guess at the version's position in the keep window.
|
||||
rule := &Rule{Status: StatusEnabled, NoncurrentVersionExpirationDays: 30, NewerNoncurrentVersions: 2}
|
||||
successor := mustTime(t, "2024-01-01T00:00:00Z")
|
||||
info := &ObjectInfo{
|
||||
Key: "a",
|
||||
IsLatest: false,
|
||||
ModTime: successor,
|
||||
SuccessorModTime: successor,
|
||||
NoncurrentIndex: nil,
|
||||
}
|
||||
now := successor.Add(DaysToDuration(30))
|
||||
if got := EvaluateAction(rule, ActionKindNoncurrentDays, info, now); got.Action != ActionNone {
|
||||
t.Fatalf("nil index with keep-N must be no-op, got %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvaluateAction_NewerNoncurrent_NilIndexIsNoOp(t *testing.T) {
|
||||
rule := &Rule{Status: StatusEnabled, NewerNoncurrentVersions: 3}
|
||||
info := &ObjectInfo{
|
||||
Key: "a",
|
||||
IsLatest: false,
|
||||
ModTime: mustTime(t, "2024-01-01T00:00:00Z"),
|
||||
NoncurrentIndex: nil,
|
||||
}
|
||||
if got := EvaluateAction(rule, ActionKindNewerNoncurrent, info, mustTime(t, "2025-01-01T00:00:00Z")); got.Action != ActionNone {
|
||||
t.Fatalf("nil index pure-count must be no-op, got %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvaluateAction_NewerNoncurrentCountOnly(t *testing.T) {
|
||||
rule := &Rule{Status: StatusEnabled, NewerNoncurrentVersions: 3}
|
||||
now := mustTime(t, "2025-01-01T00:00:00Z")
|
||||
mod := mustTime(t, "2024-01-01T00:00:00Z")
|
||||
|
||||
for i := 0; i < 3; i++ {
|
||||
info := &ObjectInfo{Key: "a", IsLatest: false, ModTime: mod, NoncurrentIndex: idx(i)}
|
||||
if got := EvaluateAction(rule, ActionKindNewerNoncurrent, info, now); got.Action != ActionNone {
|
||||
t.Fatalf("idx=%d should be retained, got %v", i, got)
|
||||
}
|
||||
}
|
||||
info := &ObjectInfo{Key: "a", IsLatest: false, ModTime: mod, NoncurrentIndex: idx(3)}
|
||||
if got := EvaluateAction(rule, ActionKindNewerNoncurrent, info, now); got.Action != ActionDeleteVersion {
|
||||
t.Fatalf("idx=3 should fire, got %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvaluateAction_NoncurrentDaysAndCount(t *testing.T) {
|
||||
rule := &Rule{Status: StatusEnabled, NoncurrentVersionExpirationDays: 30, NewerNoncurrentVersions: 2}
|
||||
successor := mustTime(t, "2024-01-01T00:00:00Z")
|
||||
now := successor.Add(DaysToDuration(30))
|
||||
|
||||
for i := 0; i < 2; i++ {
|
||||
info := &ObjectInfo{Key: "a", IsLatest: false, ModTime: successor, SuccessorModTime: successor, NoncurrentIndex: idx(i)}
|
||||
if got := EvaluateAction(rule, ActionKindNoncurrentDays, info, now); got.Action != ActionNone {
|
||||
t.Fatalf("idx=%d kept by NewerNoncurrent retention, got %v", i, got)
|
||||
}
|
||||
}
|
||||
info := &ObjectInfo{Key: "a", IsLatest: false, ModTime: successor, SuccessorModTime: successor, NoncurrentIndex: idx(2)}
|
||||
if got := EvaluateAction(rule, ActionKindNoncurrentDays, info, now); got.Action != ActionDeleteVersion {
|
||||
t.Fatalf("idx=2 satisfies both, got %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvaluateAction_AbortMultipartUpload(t *testing.T) {
|
||||
rule := &Rule{Status: StatusEnabled, AbortMPUDaysAfterInitiation: 7}
|
||||
init := mustTime(t, "2024-01-01T00:00:00Z")
|
||||
info := &ObjectInfo{Key: ".uploads/u1/", IsMPUInit: true, ModTime: init}
|
||||
if got := EvaluateAction(rule, ActionKindAbortMPU, info, init.Add(DaysToDuration(6))); got.Action != ActionNone {
|
||||
t.Fatalf("not due, got %v", got)
|
||||
}
|
||||
if got := EvaluateAction(rule, ActionKindAbortMPU, info, init.Add(DaysToDuration(7))); got.Action != ActionAbortMultipartUpload {
|
||||
t.Fatalf("due, got %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvaluateAction_PrefixFilter(t *testing.T) {
|
||||
rule := &Rule{Status: StatusEnabled, Prefix: "logs/", ExpirationDays: 1}
|
||||
mod := mustTime(t, "2024-01-01T00:00:00Z")
|
||||
now := mod.Add(DaysToDuration(10))
|
||||
if got := EvaluateAction(rule, ActionKindExpirationDays, &ObjectInfo{Key: "data/x", IsLatest: true, ModTime: mod}, now); got.Action != ActionNone {
|
||||
t.Fatalf("prefix mismatch should reject, got %v", got)
|
||||
}
|
||||
if got := EvaluateAction(rule, ActionKindExpirationDays, &ObjectInfo{Key: "logs/x", IsLatest: true, ModTime: mod}, now); got.Action != ActionDeleteObject {
|
||||
t.Fatalf("prefix match should fire, got %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvaluateAction_TagFilter(t *testing.T) {
|
||||
rule := &Rule{Status: StatusEnabled, ExpirationDays: 1, FilterTags: map[string]string{"env": "prod", "tier": "cold"}}
|
||||
mod := mustTime(t, "2024-01-01T00:00:00Z")
|
||||
now := mod.Add(DaysToDuration(10))
|
||||
|
||||
info := &ObjectInfo{Key: "a", IsLatest: true, ModTime: mod}
|
||||
if got := EvaluateAction(rule, ActionKindExpirationDays, info, now); got.Action != ActionNone {
|
||||
t.Fatalf("missing tags should reject, got %v", got)
|
||||
}
|
||||
info.Tags = map[string]string{"env": "prod"}
|
||||
if got := EvaluateAction(rule, ActionKindExpirationDays, info, now); got.Action != ActionNone {
|
||||
t.Fatalf("partial match should reject, got %v", got)
|
||||
}
|
||||
info.Tags = map[string]string{"env": "prod", "tier": "cold", "extra": "ignored"}
|
||||
if got := EvaluateAction(rule, ActionKindExpirationDays, info, now); got.Action != ActionDeleteObject {
|
||||
t.Fatalf("all tags match should fire, got %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvaluateAction_SizeFilter(t *testing.T) {
|
||||
rule := &Rule{Status: StatusEnabled, ExpirationDays: 1, FilterSizeGreaterThan: 100, FilterSizeLessThan: 1000}
|
||||
mod := mustTime(t, "2024-01-01T00:00:00Z")
|
||||
now := mod.Add(DaysToDuration(10))
|
||||
cases := []struct {
|
||||
size int64
|
||||
want Action
|
||||
}{
|
||||
{50, ActionNone},
|
||||
{100, ActionNone},
|
||||
{500, ActionDeleteObject},
|
||||
{1000, ActionNone},
|
||||
{2000, ActionNone},
|
||||
}
|
||||
for _, c := range cases {
|
||||
info := &ObjectInfo{Key: "a", IsLatest: true, ModTime: mod, Size: c.size}
|
||||
if got := EvaluateAction(rule, ActionKindExpirationDays, info, now); got.Action != c.want {
|
||||
t.Fatalf("size=%d want=%v got=%v", c.size, c.want, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvaluateAction_EmptyPrefixMatchesAll(t *testing.T) {
|
||||
rule := &Rule{Status: StatusEnabled, ExpirationDays: 1, Prefix: ""}
|
||||
mod := mustTime(t, "2024-01-01T00:00:00Z")
|
||||
info := &ObjectInfo{Key: "deeply/nested/path/x", IsLatest: true, ModTime: mod}
|
||||
if got := EvaluateAction(rule, ActionKindExpirationDays, info, mod.Add(DaysToDuration(10))); got.Action != ActionDeleteObject {
|
||||
t.Fatalf("empty prefix should match, got %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvaluateAction_MPUInitDoesNotFireNoncurrent(t *testing.T) {
|
||||
// IsLatest=false on an MPU init must not let NoncurrentDays /
|
||||
// NewerNoncurrent fire. The dispatcher BLOCKs noncurrent kinds with
|
||||
// empty version_id, which would freeze the cursor.
|
||||
rule := &Rule{
|
||||
ID: "r",
|
||||
Status: StatusEnabled,
|
||||
NoncurrentVersionExpirationDays: 7,
|
||||
NewerNoncurrentVersions: 3,
|
||||
}
|
||||
init := time.Now().Add(-DaysToDuration(30))
|
||||
info := &ObjectInfo{Key: "logs/foo.txt", IsMPUInit: true, ModTime: init}
|
||||
|
||||
for _, kind := range []ActionKind{ActionKindNoncurrentDays, ActionKindNewerNoncurrent} {
|
||||
if got := EvaluateAction(rule, kind, info, time.Now()); got.Action != ActionNone {
|
||||
t.Fatalf("kind=%v on IsMPUInit must return None, got %+v", kind, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user