Browse Source

clean up tests

pull/991/head
Chris Lu 6 years ago
parent
commit
693d6c0f1b
  1. 12
      weed/storage/erasure_coding/ec_test.go

12
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 {

Loading…
Cancel
Save