fix s3tests

This commit is contained in:
Konstantin Lebedev
2025-11-04 00:43:30 +05:00
parent bff703e126
commit 0e6f40e903
6 changed files with 34 additions and 7 deletions
+2 -2
View File
@@ -54,7 +54,7 @@ jobs:
shell: bash
run: |
cd weed
go install -buildvcs=false
go install -tags s3tests -buildvcs=false
set -x
# Create clean data directory for this test run
export WEED_DATA_DIR="/tmp/seaweedfs-s3tests-$(date +%s)"
@@ -794,7 +794,7 @@ jobs:
exit 1
fi
go install -tags "sqlite" -buildvcs=false
go install -tags "sqlite s3tests" -buildvcs=false
# Create clean data directory for this test run with unique timestamp and process ID
export WEED_DATA_DIR="/tmp/seaweedfs-sql-test-$(date +%s)-$$"
mkdir -p "$WEED_DATA_DIR"
+10 -1
View File
@@ -24,9 +24,18 @@ func (entry *Entry) IsDirectoryKeyObject() bool {
return entry.IsDirectory && entry.Attributes != nil && entry.Attributes.Mime != ""
}
func (entry *Entry) GetExpiryTime() (expiryTime int64) {
expiryTime = entry.Attributes.Mtime
if expiryTime == 0 {
expiryTime = entry.Attributes.Crtime
}
expiryTime += int64(entry.Attributes.TtlSec)
return expiryTime
}
func (entry *Entry) IsExpired() bool {
return entry != nil && entry.Attributes != nil && entry.Attributes.TtlSec > 0 &&
(entry.Attributes.GetMtime()+int64(entry.Attributes.TtlSec)) >= time.Now().Unix()
time.Now().Unix() >= entry.GetExpiryTime()
}
func (entry *Entry) FileMode() (fileMode os.FileMode) {
+3 -2
View File
@@ -7,6 +7,7 @@ import (
"encoding/xml"
"errors"
"fmt"
"github.com/seaweedfs/seaweedfs/weed/util"
"math"
"net/http"
"sort"
@@ -615,7 +616,7 @@ func (s3a *S3ApiServer) PutBucketLifecycleConfigurationHandler(w http.ResponseWr
}
locationPrefix := fmt.Sprintf("%s/%s/%s", s3a.option.BucketsPath, bucket, rulePrefix)
locConf := &filer_pb.FilerConf_PathConf{
LocationPrefix: fmt.Sprintf("%s/%s/%s", s3a.option.BucketsPath, bucket, rulePrefix),
LocationPrefix: locationPrefix,
Collection: collectionName,
Ttl: fmt.Sprintf("%dd", rule.Expiration.Days),
}
@@ -627,7 +628,7 @@ func (s3a *S3ApiServer) PutBucketLifecycleConfigurationHandler(w http.ResponseWr
s3err.WriteErrorResponse(w, r, s3err.ErrInternalError)
return
}
ttlSec := int32((time.Duration(rule.Expiration.Days) * 24 * time.Hour).Seconds())
ttlSec := int32((time.Duration(rule.Expiration.Days) * util.LifeCycleInterval).Seconds())
if updErr := s3a.updateEntriesTTL(locationPrefix, ttlSec); updErr != nil {
glog.Errorf("PutBucketLifecycleConfigurationHandler update: %s", err)
}
+3 -2
View File
@@ -304,8 +304,9 @@ func (s3a *S3ApiServer) listFilerEntries(bucket string, originalPrefix string, m
}
}
if s3a.option.AllowDeleteObjectsByTTL && entry.IsExpired() {
if delErr := doDeleteEntry(client, dir, entry.Name, true, false); delErr != nil {
glog.Errorf("delete expired entries %s/%s: %v", dir, entry.Name, delErr)
glog.V(1).Infof("Do delete expired entry %s/%s", dirName, entryName)
if delErr := doDeleteEntry(client, dirName, entryName, true, false); delErr != nil {
glog.Errorf("delete expired entries %s/%s: %v", dirName, entryName, delErr)
}
return
}
@@ -0,0 +1,8 @@
//go:build s3tests
// +build s3tests
package util
import "time"
const LifeCycleInterval = 10 * time.Second
@@ -0,0 +1,8 @@
//go:build !s3tests
// +build !s3tests
package util
import "time"
const LifeCycleInterval = 24 * time.Hour