aboutsummaryrefslogtreecommitdiff
path: root/zenserver-test/zenserver-test.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2022-05-19 11:37:25 +0200
committerDan Engelbrecht <[email protected]>2022-05-19 11:37:25 +0200
commita9130d34b5318b0da5d3547c432a8734213fbe9b (patch)
tree2cdb96f85e221cc24227b410d4d5f8f4e4af7a41 /zenserver-test/zenserver-test.cpp
parentMerge pull request #98 from EpicGames/de/fix-bucket-name-rules (diff)
downloadzen-a9130d34b5318b0da5d3547c432a8734213fbe9b.tar.xz
zen-a9130d34b5318b0da5d3547c432a8734213fbe9b.zip
Keep Namespace out of CacheKey and store it on request level
RPC requests now has a Namespace field under Params instead of one Namespace per cache key Fall back to legacy upstream HTTP URI format if default namespace is requested
Diffstat (limited to 'zenserver-test/zenserver-test.cpp')
-rw-r--r--zenserver-test/zenserver-test.cpp49
1 files changed, 28 insertions, 21 deletions
diff --git a/zenserver-test/zenserver-test.cpp b/zenserver-test/zenserver-test.cpp
index 0f4858bd5..c79b540ea 100644
--- a/zenserver-test/zenserver-test.cpp
+++ b/zenserver-test/zenserver-test.cpp
@@ -1462,7 +1462,7 @@ TEST_CASE("zcache.rpc")
{
zen::IoHash KeyHash;
((uint32_t*)(KeyHash.Hash))[0] = Key;
- const zen::CacheKey CacheKey = zen::CacheKey::Create(Namespace, Bucket, KeyHash);
+ const zen::CacheKey CacheKey = zen::CacheKey::Create(Bucket, KeyHash);
CbPackage Package;
CbWriter Writer;
@@ -1474,6 +1474,7 @@ TEST_CASE("zcache.rpc")
{
CachePolicy BatchDefaultPolicy = CachePolicy::Default;
Writer << "DefaultPolicy"sv << WriteToString<128>(BatchDefaultPolicy);
+ Writer << "Namespace"sv << Namespace;
Writer.BeginArray("Requests"sv);
{
AppendCacheRecord(Package, Writer, CacheKey, PayloadSize, BatchDefaultPolicy, CachePolicy::Default);
@@ -1505,7 +1506,10 @@ TEST_CASE("zcache.rpc")
bool Success;
};
- auto GetCacheRecords = [](std::string_view BaseUri, std::span<zen::CacheKey> Keys, zen::CachePolicy Policy) -> GetCacheRecordResult {
+ auto GetCacheRecords = [](std::string_view BaseUri,
+ std::string_view Namespace,
+ std::span<zen::CacheKey> Keys,
+ zen::CachePolicy Policy) -> GetCacheRecordResult {
using namespace zen;
CbObjectWriter Request;
@@ -1514,6 +1518,8 @@ TEST_CASE("zcache.rpc")
Request.BeginObject("Params"sv);
{
Request << "DefaultPolicy"sv << WriteToString<128>(Policy);
+ Request << "Namespace"sv << Namespace;
+
Request.BeginArray("Requests"sv);
for (const CacheKey& Key : Keys)
{
@@ -1563,9 +1569,7 @@ TEST_CASE("zcache.rpc")
auto LoadKey = [](zen::CbFieldView KeyView) -> zen::CacheKey {
if (zen::CbObjectView KeyObj = KeyView.AsObjectView())
{
- return CacheKey::Create(KeyObj["Namespace"sv] ? KeyObj["Namespace"sv].AsString() : ""sv,
- KeyObj["Bucket"sv].AsString(),
- KeyObj["Hash"].AsHash());
+ return CacheKey::Create(KeyObj["Bucket"sv].AsString(), KeyObj["Hash"].AsHash());
}
return CacheKey::Empty;
};
@@ -1582,8 +1586,8 @@ TEST_CASE("zcache.rpc")
Inst.WaitUntilReady();
CachePolicy Policy = CachePolicy::Default;
- std::vector<zen::CacheKey> Keys = PutCacheRecords(BaseUri, ""sv, "mastodon"sv, 128);
- GetCacheRecordResult Result = GetCacheRecords(BaseUri, Keys, Policy);
+ std::vector<zen::CacheKey> Keys = PutCacheRecords(BaseUri, "default"sv, "mastodon"sv, 128);
+ GetCacheRecordResult Result = GetCacheRecords(BaseUri, "default"sv, Keys, Policy);
CHECK(Result.Records.size() == Keys.size());
@@ -1593,11 +1597,9 @@ TEST_CASE("zcache.rpc")
CbObjectView RecordObj = RecordView.AsObjectView();
CbObjectView KeyObj = RecordObj["Key"sv].AsObjectView();
- const CacheKey Key = CacheKey::Create(KeyObj["Namespace"sv] ? KeyObj["Namespace"sv].AsString() : ""sv,
- KeyObj["Bucket"sv].AsString(),
- KeyObj["Hash"].AsHash());
- IoHash AttachmentHash;
- size_t NumValues = 0;
+ const CacheKey Key = CacheKey::Create(KeyObj["Bucket"sv].AsString(), KeyObj["Hash"].AsHash());
+ IoHash AttachmentHash;
+ size_t NumValues = 0;
for (CbFieldView Value : RecordObj["Values"sv])
{
AttachmentHash = Value.AsObjectView()["RawHash"sv].AsHash();
@@ -1623,16 +1625,16 @@ TEST_CASE("zcache.rpc")
Inst.WaitUntilReady();
CachePolicy Policy = CachePolicy::Default;
- std::vector<zen::CacheKey> ExistingKeys = PutCacheRecords(BaseUri, ""sv, "mastodon"sv, 128);
+ std::vector<zen::CacheKey> ExistingKeys = PutCacheRecords(BaseUri, "default"sv, "mastodon"sv, 128);
std::vector<zen::CacheKey> Keys;
for (const zen::CacheKey& Key : ExistingKeys)
{
Keys.push_back(Key);
- Keys.push_back(CacheKey::Create("missing"sv, "missing"sv, IoHash::Zero));
+ Keys.push_back(CacheKey::Create("missing"sv, IoHash::Zero));
}
- GetCacheRecordResult Result = GetCacheRecords(BaseUri, Keys, Policy);
+ GetCacheRecordResult Result = GetCacheRecords(BaseUri, "default"sv, Keys, Policy);
CHECK(Result.Records.size() == Keys.size());
@@ -1677,10 +1679,10 @@ TEST_CASE("zcache.rpc")
SpawnServer(UpstreamServer, UpstreamCfg);
SpawnServer(LocalServer, LocalCfg);
- std::vector<zen::CacheKey> Keys = PutCacheRecords(UpstreamCfg.BaseUri, ""sv, "mastodon"sv, 4);
+ std::vector<zen::CacheKey> Keys = PutCacheRecords(UpstreamCfg.BaseUri, "default"sv, "mastodon"sv, 4);
CachePolicy Policy = CachePolicy::QueryLocal;
- GetCacheRecordResult Result = GetCacheRecords(LocalCfg.BaseUri, Keys, Policy);
+ GetCacheRecordResult Result = GetCacheRecords(LocalCfg.BaseUri, "default"sv, Keys, Policy);
CHECK(Result.Records.size() == Keys.size());
@@ -1702,10 +1704,10 @@ TEST_CASE("zcache.rpc")
SpawnServer(UpstreamServer, UpstreamCfg);
SpawnServer(LocalServer, LocalCfg);
- std::vector<zen::CacheKey> Keys = PutCacheRecords(UpstreamCfg.BaseUri, ""sv, "mastodon"sv, 4);
+ std::vector<zen::CacheKey> Keys = PutCacheRecords(UpstreamCfg.BaseUri, "default"sv, "mastodon"sv, 4);
CachePolicy Policy = (CachePolicy::QueryLocal | CachePolicy::QueryRemote);
- GetCacheRecordResult Result = GetCacheRecords(LocalCfg.BaseUri, Keys, Policy);
+ GetCacheRecordResult Result = GetCacheRecords(LocalCfg.BaseUri, "default"sv, Keys, Policy);
CHECK(Result.Records.size() == Keys.size());
@@ -1736,7 +1738,7 @@ TEST_CASE("zcache.rpc.allpolicies")
std::string_view TestVersion = "F72150A02AE34B57A9EC91D36BA1CE08"sv;
std::string_view TestBucket = "allpoliciestest"sv;
- std::string_view TestNamespace = ""sv;
+ std::string_view TestNamespace = "default"sv;
// NumKeys = (2 Value vs Record)*(2 SkipData vs Default)*(2 ForceMiss vs Not)*(2 use local)
// *(2 use remote)*(2 UseValue Policy vs not)*(4 cases per type)
@@ -1838,7 +1840,7 @@ TEST_CASE("zcache.rpc.allpolicies")
IoHash KeyHash = KeyWriter.GetHash();
KeyData& KeyData = KeyDatas[KeyIndex];
- KeyData.Key = CacheKey::Create(TestNamespace, TestBucket, KeyHash);
+ KeyData.Key = CacheKey::Create(TestBucket, KeyHash);
KeyData.KeyIndex = KeyIndex;
KeyData.GetRequestsData = (KeyIndex & (1 << 1)) == 0;
KeyData.UseValueAPI = (KeyIndex & (1 << 2)) != 0;
@@ -1937,6 +1939,7 @@ TEST_CASE("zcache.rpc.allpolicies")
{
CachePolicy BatchDefaultPolicy = CachePolicy::Default;
Writer << "DefaultPolicy"sv << WriteToString<128>(BatchDefaultPolicy);
+ Writer << "Namespace"sv << TestNamespace;
Writer.BeginArray("Requests"sv);
for (CachePutRequest& Request : PutRequests)
{
@@ -1992,6 +1995,7 @@ TEST_CASE("zcache.rpc.allpolicies")
{
CachePolicy BatchDefaultPolicy = CachePolicy::Default;
Writer << "DefaultPolicy"sv << WriteToString<128>(BatchDefaultPolicy);
+ Writer << "Namespace"sv << TestNamespace;
Writer.BeginArray("Requests"sv);
for (CachePutValueRequest& Request : PutValueRequests)
{
@@ -2047,6 +2051,7 @@ TEST_CASE("zcache.rpc.allpolicies")
{
CachePolicy BatchDefaultPolicy = CachePolicy::Default;
Writer << "DefaultPolicy"sv << WriteToString<128>(BatchDefaultPolicy);
+ Writer << "Namespace"sv << TestNamespace;
Writer.BeginArray("Requests"sv);
for (CacheGetRequest& Request : GetRequests)
{
@@ -2158,6 +2163,7 @@ TEST_CASE("zcache.rpc.allpolicies")
{
CachePolicy BatchDefaultPolicy = CachePolicy::Default;
Writer << "DefaultPolicy"sv << WriteToString<128>(BatchDefaultPolicy);
+ Writer << "Namespace"sv << TestNamespace;
Writer.BeginArray("Requests"sv);
for (CacheGetValueRequest& Request : GetValueRequests)
{
@@ -2252,6 +2258,7 @@ TEST_CASE("zcache.rpc.allpolicies")
{
CachePolicy BatchDefaultPolicy = CachePolicy::Default;
Writer << "DefaultPolicy"sv << WriteToString<128>(BatchDefaultPolicy);
+ Writer << "Namespace"sv << TestNamespace;
Writer.BeginArray("ChunkRequests"sv);
for (CacheGetChunkRequest& Request : ChunkRequests)
{