From 02dd0b386fbc1fde486b8f6780cc620e1850515f Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Mon, 21 Mar 2022 08:42:29 +0100 Subject: add test that triggers direct removal of block in gc --- zenstore/compactcas.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'zenstore/compactcas.cpp') 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); -- cgit v1.2.3