aboutsummaryrefslogtreecommitdiff
path: root/zenserver-test/zenserver-test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'zenserver-test/zenserver-test.cpp')
-rw-r--r--zenserver-test/zenserver-test.cpp72
1 files changed, 31 insertions, 41 deletions
diff --git a/zenserver-test/zenserver-test.cpp b/zenserver-test/zenserver-test.cpp
index efcbf5da8..df17cc353 100644
--- a/zenserver-test/zenserver-test.cpp
+++ b/zenserver-test/zenserver-test.cpp
@@ -10,6 +10,7 @@
#include <zencore/filesystem.h>
#include <zencore/fmtutils.h>
#include <zencore/iohash.h>
+#include <zencore/logging.h>
#include <zencore/string.h>
#include <zencore/thread.h>
#include <zencore/timer.h>
@@ -26,8 +27,6 @@
#endif
#include <cpr/cpr.h>
-#include <spdlog/spdlog.h>
-
#include <ppl.h>
#include <atomic>
#include <filesystem>
@@ -123,7 +122,7 @@ public:
private:
void Reset() {}
- void OnError(const std::error_code& Error) { spdlog::error("HTTP client error! '{}'", Error.message()); }
+ void OnError(const std::error_code& Error) { ZEN_ERROR("HTTP client error! '{}'", Error.message()); }
int OnHeader(const char* Data, size_t Bytes)
{
@@ -137,7 +136,7 @@ private:
}
int OnHeadersComplete()
{
- spdlog::debug("Headers complete");
+ ZEN_DEBUG("Headers complete");
return 0;
}
int OnMessageComplete()
@@ -198,7 +197,7 @@ private:
{
// Something bad!
- spdlog::error("parse error {}", (uint32_t)m_HttpParser.http_errno);
+ ZEN_ERROR("parse error {}", (uint32_t)m_HttpParser.http_errno);
}
switch (m_RequestState)
@@ -613,7 +612,7 @@ main()
if (Result.status_code != 200)
{
- spdlog::warn("request response: {}", Result.status_code);
+ ZEN_WARN("request response: {}", Result.status_code);
}
}
};
@@ -631,7 +630,7 @@ main()
// cpr::Response r = cpr::Get(cpr::Url{ "http://localhost:1337/test/hello" });
- spdlog::info("{} requests in {} ({})",
+ ZEN_INFO("{} requests in {} ({})",
RequestCount,
zen::NiceTimeSpanMs(timer.getElapsedTimeMs()),
zen::NiceRate(RequestCount, (uint32_t)timer.getElapsedTimeMs(), "req"));
@@ -668,7 +667,7 @@ main(int argc, char** argv)
TestEnv.InitializeForTest(ProgramBaseDir, TestBaseDir);
- spdlog::info("Running tests...(base dir: '{}')", TestBaseDir);
+ ZEN_INFO("Running tests...(base dir: '{}')", TestBaseDir);
return doctest::Context(argc, argv).run();
}
@@ -681,7 +680,7 @@ TEST_CASE("asio.http")
Instance.SetTestDir(TestDir);
Instance.SpawnServer(13337);
- spdlog::info("Waiting...");
+ ZEN_INFO("Waiting...");
Instance.WaitUntilReady();
@@ -704,20 +703,20 @@ TEST_CASE("default.single")
Instance.SetTestDir(TestDir);
Instance.SpawnServer(13337);
- spdlog::info("Waiting...");
+ ZEN_INFO("Waiting...");
Instance.WaitUntilReady();
std::atomic<uint64_t> RequestCount{0};
std::atomic<uint64_t> BatchCounter{0};
- spdlog::info("Running single server test...");
+ ZEN_INFO("Running single server test...");
auto IssueTestRequests = [&] {
const uint64_t BatchNo = BatchCounter.fetch_add(1);
const DWORD ThreadId = GetCurrentThreadId();
- spdlog::info("query batch {} started (thread {})", BatchNo, ThreadId);
+ ZEN_INFO("query batch {} started (thread {})", BatchNo, ThreadId);
cpr::Session cli;
cli.SetUrl(cpr::Url{"http://localhost:13337/test/hello"});
@@ -726,7 +725,7 @@ TEST_CASE("default.single")
auto res = cli.Get();
++RequestCount;
}
- spdlog::info("query batch {} ended (thread {})", BatchNo, ThreadId);
+ ZEN_INFO("query batch {} ended (thread {})", BatchNo, ThreadId);
};
auto fun10 = [&] {
@@ -758,10 +757,7 @@ TEST_CASE("default.single")
uint64_t Elapsed = timer.getElapsedTimeMs();
- spdlog::info("{} requests in {} ({})",
- RequestCount,
- zen::NiceTimeSpanMs(Elapsed),
- zen::NiceRate(RequestCount, (uint32_t)Elapsed, "req"));
+ ZEN_INFO("{} requests in {} ({})", RequestCount, zen::NiceTimeSpanMs(Elapsed), zen::NiceRate(RequestCount, (uint32_t)Elapsed, "req"));
}
TEST_CASE("multi.basic")
@@ -776,7 +772,7 @@ TEST_CASE("multi.basic")
Instance2.SetTestDir(TestDir2);
Instance2.SpawnServer(13338);
- spdlog::info("Waiting...");
+ ZEN_INFO("Waiting...");
Instance1.WaitUntilReady();
Instance2.WaitUntilReady();
@@ -788,7 +784,7 @@ TEST_CASE("multi.basic")
const uint64_t BatchNo = BatchCounter.fetch_add(1);
const DWORD ThreadId = GetCurrentThreadId();
- spdlog::info("query batch {} started (thread {}) for port {}", BatchNo, ThreadId, PortNumber);
+ ZEN_INFO("query batch {} started (thread {}) for port {}", BatchNo, ThreadId, PortNumber);
cpr::Session cli;
cli.SetUrl(cpr::Url{"http://localhost:{}/test/hello"_format(PortNumber)});
@@ -798,12 +794,12 @@ TEST_CASE("multi.basic")
auto res = cli.Get();
++RequestCount;
}
- spdlog::info("query batch {} ended (thread {})", BatchNo, ThreadId);
+ ZEN_INFO("query batch {} ended (thread {})", BatchNo, ThreadId);
};
zen::Stopwatch timer;
- spdlog::info("Running multi-server test...");
+ ZEN_INFO("Running multi-server test...");
Concurrency::parallel_invoke([&] { IssueTestRequests(13337); },
[&] { IssueTestRequests(13338); },
@@ -812,10 +808,7 @@ TEST_CASE("multi.basic")
uint64_t Elapsed = timer.getElapsedTimeMs();
- spdlog::info("{} requests in {} ({})",
- RequestCount,
- zen::NiceTimeSpanMs(Elapsed),
- zen::NiceRate(RequestCount, (uint32_t)Elapsed, "req"));
+ ZEN_INFO("{} requests in {} ({})", RequestCount, zen::NiceTimeSpanMs(Elapsed), zen::NiceRate(RequestCount, (uint32_t)Elapsed, "req"));
}
TEST_CASE("cas.basic")
@@ -888,10 +881,10 @@ TEST_CASE("cas.basic")
uint64_t Elapsed = timer.getElapsedTimeMs();
- spdlog::info("{} requests in {} ({})",
- RequestCount,
- zen::NiceTimeSpanMs(Elapsed),
- zen::NiceRate(RequestCount, (uint32_t)Elapsed, "req"));
+ ZEN_INFO("{} requests in {} ({})",
+ RequestCount,
+ zen::NiceTimeSpanMs(Elapsed),
+ zen::NiceRate(RequestCount, (uint32_t)Elapsed, "req"));
}
// Verify that the data persists between process runs (the previous server has exited at this point)
@@ -1058,17 +1051,14 @@ TEST_CASE("project.basic")
CHECK(Response.text.size() == 10);
}
- spdlog::info("+++++++");
+ ZEN_INFO("+++++++");
}
- SUBCASE("build store op commit") { spdlog::info("-------"); }
+ SUBCASE("build store op commit") { ZEN_INFO("-------"); }
}
const uint64_t Elapsed = timer.getElapsedTimeMs();
- spdlog::info("{} requests in {} ({})",
- RequestCount,
- zen::NiceTimeSpanMs(Elapsed),
- zen::NiceRate(RequestCount, (uint32_t)Elapsed, "req"));
+ ZEN_INFO("{} requests in {} ({})", RequestCount, zen::NiceTimeSpanMs(Elapsed), zen::NiceRate(RequestCount, (uint32_t)Elapsed, "req"));
}
# if 0 // this is extremely WIP
@@ -1239,12 +1229,12 @@ struct RemoteExecutionRequest
if (CasResponse.status_code >= 300)
{
- spdlog::error("CAS put failed with {}", CasResponse.status_code);
+ ZEN_ERROR("CAS put failed with {}", CasResponse.status_code);
}
}
else
{
- spdlog::error("unknown hash in 'need' list: {}", NeedHash);
+ ZEN_ERROR("unknown hash in 'need' list: {}", NeedHash);
}
}
}
@@ -1260,7 +1250,7 @@ struct RemoteExecutionRequest
return zen::LoadCompactBinaryObject(std::move(Payload));
}
- spdlog::info("job exec: {}", JobResponse.status_code);
+ ZEN_INFO("job exec: {}", JobResponse.status_code);
return {};
}
@@ -1280,7 +1270,7 @@ private:
zen::IoHash Hash = Ios.GetHash();
std::wstring RelativePath = FullPath.lexically_relative(m_RootPath).native();
- // spdlog::info("File: {:32} => {} ({})", zen::WideToUtf8(RelativePath), Hash, FileSize);
+ // ZEN_INFO("File: {:32} => {} ({})", zen::WideToUtf8(RelativePath), Hash, FileSize);
FileEntry& Entry = m_Files[RelativePath];
Entry.Hash = Hash;
@@ -1360,7 +1350,7 @@ TEST_CASE("mesh.basic")
const int kInstanceCount = 4;
- spdlog::info("spawning {} instances", kInstanceCount);
+ ZEN_INFO("spawning {} instances", kInstanceCount);
std::unique_ptr<ZenServerInstance> Instances[kInstanceCount];
@@ -1395,7 +1385,7 @@ public:
void SpawnServers(auto&& Callback)
{
- spdlog::info("{}: spawning {} server instances", m_HelperId, m_ServerCount);
+ ZEN_INFO("{}: spawning {} server instances", m_HelperId, m_ServerCount);
m_Instances.resize(m_ServerCount);