diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-09-27 11:42:51 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-09-27 11:42:51 -0700 |
| commit | 9ad2dcca2b49b11e85c09df9ade18fb417e4e755 (patch) | |
| tree | a53467e2558e145f7b79329a70bc2211b80bf875 /weed/util/chunk_cache/chunk_cache_on_disk_test.go | |
| parent | e43d86c79600ee09ef9bc5b271758bea662c0ca9 (diff) | |
| download | seaweedfs-9ad2dcca2b49b11e85c09df9ade18fb417e4e755.tar.xz seaweedfs-9ad2dcca2b49b11e85c09df9ade18fb417e4e755.zip | |
more tests
Diffstat (limited to 'weed/util/chunk_cache/chunk_cache_on_disk_test.go')
| -rw-r--r-- | weed/util/chunk_cache/chunk_cache_on_disk_test.go | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/weed/util/chunk_cache/chunk_cache_on_disk_test.go b/weed/util/chunk_cache/chunk_cache_on_disk_test.go index edcd23e62..4b179e5d3 100644 --- a/weed/util/chunk_cache/chunk_cache_on_disk_test.go +++ b/weed/util/chunk_cache/chunk_cache_on_disk_test.go @@ -34,9 +34,22 @@ func TestOnDisk(t *testing.T) { size: uint64(len(buff)), } cache.SetChunk(testData[i].fileId, testData[i].data) + + // read back right after write + 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) + } } - for i := 0; i < writeCount; i++ { + 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) @@ -47,7 +60,14 @@ func TestOnDisk(t *testing.T) { cache = NewTieredChunkCache(0, tmpDir, totalDiskSizeInKB, 1024) - for i := 0; i < writeCount; i++ { + 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) |
