aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-10-20 11:32:21 +0200
committerStefan Boberg <[email protected]>2021-10-20 11:32:21 +0200
commitae8446a752944bb0e48264615566ae1454e47c7e (patch)
treee3ff4d12847cf5d74a41a5d156c569cc3549f2f4
parentgc: comment (diff)
downloadzen-ae8446a752944bb0e48264615566ae1454e47c7e.tar.xz
zen-ae8446a752944bb0e48264615566ae1454e47c7e.zip
cas: Adding cas.file.gc test for exercising garbage collection (incomplete)
-rw-r--r--zenstore/filecas.cpp36
1 files changed, 35 insertions, 1 deletions
diff --git a/zenstore/filecas.cpp b/zenstore/filecas.cpp
index a37450cd8..d8811de00 100644
--- a/zenstore/filecas.cpp
+++ b/zenstore/filecas.cpp
@@ -15,6 +15,11 @@
#include <zencore/uid.h>
#include <zenstore/basicfile.h>
+#if ZEN_WITH_TESTS
+# include <zencore/compactbinarybuilder.h>
+# include <zenstore/gc.h>
+#endif
+
#include <gsl/gsl-lite.hpp>
#include <barrier>
@@ -489,7 +494,8 @@ TEST_CASE("cas.file.move")
{
using namespace fmt::literals;
- ScopedTemporaryDirectory TempDir{"d:\\filecas_testdir"};
+ // specifying an absolute path here can be helpful when using procmon to dig into things
+ ScopedTemporaryDirectory TempDir; // {"d:\\filecas_testdir"};
CasStoreConfiguration CasConfig;
CasConfig.RootDirectory = TempDir.Path() / "cas";
@@ -564,6 +570,34 @@ TEST_CASE("cas.file.move")
# endif
}
+TEST_CASE("cas.file.gc")
+{
+ // specifying an absolute path here can be helpful when using procmon to dig into things
+ ScopedTemporaryDirectory TempDir; // {"d:\\filecas_testdir"};
+
+ CasStoreConfiguration CasConfig;
+ CasConfig.RootDirectory = TempDir.Path() / "cas";
+
+ FileCasStrategy FileCas(CasConfig);
+
+ for (int i = 0; i < 1000; ++i)
+ {
+ CbObjectWriter Cbo;
+ Cbo << "id" << i;
+ CbObject Obj = Cbo.Save();
+
+ IoBuffer ObjBuffer = Obj.GetBuffer().AsIoBuffer();
+ IoHash Hash = HashBuffer(ObjBuffer);
+
+ FileCas.InsertChunk(ObjBuffer, Hash);
+ ;
+ }
+
+ GcContext Ctx;
+
+ FileCas.GarbageCollect(Ctx);
+}
+
#endif
void