diff options
| author | Per Larsson <[email protected]> | 2021-09-17 14:56:28 +0200 |
|---|---|---|
| committer | Per Larsson <[email protected]> | 2021-09-17 14:56:28 +0200 |
| commit | 3de09e2bbf9aba945f8f7e55c6c8dc866fc8d712 (patch) | |
| tree | b8dc1eb4e7cf1511f68ab5fae2804819cece353a /zenserver-test/zenserver-test.cpp | |
| parent | Initial support for cache policies. (diff) | |
| download | zen-3de09e2bbf9aba945f8f7e55c6c8dc866fc8d712.tar.xz zen-3de09e2bbf9aba945f8f7e55c6c8dc866fc8d712.zip | |
Added test for store local/remote cache policy.
Diffstat (limited to 'zenserver-test/zenserver-test.cpp')
| -rw-r--r-- | zenserver-test/zenserver-test.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/zenserver-test/zenserver-test.cpp b/zenserver-test/zenserver-test.cpp index 8db056bc4..8811a87e9 100644 --- a/zenserver-test/zenserver-test.cpp +++ b/zenserver-test/zenserver-test.cpp @@ -1479,6 +1479,41 @@ TEST_CASE("zcache.policy") CHECK(Result.status_code == 200); } } + + SUBCASE("store - 'local' does store upstream") + { + ZenConfig UpstreamCfg = ZenConfig::New(13338); + ZenServerInstance UpstreamInst(TestEnv); + ZenConfig LocalCfg = ZenConfig::NewWithUpstream(13338); + ZenServerInstance LocalInst(TestEnv); + const auto Bucket = "legacy"sv; + + UpstreamCfg.Spawn(UpstreamInst); + LocalCfg.Spawn(LocalInst); + + zen::IoHash Key; + auto BinaryValue = GenerateData(1024, Key); + + // Store binary cache value upstream + { + cpr::Response Result = cpr::Put(cpr::Url{"{}/{}/{}?store=local"_format(LocalCfg.BaseUri, Bucket, Key)}, + cpr::Body{(const char*)BinaryValue.GetData(), BinaryValue.GetSize()}, + cpr::Header{{"Content-Type", "application/octet-stream"}}); + CHECK(Result.status_code == 201); + } + + { + cpr::Response Result = cpr::Get(cpr::Url{"{}/{}/{}"_format(UpstreamCfg.BaseUri, Bucket, Key)}, + cpr::Header{{"Accept", "application/octet-stream"}}); + CHECK(Result.status_code == 404); + } + + { + cpr::Response Result = + cpr::Get(cpr::Url{"{}/{}/{}"_format(LocalCfg.BaseUri, Bucket, Key)}, cpr::Header{{"Accept", "application/octet-stream"}}); + CHECK(Result.status_code == 200); + } + } } struct RemoteExecutionRequest |