refactor(test): set up test configs with test::Configure()

- 33 places repeated the same session, shm segment size, shm monitor
  and expanded metadata properties
- call test::Configure() and set only the properties that differ

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-11-03 14:14:53 +00:00
committed by Dennis Klein
parent d4a85086aa
commit 0367c2a4a8
8 changed files with 39 additions and 124 deletions

View File

@@ -14,6 +14,7 @@
#include <fairmq/ProgOptions.h>
#include <fairmq/TransportFactory.h>
#include <fairmq/tools/Unique.h>
#include <helper/Transport.h>
#include <gtest/gtest.h>
#include <memory>
#include <sstream>
@@ -40,9 +41,7 @@ void CheckOldOptionInterface(Channel& channel, const string& option)
void RunOptionsTest(const string& transport)
{
ProgOptions config;
config.SetProperty<string>("session", tools::Uuid());
config.SetProperty<bool>("shm-monitor", true);
config.SetProperty<size_t>("shm-segment-size", 100000000);
test::Configure(config);
auto factory = TransportFactory::CreateTransportFactory(transport, tools::Uuid(), &config);
Channel channel("Push", "push", factory);
@@ -72,11 +71,10 @@ void RunOptionsTest(const string& transport)
void ZeroingAndMlock(const string& transport)
{
ProgOptions config;
config.SetProperty<string>("session", tools::Uuid());
test::Configure(config);
config.SetProperty<size_t>("shm-segment-size", 16384); // NOLINT
config.SetProperty<bool>("shm-zero-segment", true);
config.SetProperty<bool>("shm-mlock-segment", true);
config.SetProperty<bool>("shm-monitor", true);
auto factory = TransportFactory::CreateTransportFactory(transport, tools::Uuid(), &config);
@@ -88,14 +86,11 @@ void ZeroingAndMlock(const string& transport)
void ZeroingAndMlockOnCreation(const string& transport)
{
size_t session{tools::UuidHash()};
ProgOptions config;
config.SetProperty<string>("session", to_string(session));
test::Configure(config);
config.SetProperty<size_t>("shm-segment-size", 16384); // NOLINT
config.SetProperty<bool>("shm-mlock-segment-on-creation", true);
config.SetProperty<bool>("shm-zero-segment-on-creation", true);
config.SetProperty<bool>("shm-monitor", true);
auto factory = TransportFactory::CreateTransportFactory(transport, tools::Uuid(), &config);

View File

@@ -11,6 +11,7 @@
#include <fairmq/tools/Unique.h>
#include <fairmq/TransportFactory.h>
#include <helper/Transport.h>
#include <gtest/gtest.h>
#include <string>
@@ -24,10 +25,7 @@ using namespace fair::mq;
void GetFreeMemory()
{
ProgOptions config;
string sessionId(to_string(tools::UuidHash()));
config.SetProperty<string>("session", sessionId);
config.SetProperty<bool>("shm-monitor", true);
config.SetProperty<size_t>("shm-segment-size", 100000000);
string const sessionId(test::Configure(config));
ASSERT_THROW(shmem::Monitor::GetFreeMemory(shmem::SessionId{sessionId}, 0), shmem::Monitor::MonitorError);

View File

@@ -17,6 +17,7 @@
#include <fairlogger/Logger.h>
#include <helper/Transport.h>
#include <gtest/gtest.h>
#include <chrono>
@@ -74,9 +75,7 @@ void InterruptTransfer(const string& transport, const string& _address)
std::string address(ToString(_address, "_", transport));
fair::mq::ProgOptions config;
config.SetProperty<string>("session", to_string(session));
config.SetProperty<size_t>("shm-segment-size", 100000000);
config.SetProperty<bool>("shm-monitor", true);
test::Configure(config, to_string(session));
auto factory = TransportFactory::CreateTransportFactory(transport, Uuid(), &config);