Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

clean up tests

Chris Lu693d6c0f1bf4
diff --git a/weed/storage/erasure_coding/ec_test.go b/weed/storage/erasure_coding/ec_test.go
index fb6cb1f93a..d631471e97 100644
--- a/weed/storage/erasure_coding/ec_test.go
+++ b/weed/storage/erasure_coding/ec_test.go
@@ -37,6 +37,8 @@ func TestEncodingDecoding(t *testing.T) {
t.Logf("writeSortedEcxFiles: %v", err)
}
+ removeGeneratedFiles(baseFileName)
+
}
func generateEcFiles(baseFileName string, bufferSize int, largeBlockSize int64, smallBlockSize int64) error {
@@ -251,7 +253,7 @@ func readFromOtherEcFiles(ecFiles []*os.File, ecFileIndex int, ecFileOffset int6
bufs := make([][]byte, DataShardsCount+ParityShardsCount)
for i := 0; i < DataShardsCount; {
- n := int(rand.Int31n(DataShardsCount+ParityShardsCount))
+ n := int(rand.Int31n(DataShardsCount + ParityShardsCount))
if n == ecFileIndex || bufs[n] != nil {
continue
}
@@ -281,6 +283,14 @@ func readFromFile(file *os.File, data []byte, ecFileOffset int64) (err error) {
return
}
+func removeGeneratedFiles(baseFileName string) {
+ for i := 0; i < DataShardsCount+ParityShardsCount; i++ {
+ fname := fmt.Sprintf("%s.ec%02d", baseFileName, i+1)
+ os.Remove(fname)
+ }
+ os.Remove(baseFileName+".ecx")
+}
+
func TestLocateData(t *testing.T) {
intervals := locateData(largeBlockSize, smallBlockSize, DataShardsCount*largeBlockSize+1, DataShardsCount*largeBlockSize, 1)
if len(intervals) != 1 {