Add tests for poller.

This commit is contained in:
Alexey Rybalchenko
2017-05-19 09:41:45 +02:00
committed by Mohammad Al-Turany
parent 6b221d950c
commit 9288a2c3d5
6 changed files with 399 additions and 0 deletions

View File

@@ -0,0 +1,83 @@
/********************************************************************************
* Copyright (C) 2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence (LGPL) version 3, *
* copied verbatim in the file "LICENSE" *
********************************************************************************/
#include "runner.h"
#include <gtest/gtest.h>
#include <sstream> // std::stringstream
#include <thread>
namespace
{
using namespace std;
using namespace fair::mq::test;
auto RunPoller(string transport, int pollType) -> void
{
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 << "\"";
pollout = execute(cmd.str(), "[POLLOUT]");
});
auto pollin = execute_result{"", 0};
thread poll_in_thread([&]() {
stringstream cmd;
cmd << runTestDevice
<< " --id pollin_" << transport
<< " --control static --verbosity DEBUG --log-color false"
<< " --mq-config \"" << mqConfig << "\" --poll-type " << pollType;
pollin = execute(cmd.str(), "[POLLIN]");
});
poll_out_thread.join();
poll_in_thread.join();
cerr << pollout.error_out << pollin.error_out;
exit(pollout.exit_code + pollin.exit_code);
}
TEST(Poller, ZeroMQ_subchannel)
{
EXPECT_EXIT(RunPoller("zeromq", 0), ::testing::ExitedWithCode(0), "POLL test successfull");
}
#ifdef NANOMSG_FOUND
TEST(Poller, Nanomsg_subchannel)
{
EXPECT_EXIT(RunPoller("nanomsg", 0), ::testing::ExitedWithCode(0), "POLL test successfull");
}
#endif /* NANOMSG_FOUND */
TEST(Poller, ShMem_subchannel)
{
EXPECT_EXIT(RunPoller("shmem", 0), ::testing::ExitedWithCode(0), "POLL test successfull");
}
TEST(Poller, ZeroMQ_channel)
{
EXPECT_EXIT(RunPoller("zeromq", 1), ::testing::ExitedWithCode(0), "POLL test successfull");
}
#ifdef NANOMSG_FOUND
TEST(Poller, Nanomsg_channel)
{
EXPECT_EXIT(RunPoller("nanomsg", 1), ::testing::ExitedWithCode(0), "POLL test successfull");
}
#endif /* NANOMSG_FOUND */
TEST(Poller, ShMem_channel)
{
EXPECT_EXIT(RunPoller("shmem", 1), ::testing::ExitedWithCode(0), "POLL test successfull");
}
} // namespace

View File

@@ -384,6 +384,132 @@
"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_nanomsg",
"channels": [
{
"address": "tcp://127.0.0.1:6002",
"method": "bind",
"name": "data1",
"rateLogging": 0,
"transport": "nanomsg",
"type": "push"
},
{
"address": "tcp://127.0.0.1:6003",
"method": "bind",
"name": "data2",
"rateLogging": 0,
"transport": "nanomsg",
"type": "push"
}
]
},
{
"id": "pollin_nanomsg",
"channels": [
{
"address": "tcp://127.0.0.1:6002",
"method": "connect",
"name": "data1",
"rateLogging": 0,
"transport": "nanomsg",
"type": "pull"
},
{
"address": "tcp://127.0.0.1:6003",
"method": "connect",
"name": "data2",
"rateLogging": 0,
"transport": "nanomsg",
"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"
}
]
}
]
}