Browse Source

fix test

pull/1502/head
Chris Lu 4 years ago
parent
commit
b9887504e8
  1. 36
      weed/util/chunk_cache/chunk_cache_on_disk_test.go

36
weed/util/chunk_cache/chunk_cache_on_disk_test.go

@ -49,6 +49,24 @@ func TestOnDisk(t *testing.T) {
}
}
for i := 2; i < writeCount; i++ {
data := cache.GetChunk(testData[i].fileId, testData[i].size)
if bytes.Compare(data, testData[i].data) != 0 {
t.Errorf("failed to write to and read from cache: %d", i)
}
}
cache.Shutdown()
cache = NewTieredChunkCache(2, tmpDir, totalDiskSizeInKB, 1024)
for i := 0; i < 2; i++ {
data := cache.GetChunk(testData[i].fileId, testData[i].size)
if bytes.Compare(data, testData[i].data) == 0 {
t.Errorf("old cache should have been purged: %d", i)
}
}
for i := 2; i < writeCount; i++ {
if i == 4 {
// FIXME this failed many times on build machines
@ -77,22 +95,4 @@ func TestOnDisk(t *testing.T) {
cache.Shutdown()
cache = NewTieredChunkCache(2, tmpDir, totalDiskSizeInKB, 1024)
for i := 0; i < 2; i++ {
data := cache.GetChunk(testData[i].fileId, testData[i].size)
if bytes.Compare(data, testData[i].data) == 0 {
t.Errorf("old cache should have been purged: %d", i)
}
}
for i := 2; i < writeCount; i++ {
data := cache.GetChunk(testData[i].fileId, testData[i].size)
if bytes.Compare(data, testData[i].data) != 0 {
t.Errorf("failed to write to and read from cache: %d", i)
}
}
cache.Shutdown()
}
Loading…
Cancel
Save