diff options
Diffstat (limited to 'src/zenstore')
| -rw-r--r-- | src/zenstore/cache/cacherpc.cpp | 52 | ||||
| -rw-r--r-- | src/zenstore/cache/structuredcachestore.cpp | 20 | ||||
| -rw-r--r-- | src/zenstore/zenstore.cpp | 2 |
3 files changed, 15 insertions, 59 deletions
diff --git a/src/zenstore/cache/cacherpc.cpp b/src/zenstore/cache/cacherpc.cpp index 5acb2b8c9..e6ba6629d 100644 --- a/src/zenstore/cache/cacherpc.cpp +++ b/src/zenstore/cache/cacherpc.cpp @@ -14,55 +14,9 @@ #include <zenstore/cache/structuredcachestore.h> #include <zenstore/cache/upstreamcacheclient.h> #include <zenstore/cidstore.h> +#include <zenutil/cache/cacherequests.h> #include <zenutil/packageformat.h> -namespace zen { namespace { - - constinit AsciiSet ValidNamespaceNameCharactersSet{"abcdefghijklmnopqrstuvwxyz0123456789-_.ABCDEFGHIJKLMNOPQRSTUVWXYZ"}; - constinit AsciiSet ValidBucketNameCharactersSet{"abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}; - - std::optional<std::string> GetValidNamespaceName(std::string_view Name) - { - if (Name.empty()) - { - ZEN_WARN("Namespace is invalid, empty namespace is not allowed"); - return {}; - } - - if (Name.length() > 64) - { - ZEN_WARN("Namespace '{}' is invalid, length exceeds 64 characters", Name); - return {}; - } - - if (!AsciiSet::HasOnly(Name, ValidNamespaceNameCharactersSet)) - { - ZEN_WARN("Namespace '{}' is invalid, invalid characters detected", Name); - return {}; - } - - return ToLower(Name); - } - - std::optional<std::string> GetValidBucketName(std::string_view Name) - { - if (Name.empty()) - { - ZEN_WARN("Bucket name is invalid, empty bucket name is not allowed"); - return {}; - } - - if (!AsciiSet::HasOnly(Name, ValidBucketNameCharactersSet)) - { - ZEN_WARN("Bucket name '{}' is invalid, invalid characters detected", Name); - return {}; - } - - return ToLower(Name); - } - -}} // namespace zen:: - ////////////////////////////////////////////////////////////////////////// namespace zen { @@ -86,7 +40,7 @@ GetRpcRequestNamespace(const CbObjectView Params) { return {}; } - return GetValidNamespaceName(NamespaceField.AsString()); + return cacherequests::GetValidNamespaceName(NamespaceField.AsString()); } bool @@ -101,7 +55,7 @@ GetRpcRequestCacheKey(const CbObjectView& KeyView, CacheKey& Key) { return false; } - std::optional<std::string> Bucket = GetValidBucketName(BucketField.AsString()); + std::optional<std::string> Bucket = cacherequests::GetValidBucketName(BucketField.AsString()); if (!Bucket.has_value()) { return false; diff --git a/src/zenstore/cache/structuredcachestore.cpp b/src/zenstore/cache/structuredcachestore.cpp index 7ef290cf5..daa628f77 100644 --- a/src/zenstore/cache/structuredcachestore.cpp +++ b/src/zenstore/cache/structuredcachestore.cpp @@ -873,7 +873,7 @@ namespace testutils { } // namespace testutils -TEST_CASE("z$.store") +TEST_CASE("cachestore.store") { ScopedTemporaryDirectory TempDir; @@ -914,7 +914,7 @@ TEST_CASE("z$.store") } } -TEST_CASE("z$.size") +TEST_CASE("cachestore.size") { auto JobQueue = MakeJobQueue(1, "testqueue"); @@ -1029,7 +1029,7 @@ TEST_CASE("z$.size") } } -TEST_CASE("z$.gc") +TEST_CASE("cachestore.gc") { using namespace testutils; @@ -1208,7 +1208,7 @@ TEST_CASE("z$.gc") } } -TEST_CASE_TEMPLATE("z$.threadedinsert", GCV2, FalseType, TrueType) // * doctest::skip(true)) +TEST_CASE_TEMPLATE("cachestore.threadedinsert", GCV2, FalseType, TrueType) // * doctest::skip(true)) { // for (uint32_t i = 0; i < 100; ++i) { @@ -1482,7 +1482,7 @@ TEST_CASE_TEMPLATE("z$.threadedinsert", GCV2, FalseType, TrueType) // * doctest: } } -TEST_CASE("z$.namespaces") +TEST_CASE("cachestore.namespaces") { using namespace testutils; @@ -1550,7 +1550,7 @@ TEST_CASE("z$.namespaces") } } -TEST_CASE("z$.drop.bucket") +TEST_CASE("cachestore.drop.bucket") { using namespace testutils; @@ -1625,7 +1625,7 @@ TEST_CASE("z$.drop.bucket") } } -TEST_CASE("z$.drop.namespace") +TEST_CASE("cachestore.drop.namespace") { using namespace testutils; @@ -1715,7 +1715,7 @@ TEST_CASE("z$.drop.namespace") } } -TEST_CASE("z$.blocked.disklayer.put") +TEST_CASE("cachestore.blocked.disklayer.put") { ScopedTemporaryDirectory TempDir; @@ -1768,7 +1768,7 @@ TEST_CASE("z$.blocked.disklayer.put") CHECK(memcmp(NewView.GetData(), Buffer2.GetData(), NewView.GetSize()) == 0); } -TEST_CASE("z$.scrub") +TEST_CASE("cachestore.scrub") { ScopedTemporaryDirectory TempDir; @@ -1862,7 +1862,7 @@ TEST_CASE("z$.scrub") CHECK(ScrubCtx.BadCids().GetSize() == 0); } -TEST_CASE("z$.newgc.basics") +TEST_CASE("cachestore.newgc.basics") { using namespace testutils; diff --git a/src/zenstore/zenstore.cpp b/src/zenstore/zenstore.cpp index 60dabe31f..038c6bdc7 100644 --- a/src/zenstore/zenstore.cpp +++ b/src/zenstore/zenstore.cpp @@ -5,6 +5,7 @@ #if ZEN_WITH_TESTS # include <zenstore/blockstore.h> +# include <zenstore/cache/structuredcachestore.h> # include <zenstore/gc.h> # include <zenstore/hashkeyset.h> @@ -23,6 +24,7 @@ zenstore_forcelinktests() compactcas_forcelink(); gc_forcelink(); hashkeyset_forcelink(); + structured_cachestore_forcelink(); } } // namespace zen |