aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/zenmaster/zenmaster.cpp59
1 files changed, 58 insertions, 1 deletions
diff --git a/src/zenmaster/zenmaster.cpp b/src/zenmaster/zenmaster.cpp
index 483ec6828..4981a3eb0 100644
--- a/src/zenmaster/zenmaster.cpp
+++ b/src/zenmaster/zenmaster.cpp
@@ -294,7 +294,64 @@ main(int argc, char** argv)
ShutdownLogging();
});
- zen::Sleep(1000000);
+ // Spawn some zenserver processes
+
+ zen::ZenServerEnvironment TestEnv;
+
+ std::filesystem::path ProgramBaseDir = GetRunningExecutablePath().parent_path();
+ std::filesystem::path TestBaseDir = std::filesystem::current_path() / ".test";
+
+ const std::string ServerClass;
+
+ TestEnv.InitializeForTest(ProgramBaseDir, TestBaseDir, ServerClass);
+
+ auto TimedBlock = [&](const std::string_view Tag, auto&& Fun) {
+ Stopwatch t;
+ ZEN_INFO("BEGIN {}", Tag);
+ Fun();
+ ZEN_INFO("END {}, took {}", Tag, NiceTimeSpanMs(t.GetElapsedTimeMs()));
+ };
+
+ int SpawnCount = 100;
+
+ std::vector<std::unique_ptr<ZenServerInstance>> Instances;
+
+ TimedBlock("Spawning instances", [&] {
+ for (int i = 0; i < SpawnCount; ++i)
+ {
+ auto& Instance = Instances.emplace_back(std::make_unique<ZenServerInstance>(TestEnv));
+
+ std::filesystem::path TestDir1 = TestEnv.CreateNewTestDir();
+ Instance->SetTestDir(TestDir1);
+ Instance->SpawnServer();
+ }
+ });
+
+ TimedBlock("Waiting for instances", [&] {
+ for (int i = 0; i < SpawnCount; ++i)
+ {
+ auto& Instance = Instances[i];
+
+ const uint16_t PortNum = Instance->WaitUntilReady();
+
+ ZEN_INFO("Instance #{} UP - port {}", i, PortNum);
+ }
+ });
+
+ zen::Sleep(10000);
+
+ TimedBlock("Shutting down instances", [&] {
+ for (int i = 0; i < SpawnCount; ++i)
+ {
+ auto& Instance = Instances[i];
+
+ ZEN_INFO("Shutting down instance #{}...", i);
+
+ Instance->Shutdown();
+
+ ZEN_INFO("Instance #{} DOWN", i);
+ }
+ });
}
catch (const OptionParseException& Ex)
{