aboutsummaryrefslogtreecommitdiff
path: root/zenstore/compactcas.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2022-03-21 08:42:29 +0100
committerDan Engelbrecht <[email protected]>2022-03-31 11:28:32 +0200
commit02dd0b386fbc1fde486b8f6780cc620e1850515f (patch)
treea61f2a03419e7dac9ca917d43806b1d08097aba7 /zenstore/compactcas.cpp
parentUse proper locking in MarkAsDeleteOnClose() (diff)
downloadzen-02dd0b386fbc1fde486b8f6780cc620e1850515f.tar.xz
zen-02dd0b386fbc1fde486b8f6780cc620e1850515f.zip
add test that triggers direct removal of block in gc
Diffstat (limited to 'zenstore/compactcas.cpp')
-rw-r--r--zenstore/compactcas.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/zenstore/compactcas.cpp b/zenstore/compactcas.cpp
index fe0fc8f6b..b816869c3 100644
--- a/zenstore/compactcas.cpp
+++ b/zenstore/compactcas.cpp
@@ -1400,6 +1400,40 @@ TEST_CASE("compactcas.gc.basic")
IoHash ChunkHash = IoHash::HashBuffer(Chunk);
const auto InsertResult = Cas.InsertChunk(Chunk, ChunkHash);
+ CHECK(InsertResult.New);
+
+ GcContext GcCtx;
+ GcCtx.CollectSmallObjects(true);
+
+ Cas.CollectGarbage(GcCtx);
+
+ CHECK(!Cas.HaveChunk(ChunkHash));
+}
+
+TEST_CASE("compactcas.gc.removefile")
+{
+ ScopedTemporaryDirectory TempDir;
+
+ CasStoreConfiguration CasConfig;
+ CasConfig.RootDirectory = TempDir.Path();
+ CreateDirectories(CasConfig.RootDirectory);
+
+ IoBuffer Chunk = CreateChunk(128);
+ IoHash ChunkHash = IoHash::HashBuffer(Chunk);
+ {
+ CasGc Gc;
+ CasContainerStrategy Cas(CasConfig, Gc);
+ Cas.Initialize("cb", 65536, 1 << 4, true);
+
+ const auto InsertResult = Cas.InsertChunk(Chunk, ChunkHash);
+ CHECK(InsertResult.New);
+ const auto InsertResultDup = Cas.InsertChunk(Chunk, ChunkHash);
+ CHECK(!InsertResultDup.New);
+ }
+
+ CasGc Gc;
+ CasContainerStrategy Cas(CasConfig, Gc);
+ Cas.Initialize("cb", 65536, 1 << 4, false);
GcContext GcCtx;
GcCtx.CollectSmallObjects(true);