FairMQ: Add uuid generator to tools & let tests use it for session names.

This commit is contained in:
Alexey Rybalchenko
2017-11-28 17:25:39 +01:00
committed by Mohammad Al-Turany
parent 85aab51bd4
commit 0dc4000187
14 changed files with 218 additions and 67 deletions

View File

@@ -7,6 +7,7 @@
********************************************************************************/
#include "runner.h"
#include <fairmq/Tools.h>
#include <gtest/gtest.h>
#include <sstream> // std::stringstream
#include <thread>
@@ -19,13 +20,15 @@ using namespace fair::mq::test;
auto RunPoller(string transport, int pollType) -> void
{
size_t session{fair::mq::tools::UuidHash()};
auto pollout = execute_result{"", 0};
thread poll_out_thread([&]() {
stringstream cmd;
cmd << runTestDevice
<< " --id pollout_"<< transport
<< " --control static --verbosity DEBUG --log-color false"
<< " --mq-config \"" << mqConfig << "\"";
<< " --session " << session << " --mq-config \"" << mqConfig << "\"";
pollout = execute(cmd.str(), "[POLLOUT]");
});
@@ -35,7 +38,7 @@ auto RunPoller(string transport, int pollType) -> void
cmd << runTestDevice
<< " --id pollin_" << transport
<< " --control static --verbosity DEBUG --log-color false"
<< " --mq-config \"" << mqConfig << "\" --poll-type " << pollType;
<< " --session " << session << " --mq-config \"" << mqConfig << "\" --poll-type " << pollType;
pollin = execute(cmd.str(), "[POLLIN]");
});

View File

@@ -7,6 +7,7 @@
********************************************************************************/
#include "runner.h"
#include <fairmq/Tools.h>
#include <gtest/gtest.h>
#include <sstream> // std::stringstream
#include <thread>
@@ -19,11 +20,13 @@ using namespace fair::mq::test;
auto RunPubSub(string transport) -> void
{
size_t session{fair::mq::tools::UuidHash()};
auto pub = execute_result{"", 0};
thread pub_thread([&]() {
stringstream cmd;
cmd << runTestDevice << " --id pub_" << transport << " --control static --verbosity DEBUG "
<< "--log-color false --mq-config \"" << mqConfig << "\"";
<< "--session " << session << " --log-color false --mq-config \"" << mqConfig << "\"";
pub = execute(cmd.str(), "[PUB]");
});
@@ -31,7 +34,7 @@ auto RunPubSub(string transport) -> void
thread sub1_thread([&]() {
stringstream cmd;
cmd << runTestDevice << " --id sub_1" << transport << " --control static --verbosity DEBUG "
<< "--log-color false --mq-config \"" << mqConfig << "\"";
<< "--session " << session << " --log-color false --mq-config \"" << mqConfig << "\"";
sub1 = execute(cmd.str(), "[SUB1]");
});
@@ -39,7 +42,7 @@ auto RunPubSub(string transport) -> void
thread sub2_thread([&]() {
stringstream cmd;
cmd << runTestDevice << " --id sub_2" << transport << " --control static --verbosity DEBUG "
<< "--log-color false --mq-config \"" << mqConfig << "\"";
<< "--session " << session << " --log-color false --mq-config \"" << mqConfig << "\"";
sub2 = execute(cmd.str(), "[SUB2]");
});

View File

@@ -7,6 +7,7 @@
********************************************************************************/
#include "runner.h"
#include <fairmq/Tools.h>
#include <gtest/gtest.h>
#include <sstream> // std::stringstream
#include <thread>
@@ -19,11 +20,13 @@ using namespace fair::mq::test;
auto RunPushPull(string transport) -> void
{
size_t session{fair::mq::tools::UuidHash()};
auto push = execute_result{"", 100};
thread push_thread([&]() {
stringstream cmd;
cmd << runTestDevice << " --id push_" << transport << " --control static --verbosity DEBUG "
<< "--log-color false --mq-config \"" << mqConfig << "\"";
<< "--session " << session << " --log-color false --mq-config \"" << mqConfig << "\"";
push = execute(cmd.str(), "[PUSH]");
});
@@ -31,7 +34,7 @@ auto RunPushPull(string transport) -> void
thread pull_thread([&]() {
stringstream cmd;
cmd << runTestDevice << " --id pull_" << transport << " --control static --verbosity DEBUG "
<< "--log-color false --mq-config \"" << mqConfig << "\"";
<< "--session " << session << " --log-color false --mq-config \"" << mqConfig << "\"";
pull = execute(cmd.str(), "[PULL]");
});

View File

@@ -11,6 +11,9 @@
#include <FairMQParts.h>
#include <FairMQLogger.h>
#include <FairMQTransportFactory.h>
#include <fairmq/Tools.h>
#include <options/FairMQProgOptions.h>
#include <algorithm>
#include <memory>
#include <sstream>
@@ -23,7 +26,14 @@ namespace
using namespace std;
auto RunSingleThreadedMultipart(string transport, string address) -> void {
auto factory = FairMQTransportFactory::CreateTransportFactory(transport);
size_t session{fair::mq::tools::UuidHash()};
FairMQProgOptions config;
config.SetValue<string>("session", std::to_string(session));
config.SetValue<int>("io-threads", 1);
config.SetValue<size_t>("shm-segment-size", 20000000);
auto factory = FairMQTransportFactory::CreateTransportFactory(transport, fair::mq::tools::Uuid(), &config);
auto push = FairMQChannel{"Push", "push", factory};
ASSERT_TRUE(push.Bind(address));
auto pull = FairMQChannel{"Pull", "pull", factory};
@@ -55,7 +65,13 @@ auto RunSingleThreadedMultipart(string transport, string address) -> void {
auto RunMultiThreadedMultipart(string transport, string address) -> void
{
auto factory = FairMQTransportFactory::CreateTransportFactory(transport);
size_t session{fair::mq::tools::UuidHash()};
FairMQProgOptions config;
config.SetValue<string>("session", std::to_string(session));
config.SetValue<int>("io-threads", 1);
config.SetValue<size_t>("shm-segment-size", 20000000);
auto factory = FairMQTransportFactory::CreateTransportFactory(transport, fair::mq::tools::Uuid(), &config);
auto push = FairMQChannel{"Push", "push", factory};
ASSERT_TRUE(push.Bind(address));
auto pull = FairMQChannel{"Pull", "pull", factory};

View File

@@ -7,6 +7,7 @@
********************************************************************************/
#include "runner.h"
#include <fairmq/Tools.h>
#include <gtest/gtest.h>
#include <sstream> // std::stringstream
#include <thread>
@@ -19,11 +20,13 @@ using namespace fair::mq::test;
auto RunReqRep(string transport) -> void
{
size_t session{fair::mq::tools::UuidHash()};
auto rep = execute_result{ "", 0 };
thread rep_thread([&]() {
stringstream cmd;
cmd << runTestDevice << " --id rep_" << transport << " --control static --verbosity DEBUG "
<< "--log-color false --mq-config \"" << mqConfig << "\"";
<< "--session " << session << " --log-color false --mq-config \"" << mqConfig << "\"";
rep = execute(cmd.str(), "[REP]");
});
@@ -31,7 +34,7 @@ auto RunReqRep(string transport) -> void
thread req1_thread([&]() {
stringstream cmd;
cmd << runTestDevice << " --id req_1" << transport << " --control static --verbosity DEBUG "
<< "--log-color false --mq-config \"" << mqConfig << "\"";
<< "--session " << session << " --log-color false --mq-config \"" << mqConfig << "\"";
req1 = execute(cmd.str(), "[REQ1]");
});
@@ -39,7 +42,7 @@ auto RunReqRep(string transport) -> void
thread req2_thread([&]() {
stringstream cmd;
cmd << runTestDevice << " --id req_2" << transport << " --control static --verbosity DEBUG "
<< "--log-color false --mq-config \"" << mqConfig << "\"";
<< "--session " << session << " --log-color false --mq-config \"" << mqConfig << "\"";
req2 = execute(cmd.str(), "[REQ2]");
});

View File

@@ -7,6 +7,7 @@
********************************************************************************/
#include "runner.h"
#include <fairmq/Tools.h>
#include <gtest/gtest.h>
#include <sstream> // std::stringstream
@@ -18,9 +19,10 @@ using namespace fair::mq::test;
auto RunTransferTimeout(string transport) -> void
{
size_t session{fair::mq::tools::UuidHash()};
stringstream cmd;
cmd << runTestDevice << " --id transfer_timeout_" << transport << " --control static --verbosity DEBUG "
<< "--log-color false --mq-config \"" << mqConfig << "\"";
<< "--session " << session << " --log-color false --mq-config \"" << mqConfig << "\"";
auto res = execute(cmd.str());
cerr << res.error_out;