mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2026-11-25 13:11:36 +00:00
test: run multi-process tests with one harness
- Add test::RunDevices(): starts the devices with the same session, transport, shm options and channel config, with a deadline per run - Add the TestDevice base: Check() fails the device, Succeed() prints a marker with the transport name that the harness verifies - Make the protocol, poller and transfer-timeout devices check their own results and drop the InitTask() sleeps - Replace EXPECT_EXIT() and the copied launch code in the protocol, poller and transfer-timeout tests - A device that uses the wrong transport now fails the test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,92 +6,55 @@
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#include "runner.h"
|
||||
#include <helper/Devices.h>
|
||||
#include <helper/Transport.h>
|
||||
|
||||
#include <fairmq/tools/Unique.h>
|
||||
#include <fairmq/tools/Process.h>
|
||||
#include <fairmq/tools/Strings.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <cstdio> // std::remove
|
||||
#include <sstream> // std::stringstream
|
||||
#include <thread>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
using namespace fair::mq::test;
|
||||
using namespace fair::mq::tools;
|
||||
|
||||
auto RunPoller(string transport, int pollType) -> void
|
||||
auto RunPoller(string const& transport, int pollType) -> void
|
||||
{
|
||||
size_t session{UuidHash()};
|
||||
string data1IpcFile("/tmp/fmq_" + to_string(session) + "_data1_" + transport);
|
||||
string data2IpcFile("/tmp/fmq_" + to_string(session) + "_data2_" + transport);
|
||||
string data1Address("ipc://" + data1IpcFile);
|
||||
string data2Address("ipc://" + data2IpcFile);
|
||||
IpcAddress const data1("poller_data1");
|
||||
IpcAddress const data2("poller_data2");
|
||||
|
||||
auto pollout = execute_result{"", 0};
|
||||
thread poll_out_thread([&]() {
|
||||
stringstream cmd;
|
||||
cmd << runTestDevice
|
||||
<< " --id pollout_"<< transport
|
||||
<< " --control static"
|
||||
<< " --transport " << transport
|
||||
<< " --color false"
|
||||
<< " --shm-monitor true"
|
||||
<< " --shm-segment-size 100000000"
|
||||
<< " --session " << session
|
||||
<< " --channel-config name=data1,type=push,method=bind,address=" << data1Address
|
||||
<< " name=data2,type=push,method=bind,address=" << data2Address;
|
||||
pollout = execute(cmd.str(), "[POLLOUT]");
|
||||
});
|
||||
auto const results = RunDevices({
|
||||
{"pollout_" + transport, "name=data1,type=push,method=bind,address=" + data1.str()
|
||||
+ " name=data2,type=push,method=bind,address=" + data2.str()},
|
||||
{"pollin_" + transport, "name=data1,type=pull,method=connect,address=" + data1.str()
|
||||
+ " name=data2,type=pull,method=connect,address=" + data2.str(),
|
||||
"--poll-type " + to_string(pollType)},
|
||||
}, RunOptions(transport));
|
||||
|
||||
auto pollin = execute_result{"", 0};
|
||||
thread poll_in_thread([&]() {
|
||||
stringstream cmd;
|
||||
cmd << runTestDevice
|
||||
<< " --id pollin_" << transport
|
||||
<< " --control static"
|
||||
<< " --transport " << transport
|
||||
<< " --color false"
|
||||
<< " --shm-monitor true"
|
||||
<< " --shm-segment-size 100000000"
|
||||
<< " --session " << session
|
||||
<< " --poll-type " << pollType
|
||||
<< " --channel-config name=data1,type=pull,method=connect,address=" << data1Address
|
||||
<< " name=data2,type=pull,method=connect,address=" << data2Address;
|
||||
pollin = execute(cmd.str(), "[POLLIN]");
|
||||
});
|
||||
|
||||
poll_out_thread.join();
|
||||
poll_in_thread.join();
|
||||
cerr << pollout.console_out << pollin.console_out;
|
||||
|
||||
std::remove(data1IpcFile.c_str());
|
||||
std::remove(data2IpcFile.c_str());
|
||||
|
||||
exit(pollout.exit_code + pollin.exit_code);
|
||||
for (auto const& result : results) {
|
||||
EXPECT_TRUE(Succeeded(result, transport));
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Subchannel, zeromq)
|
||||
{
|
||||
EXPECT_EXIT(RunPoller("zeromq", 0), ::testing::ExitedWithCode(0), "POLL test successfull");
|
||||
RunPoller("zeromq", 0);
|
||||
}
|
||||
|
||||
TEST(Subchannel, shmem)
|
||||
{
|
||||
EXPECT_EXIT(RunPoller("shmem", 0), ::testing::ExitedWithCode(0), "POLL test successfull");
|
||||
RunPoller("shmem", 0);
|
||||
}
|
||||
|
||||
TEST(Channel, zeromq)
|
||||
{
|
||||
EXPECT_EXIT(RunPoller("zeromq", 1), ::testing::ExitedWithCode(0), "POLL test successfull");
|
||||
RunPoller("zeromq", 1);
|
||||
}
|
||||
|
||||
TEST(Channel, shmem)
|
||||
{
|
||||
EXPECT_EXIT(RunPoller("shmem", 1), ::testing::ExitedWithCode(0), "POLL test successfull");
|
||||
RunPoller("shmem", 1);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user