aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2019-05-19 21:16:01 -0700
committerChris Lu <chris.lu@gmail.com>2019-05-19 21:16:01 -0700
commit693d6c0f1bf430f4f6e2a1146864731c90d1ef28 (patch)
tree21d9fc9281b96ec31ee1b5c7313beaddc9e18bfa
parent6386a3174b7cf82025a41473c39a458029707cd9 (diff)
downloadseaweedfs-693d6c0f1bf430f4f6e2a1146864731c90d1ef28.tar.xz
seaweedfs-693d6c0f1bf430f4f6e2a1146864731c90d1ef28.zip
clean up tests
-rw-r--r--weed/storage/erasure_coding/ec_test.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/weed/storage/erasure_coding/ec_test.go b/weed/storage/erasure_coding/ec_test.go
index fb6cb1f93..d631471e9 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 {