Avoid fixed ports in the test suites

This commit is contained in:
Alexey Rybalchenko
2022-01-23 18:44:59 +01:00
committed by Dennis Klein
parent bfd08bb33f
commit f4d39d224b
22 changed files with 347 additions and 532 deletions

View File

@@ -9,7 +9,9 @@
#include "runner.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>
@@ -23,20 +25,37 @@ using namespace fair::mq::tools;
auto RunPair(string transport) -> void
{
size_t session{fair::mq::tools::UuidHash()};
string ipcFile("/tmp/fmq_" + to_string(session) + "_data_" + transport);
string address("ipc://" + ipcFile);
// ofi does not run with ipc://
if (transport == "ofi") {
address = "tcp://127.0.0.1:5957";
}
auto pairleft = execute_result{"", 100};
thread pairleft_thread([&]() {
stringstream cmd;
cmd << runTestDevice << " --id pairleft_" << transport << " --control static "
<< "--session " << session << " --color false --mq-config \"" << mqConfig << "\"";
cmd << runTestDevice
<< " --id pairleft_" << transport
<< " --control static"
<< " --shm-segment-size 100000000"
<< " --session " << session
<< " --color false"
<< " --channel-config name=data,type=pair,method=bind,address=" << address;
pairleft = execute(cmd.str(), "[PAIR L]");
});
auto pairright = execute_result{"", 100};
thread pairright_thread([&]() {
stringstream cmd;
cmd << runTestDevice << " --id pairright_" << transport << " --control static "
<< "--session " << session << " --color false --mq-config \"" << mqConfig << "\"";
cmd << runTestDevice
<< " --id pairright_" << transport
<< " --control static"
<< " --shm-segment-size 100000000"
<< " --session " << session
<< " --color false"
<< " --channel-config name=data,type=pair,method=connect,address=" << address;
pairright = execute(cmd.str(), "[PAIR R]");
});
@@ -44,6 +63,8 @@ auto RunPair(string transport) -> void
pairright_thread.join();
cerr << pairleft.console_out << pairright.console_out;
std::remove(ipcFile.c_str());
exit(pairleft.exit_code + pairright.exit_code);
}

View File

@@ -7,9 +7,14 @@
********************************************************************************/
#include "runner.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>
@@ -23,28 +28,47 @@ using namespace fair::mq::tools;
auto RunPubSub(string transport) -> void
{
size_t session{fair::mq::tools::UuidHash()};
string dataIpcFile("/tmp/fmq_" + to_string(session) + "_data_" + transport);
string ctrlIpcFile("/tmp/fmq_" + to_string(session) + "_ctrl_" + transport);
string dataAddress("ipc://" + dataIpcFile);
string ctrlAddress("ipc://" + ctrlIpcFile);
auto pub = execute_result{"", 0};
thread pub_thread([&]() {
stringstream cmd;
cmd << runTestDevice << " --id pub_" << transport << " --control static "
<< "--session " << session << " --color false --mq-config \"" << mqConfig << "\"";
cmd << runTestDevice
<< " --id pub_" << transport
<< " --control static"
<< " --session " << session
<< " --color false"
<< " --channel-config name=data,type=pub,method=bind,address=" << dataAddress
<< " name=control,type=pull,method=bind,address=" << ctrlAddress;
pub = execute(cmd.str(), "[PUB]");
});
auto sub1 = execute_result{"", 0};
thread sub1_thread([&]() {
stringstream cmd;
cmd << runTestDevice << " --id sub_1" << transport << " --control static "
<< "--session " << session << " --color false --mq-config \"" << mqConfig << "\"";
cmd << runTestDevice
<< " --id sub_1" << transport
<< " --control static"
<< " --session " << session
<< " --color false"
<< " --channel-config name=data,type=sub,method=connect,address=" << dataAddress
<< " name=control,type=push,method=connect,address=" << ctrlAddress;
sub1 = execute(cmd.str(), "[SUB1]");
});
auto sub2 = execute_result{"", 0};
thread sub2_thread([&]() {
stringstream cmd;
cmd << runTestDevice << " --id sub_2" << transport << " --control static "
<< "--session " << session << " --color false --mq-config \"" << mqConfig << "\"";
cmd << runTestDevice
<< " --id sub_2" << transport
<< " --control static"
<< " --session " << session
<< " --color false"
<< " --channel-config name=data,type=sub,method=connect,address=" << dataAddress
<< " name=control,type=push,method=connect,address=" << ctrlAddress;
sub2 = execute(cmd.str(), "[SUB2]");
});
@@ -53,6 +77,9 @@ auto RunPubSub(string transport) -> void
sub2_thread.join();
cerr << pub.console_out << sub1.console_out << sub2.console_out << endl;
std::remove(dataIpcFile.c_str());
std::remove(ctrlIpcFile.c_str());
exit(pub.exit_code + sub1.exit_code + sub2.exit_code);
}

View File

@@ -9,7 +9,9 @@
#include "runner.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>
@@ -22,21 +24,33 @@ using namespace fair::mq::tools;
auto RunPushPull(string transport) -> void
{
size_t session{fair::mq::tools::UuidHash()};
size_t session(fair::mq::tools::UuidHash());
string ipcFile("/tmp/fmq_" + to_string(session) + "_data_" + transport);
string address("ipc://" + ipcFile);
auto push = execute_result{"", 100};
thread push_thread([&]() {
stringstream cmd;
cmd << runTestDevice << " --id push_" << transport << " --control static "
<< "--session " << session << " --color false --mq-config \"" << mqConfig << "\"";
cmd << runTestDevice
<< " --id push_" << transport
<< " --control static"
<< " --shm-segment-size 100000000"
<< " --session " << session
<< " --color false"
<< " --channel-config name=data,type=push,method=bind,address=" << address;
push = execute(cmd.str(), "[PUSH]");
});
auto pull = execute_result{"", 100};
thread pull_thread([&]() {
stringstream cmd;
cmd << runTestDevice << " --id pull_" << transport << " --control static "
<< "--session " << session << " --color false --mq-config \"" << mqConfig << "\"";
cmd << runTestDevice
<< " --id pull_" << transport
<< " --control static"
<< " --shm-segment-size 100000000"
<< " --session " << session
<< " --color false"
<< " --channel-config name=data,type=pull,method=connect,address=" << address;
pull = execute(cmd.str(), "[PULL]");
});
@@ -44,15 +58,17 @@ auto RunPushPull(string transport) -> void
pull_thread.join();
cerr << push.console_out << pull.console_out;
std::remove(ipcFile.c_str());
exit(push.exit_code + pull.exit_code);
}
TEST(PushPull, SingleMsg_MP_tcp_zeromq)
TEST(PushPull, SingleMsg_MP_ipc_zeromq)
{
EXPECT_EXIT(RunPushPull("zeromq"), ::testing::ExitedWithCode(0), "PUSH-PULL test successfull");
}
TEST(PushPull, SingleMsg_MP_tcp_shmem)
TEST(PushPull, SingleMsg_MP_ipc_shmem)
{
EXPECT_EXIT(RunPushPull("shmem"), ::testing::ExitedWithCode(0), "PUSH-PULL test successfull");
}

View File

@@ -29,6 +29,7 @@ auto RunSingleThreadedMultipart(string transport, string address1, string addres
fair::mq::ProgOptions config;
config.SetProperty<string>("session", tools::Uuid());
config.SetProperty<size_t>("shm-segment-size", 100000000);
auto factory = TransportFactory::CreateTransportFactory(transport, tools::Uuid(), &config);

View File

@@ -9,7 +9,9 @@
#include "runner.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>
@@ -23,37 +25,45 @@ using namespace fair::mq::tools;
auto RunReqRep(string transport) -> void
{
size_t session{fair::mq::tools::UuidHash()};
string ipcFile("/tmp/fmq_" + to_string(session) + "_data_" + transport);
string address("ipc://" + ipcFile);
auto rep = execute_result{"", 0};
thread rep_thread([&]() {
stringstream cmd;
cmd << runTestDevice << " --id rep_" << transport
cmd << runTestDevice
<< " --id rep_" << transport
<< " --control static"
<< " --shm-segment-size 100000000"
<< " --session " << session
<< " --color false"
<< " --mq-config \"" << mqConfig << "\"";
<< " --channel-config name=data,type=rep,method=bind,address=" << address;
rep = execute(cmd.str(), "[REP]");
});
auto req1 = execute_result{"", 0};
thread req1_thread([&]() {
stringstream cmd;
cmd << runTestDevice << " --id req_1" << transport
cmd << runTestDevice
<< " --id req_1" << transport
<< " --control static"
<< " --shm-segment-size 100000000"
<< " --session " << session
<< " --color false"
<< " --mq-config \"" << mqConfig << "\"";
<< " --channel-config name=data,type=req,method=connect,address=" << address;
req1 = execute(cmd.str(), "[REQ1]");
});
auto req2 = execute_result{"", 0};
thread req2_thread([&]() {
stringstream cmd;
cmd << runTestDevice << " --id req_2" << transport
cmd << runTestDevice
<< " --id req_2" << transport
<< " --control static"
<< " --shm-segment-size 100000000"
<< " --session " << session
<< " --color false"
<< " --mq-config \"" << mqConfig << "\"";
<< " --channel-config name=data,type=req,method=connect,address=" << address;
req2 = execute(cmd.str(), "[REQ2]");
});
@@ -62,6 +72,8 @@ auto RunReqRep(string transport) -> void
req2_thread.join();
cerr << req1.console_out << req2.console_out << rep.console_out;
std::remove(ipcFile.c_str());
exit(req1.exit_code + req2.exit_code + rep.exit_code);
}

View File

@@ -1,403 +0,0 @@
{
"fairMQOptions": {
"devices": [
{
"id": "pairleft_zeromq",
"channels": [
{
"address": "tcp://127.0.0.1:5557",
"method": "bind",
"name": "data",
"rateLogging": 0,
"transport": "zeromq",
"type": "pair"
}
]
},
{
"id": "pairright_zeromq",
"channels": [
{
"address": "tcp://127.0.0.1:5557",
"method": "connect",
"name": "data",
"rateLogging": 0,
"transport": "zeromq",
"type": "pair"
}
]
},
{
"id": "pairleft_shmem",
"channels": [
{
"address": "tcp://127.0.0.1:5857",
"method": "bind",
"name": "data",
"rateLogging": 0,
"transport": "shmem",
"type": "pair"
}
]
},
{
"id": "pairright_shmem",
"channels": [
{
"address": "tcp://127.0.0.1:5857",
"method": "connect",
"name": "data",
"rateLogging": 0,
"transport": "shmem",
"type": "pair"
}
]
},
{
"id": "pairleft_ofi",
"channels": [
{
"address": "tcp://127.0.0.1:5957",
"method": "bind",
"name": "data",
"rateLogging": 0,
"transport": "ofi",
"type": "pair"
}
]
},
{
"id": "pairright_ofi",
"channels": [
{
"address": "tcp://127.0.0.1:5957",
"method": "connect",
"name": "data",
"rateLogging": 0,
"transport": "ofi",
"type": "pair"
}
]
},
{
"id": "push_zeromq",
"channels": [
{
"address": "tcp://127.0.0.1:5557",
"method": "bind",
"name": "data",
"rateLogging": 0,
"transport": "zeromq",
"type": "push"
}
]
},
{
"id": "pull_zeromq",
"channels": [
{
"address": "tcp://127.0.0.1:5557",
"method": "connect",
"name": "data",
"rateLogging": 0,
"transport": "zeromq",
"type": "pull"
}
]
},
{
"id": "push_shmem",
"channels": [
{
"address": "tcp://127.0.0.1:5857",
"method": "bind",
"name": "data",
"rateLogging": 0,
"transport": "shmem",
"type": "push"
}
]
},
{
"id": "pull_shmem",
"channels": [
{
"address": "tcp://127.0.0.1:5857",
"method": "connect",
"name": "data",
"rateLogging": 0,
"transport": "shmem",
"type": "pull"
}
]
},
{
"id": "pub_zeromq",
"channels": [
{
"address": "tcp://127.0.0.1:5556",
"method": "bind",
"name": "data",
"rateLogging": 0,
"transport": "zeromq",
"type": "pub"
},
{
"address": "tcp://127.0.0.1:5555",
"method": "bind",
"name": "control",
"rateLogging": 0,
"transport": "zeromq",
"type": "pull"
}
]
},
{
"id": "sub_1zeromq",
"channels": [
{
"address": "tcp://127.0.0.1:5556",
"method": "connect",
"name": "data",
"rateLogging": 0,
"transport": "zeromq",
"type": "sub"
},
{
"address": "tcp://127.0.0.1:5555",
"method": "connect",
"name": "control",
"rateLogging": 0,
"transport": "zeromq",
"type": "push"
}
]
},
{
"id": "sub_2zeromq",
"channels": [
{
"address": "tcp://127.0.0.1:5556",
"method": "connect",
"name": "data",
"rateLogging": 0,
"transport": "zeromq",
"type": "sub"
},
{
"address": "tcp://127.0.0.1:5555",
"method": "connect",
"name": "control",
"rateLogging": 0,
"transport": "zeromq",
"type": "push"
}
]
},
{
"id": "req_1zeromq",
"channels": [
{
"address": "tcp://127.0.0.1:5558",
"method": "connect",
"name": "data",
"rateLogging": 0,
"transport": "zeromq",
"type": "req"
}
]
},
{
"id": "req_2zeromq",
"channels": [
{
"address": "tcp://127.0.0.1:5558",
"method": "connect",
"name": "data",
"rateLogging": 0,
"transport": "zeromq",
"type": "req"
}
]
},
{
"id": "req_1shmem",
"channels": [
{
"address": "tcp://127.0.0.1:5758",
"method": "connect",
"name": "data",
"rateLogging": 0,
"transport": "shmem",
"type": "req"
}
]
},
{
"id": "req_2shmem",
"channels": [
{
"address": "tcp://127.0.0.1:5758",
"method": "connect",
"name": "data",
"rateLogging": 0,
"transport": "shmem",
"type": "req"
}
]
},
{
"id": "rep_zeromq",
"channels": [
{
"address": "tcp://127.0.0.1:5558",
"method": "bind",
"name": "data",
"rateLogging": 0,
"transport": "zeromq",
"type": "rep"
}
]
},
{
"id": "rep_shmem",
"channels": [
{
"address": "tcp://127.0.0.1:5758",
"method": "bind",
"name": "data",
"rateLogging": 0,
"transport": "shmem",
"type": "rep"
}
]
},
{
"id": "transfer_timeout_zeromq",
"channels": [
{
"address": "tcp://127.0.0.1:5559",
"method": "bind",
"name": "data-in",
"rateLogging": 0,
"transport": "zeromq",
"type": "pull"
},
{
"address": "tcp://127.0.0.1:5560",
"method": "bind",
"name": "data-out",
"rateLogging": 0,
"transport": "zeromq",
"type": "push"
}
]
},
{
"id": "transfer_timeout_shmem",
"channels": [
{
"address": "tcp://127.0.0.1:5959",
"method": "bind",
"name": "data-in",
"rateLogging": 0,
"transport": "shmem",
"type": "pull"
},
{
"address": "tcp://127.0.0.1:5960",
"method": "bind",
"name": "data-out",
"rateLogging": 0,
"transport": "shmem",
"type": "push"
}
]
},
{
"id": "pollout_zeromq",
"channels": [
{
"address": "tcp://127.0.0.1:6000",
"method": "bind",
"name": "data1",
"rateLogging": 0,
"transport": "zeromq",
"type": "push"
},
{
"address": "tcp://127.0.0.1:6001",
"method": "bind",
"name": "data2",
"rateLogging": 0,
"transport": "zeromq",
"type": "push"
}
]
},
{
"id": "pollin_zeromq",
"channels": [
{
"address": "tcp://127.0.0.1:6000",
"method": "connect",
"name": "data1",
"rateLogging": 0,
"transport": "zeromq",
"type": "pull"
},
{
"address": "tcp://127.0.0.1:6001",
"method": "connect",
"name": "data2",
"rateLogging": 0,
"transport": "zeromq",
"type": "pull"
}
]
},
{
"id": "pollout_shmem",
"channels": [
{
"address": "tcp://127.0.0.1:6004",
"method": "bind",
"name": "data1",
"rateLogging": 0,
"transport": "shmem",
"type": "push"
},
{
"address": "tcp://127.0.0.1:6005",
"method": "bind",
"name": "data2",
"rateLogging": 0,
"transport": "shmem",
"type": "push"
}
]
},
{
"id": "pollin_shmem",
"channels": [
{
"address": "tcp://127.0.0.1:6004",
"method": "connect",
"name": "data1",
"rateLogging": 0,
"transport": "shmem",
"type": "pull"
},
{
"address": "tcp://127.0.0.1:6005",
"method": "connect",
"name": "data2",
"rateLogging": 0,
"transport": "shmem",
"type": "pull"
}
]
}
]
}
}