mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-16 01:51:45 +00:00
Add FairMQ tests (PUB-SUB, PUSH-PULL, REQ-REP).
This commit is contained in:
committed by
Mohammad Al-Turany
parent
fbf7dbf2ba
commit
f13bb5995d
47
fairmq/test/pub-sub/FairMQTestPub.cxx
Normal file
47
fairmq/test/pub-sub/FairMQTestPub.cxx
Normal file
@@ -0,0 +1,47 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQTestPub.cpp
|
||||
*
|
||||
* @since 2015-09-05
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#include <memory> // unique_ptr
|
||||
|
||||
#include "FairMQTestPub.h"
|
||||
#include "FairMQLogger.h"
|
||||
|
||||
FairMQTestPub::FairMQTestPub()
|
||||
{
|
||||
}
|
||||
|
||||
void FairMQTestPub::Run()
|
||||
{
|
||||
std::unique_ptr<FairMQMessage> ready1Msg(fTransportFactory->CreateMessage());
|
||||
fChannels.at("control").at(0).Receive(ready1Msg);
|
||||
std::unique_ptr<FairMQMessage> ready2Msg(fTransportFactory->CreateMessage());
|
||||
fChannels.at("control").at(0).Receive(ready2Msg);
|
||||
|
||||
std::unique_ptr<FairMQMessage> msg(fTransportFactory->CreateMessage());
|
||||
fChannels.at("data").at(0).Send(msg);
|
||||
|
||||
std::unique_ptr<FairMQMessage> ack1Msg(fTransportFactory->CreateMessage());
|
||||
std::unique_ptr<FairMQMessage> ack2Msg(fTransportFactory->CreateMessage());
|
||||
if (fChannels.at("control").at(0).Receive(ack1Msg) >= 0)
|
||||
{
|
||||
if (fChannels.at("control").at(0).Receive(ack2Msg) >= 0)
|
||||
{
|
||||
LOG(INFO) << "PUB-SUB test successfull";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FairMQTestPub::~FairMQTestPub()
|
||||
{
|
||||
}
|
30
fairmq/test/pub-sub/FairMQTestPub.h
Normal file
30
fairmq/test/pub-sub/FairMQTestPub.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQTestPub.h
|
||||
*
|
||||
* @since 2015-09-05
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#ifndef FAIRMQTESTPUB_H_
|
||||
#define FAIRMQTESTPUB_H_
|
||||
|
||||
#include "FairMQDevice.h"
|
||||
|
||||
class FairMQTestPub : public FairMQDevice
|
||||
{
|
||||
public:
|
||||
FairMQTestPub();
|
||||
virtual ~FairMQTestPub();
|
||||
|
||||
protected:
|
||||
virtual void Run();
|
||||
};
|
||||
|
||||
#endif /* FAIRMQTESTPUB_H_ */
|
43
fairmq/test/pub-sub/FairMQTestSub.cxx
Normal file
43
fairmq/test/pub-sub/FairMQTestSub.cxx
Normal file
@@ -0,0 +1,43 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQTestSub.cxx
|
||||
*
|
||||
* @since 2015-09-05
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#include <memory> // unique_ptr
|
||||
|
||||
#include "FairMQTestSub.h"
|
||||
#include "FairMQLogger.h"
|
||||
|
||||
FairMQTestSub::FairMQTestSub()
|
||||
{
|
||||
}
|
||||
|
||||
void FairMQTestSub::Run()
|
||||
{
|
||||
std::unique_ptr<FairMQMessage> readyMsg(fTransportFactory->CreateMessage());
|
||||
fChannels.at("control").at(0).Send(readyMsg);
|
||||
|
||||
std::unique_ptr<FairMQMessage> msg(fTransportFactory->CreateMessage());
|
||||
if (fChannels.at("data").at(0).Receive(msg) >= 0)
|
||||
{
|
||||
std::unique_ptr<FairMQMessage> ackMsg(fTransportFactory->CreateMessage());
|
||||
fChannels.at("control").at(0).Send(ackMsg);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(ERROR) << "Test failed: size of the received message doesn't match. Expected: 0, Received: " << msg->GetSize();
|
||||
}
|
||||
}
|
||||
|
||||
FairMQTestSub::~FairMQTestSub()
|
||||
{
|
||||
}
|
30
fairmq/test/pub-sub/FairMQTestSub.h
Normal file
30
fairmq/test/pub-sub/FairMQTestSub.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQTestSub.h
|
||||
*
|
||||
* @since 2015-09-05
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#ifndef FAIRMQTESTSUB_H_
|
||||
#define FAIRMQTESTSUB_H_
|
||||
|
||||
#include "FairMQDevice.h"
|
||||
|
||||
class FairMQTestSub : public FairMQDevice
|
||||
{
|
||||
public:
|
||||
FairMQTestSub();
|
||||
virtual ~FairMQTestSub();
|
||||
|
||||
protected:
|
||||
virtual void Run();
|
||||
};
|
||||
|
||||
#endif /* FAIRMQTESTSUB_H_ */
|
65
fairmq/test/pub-sub/runTestPub.cxx
Normal file
65
fairmq/test/pub-sub/runTestPub.cxx
Normal file
@@ -0,0 +1,65 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* runTestPub.cxx
|
||||
*
|
||||
* @since 2015-09-05
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "FairMQLogger.h"
|
||||
#include "FairMQTestPub.h"
|
||||
|
||||
#ifdef NANOMSG
|
||||
#include "FairMQTransportFactoryNN.h"
|
||||
#else
|
||||
#include "FairMQTransportFactoryZMQ.h"
|
||||
#endif
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
FairMQTestPub testPub;
|
||||
testPub.CatchSignals();
|
||||
|
||||
#ifdef NANOMSG
|
||||
testPub.SetTransport(new FairMQTransportFactoryNN());
|
||||
#else
|
||||
testPub.SetTransport(new FairMQTransportFactoryZMQ());
|
||||
#endif
|
||||
|
||||
testPub.SetProperty(FairMQTestPub::Id, "testPub");
|
||||
|
||||
FairMQChannel controlChannel("pull", "bind", "tcp://127.0.0.1:5555");
|
||||
controlChannel.UpdateRateLogging(0);
|
||||
testPub.fChannels["control"].push_back(controlChannel);
|
||||
|
||||
FairMQChannel pubChannel("pub", "bind", "tcp://127.0.0.1:5556");
|
||||
pubChannel.UpdateRateLogging(0);
|
||||
testPub.fChannels["data"].push_back(pubChannel);
|
||||
|
||||
testPub.ChangeState("INIT_DEVICE");
|
||||
testPub.WaitForEndOfState("INIT_DEVICE");
|
||||
|
||||
testPub.ChangeState("INIT_TASK");
|
||||
testPub.WaitForEndOfState("INIT_TASK");
|
||||
|
||||
testPub.ChangeState("RUN");
|
||||
testPub.WaitForEndOfState("RUN");
|
||||
|
||||
testPub.ChangeState("RESET_TASK");
|
||||
testPub.WaitForEndOfState("RESET_TASK");
|
||||
|
||||
testPub.ChangeState("RESET_DEVICE");
|
||||
testPub.WaitForEndOfState("RESET_DEVICE");
|
||||
|
||||
testPub.ChangeState("END");
|
||||
|
||||
return 0;
|
||||
}
|
65
fairmq/test/pub-sub/runTestSub.cxx
Normal file
65
fairmq/test/pub-sub/runTestSub.cxx
Normal file
@@ -0,0 +1,65 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* runTestSub.cxx
|
||||
*
|
||||
* @since 2015-09-05
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "FairMQLogger.h"
|
||||
#include "FairMQTestSub.h"
|
||||
|
||||
#ifdef NANOMSG
|
||||
#include "FairMQTransportFactoryNN.h"
|
||||
#else
|
||||
#include "FairMQTransportFactoryZMQ.h"
|
||||
#endif
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
FairMQTestSub testSub;
|
||||
testSub.CatchSignals();
|
||||
|
||||
#ifdef NANOMSG
|
||||
testSub.SetTransport(new FairMQTransportFactoryNN());
|
||||
#else
|
||||
testSub.SetTransport(new FairMQTransportFactoryZMQ());
|
||||
#endif
|
||||
|
||||
testSub.SetProperty(FairMQTestSub::Id, "testSub_" + std::to_string(getpid()));
|
||||
|
||||
FairMQChannel controlChannel("push", "connect", "tcp://127.0.0.1:5555");
|
||||
controlChannel.UpdateRateLogging(0);
|
||||
testSub.fChannels["control"].push_back(controlChannel);
|
||||
|
||||
FairMQChannel subChannel("sub", "connect", "tcp://127.0.0.1:5556");
|
||||
subChannel.UpdateRateLogging(0);
|
||||
testSub.fChannels["data"].push_back(subChannel);
|
||||
|
||||
testSub.ChangeState("INIT_DEVICE");
|
||||
testSub.WaitForEndOfState("INIT_DEVICE");
|
||||
|
||||
testSub.ChangeState("INIT_TASK");
|
||||
testSub.WaitForEndOfState("INIT_TASK");
|
||||
|
||||
testSub.ChangeState("RUN");
|
||||
testSub.WaitForEndOfState("RUN");
|
||||
|
||||
testSub.ChangeState("RESET_TASK");
|
||||
testSub.WaitForEndOfState("RESET_TASK");
|
||||
|
||||
testSub.ChangeState("RESET_DEVICE");
|
||||
testSub.WaitForEndOfState("RESET_DEVICE");
|
||||
|
||||
testSub.ChangeState("END");
|
||||
|
||||
return 0;
|
||||
}
|
36
fairmq/test/push-pull/FairMQTestPull.cxx
Normal file
36
fairmq/test/push-pull/FairMQTestPull.cxx
Normal file
@@ -0,0 +1,36 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQTestPull.cxx
|
||||
*
|
||||
* @since 2015-09-05
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#include <memory> // unique_ptr
|
||||
|
||||
#include "FairMQTestPull.h"
|
||||
#include "FairMQLogger.h"
|
||||
|
||||
FairMQTestPull::FairMQTestPull()
|
||||
{
|
||||
}
|
||||
|
||||
void FairMQTestPull::Run()
|
||||
{
|
||||
std::unique_ptr<FairMQMessage> msg(fTransportFactory->CreateMessage());
|
||||
|
||||
if (fChannels.at("data").at(0).Receive(msg) >= 0)
|
||||
{
|
||||
LOG(INFO) << "PUSH-PULL test successfull";
|
||||
}
|
||||
}
|
||||
|
||||
FairMQTestPull::~FairMQTestPull()
|
||||
{
|
||||
}
|
30
fairmq/test/push-pull/FairMQTestPull.h
Normal file
30
fairmq/test/push-pull/FairMQTestPull.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQTestPull.h
|
||||
*
|
||||
* @since 2015-09-05
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#ifndef FAIRMQTESTPULL_H_
|
||||
#define FAIRMQTESTPULL_H_
|
||||
|
||||
#include "FairMQDevice.h"
|
||||
|
||||
class FairMQTestPull : public FairMQDevice
|
||||
{
|
||||
public:
|
||||
FairMQTestPull();
|
||||
virtual ~FairMQTestPull();
|
||||
|
||||
protected:
|
||||
virtual void Run();
|
||||
};
|
||||
|
||||
#endif /* FAIRMQTESTPULL_H_ */
|
32
fairmq/test/push-pull/FairMQTestPush.cxx
Normal file
32
fairmq/test/push-pull/FairMQTestPush.cxx
Normal file
@@ -0,0 +1,32 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQTestPush.cpp
|
||||
*
|
||||
* @since 2015-09-05
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#include <memory> // unique_ptr
|
||||
|
||||
#include "FairMQTestPush.h"
|
||||
#include "FairMQLogger.h"
|
||||
|
||||
FairMQTestPush::FairMQTestPush()
|
||||
{
|
||||
}
|
||||
|
||||
void FairMQTestPush::Run()
|
||||
{
|
||||
std::unique_ptr<FairMQMessage> msg(fTransportFactory->CreateMessage());
|
||||
fChannels.at("data").at(0).Send(msg);
|
||||
}
|
||||
|
||||
FairMQTestPush::~FairMQTestPush()
|
||||
{
|
||||
}
|
30
fairmq/test/push-pull/FairMQTestPush.h
Normal file
30
fairmq/test/push-pull/FairMQTestPush.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQTestPush.h
|
||||
*
|
||||
* @since 2015-09-05
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#ifndef FAIRMQTESTPUSH_H_
|
||||
#define FAIRMQTESTPUSH_H_
|
||||
|
||||
#include "FairMQDevice.h"
|
||||
|
||||
class FairMQTestPush : public FairMQDevice
|
||||
{
|
||||
public:
|
||||
FairMQTestPush();
|
||||
virtual ~FairMQTestPush();
|
||||
|
||||
protected:
|
||||
virtual void Run();
|
||||
};
|
||||
|
||||
#endif /* FAIRMQTESTPUSH_H_ */
|
58
fairmq/test/push-pull/runTestPull.cxx
Normal file
58
fairmq/test/push-pull/runTestPull.cxx
Normal file
@@ -0,0 +1,58 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* runTestPull.cxx
|
||||
*
|
||||
* @since 2015-09-05
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#include "FairMQLogger.h"
|
||||
#include "FairMQTestPull.h"
|
||||
|
||||
#ifdef NANOMSG
|
||||
#include "FairMQTransportFactoryNN.h"
|
||||
#else
|
||||
#include "FairMQTransportFactoryZMQ.h"
|
||||
#endif
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
FairMQTestPull testPull;
|
||||
testPull.CatchSignals();
|
||||
|
||||
#ifdef NANOMSG
|
||||
testPull.SetTransport(new FairMQTransportFactoryNN());
|
||||
#else
|
||||
testPull.SetTransport(new FairMQTransportFactoryZMQ());
|
||||
#endif
|
||||
|
||||
testPull.SetProperty(FairMQTestPull::Id, "testPull");
|
||||
|
||||
FairMQChannel pullChannel("pull", "connect", "tcp://127.0.0.1:5557");
|
||||
testPull.fChannels["data"].push_back(pullChannel);
|
||||
|
||||
testPull.ChangeState("INIT_DEVICE");
|
||||
testPull.WaitForEndOfState("INIT_DEVICE");
|
||||
|
||||
testPull.ChangeState("INIT_TASK");
|
||||
testPull.WaitForEndOfState("INIT_TASK");
|
||||
|
||||
testPull.ChangeState("RUN");
|
||||
testPull.WaitForEndOfState("RUN");
|
||||
|
||||
testPull.ChangeState("RESET_TASK");
|
||||
testPull.WaitForEndOfState("RESET_TASK");
|
||||
|
||||
testPull.ChangeState("RESET_DEVICE");
|
||||
testPull.WaitForEndOfState("RESET_DEVICE");
|
||||
|
||||
testPull.ChangeState("END");
|
||||
|
||||
return 0;
|
||||
}
|
58
fairmq/test/push-pull/runTestPush.cxx
Normal file
58
fairmq/test/push-pull/runTestPush.cxx
Normal file
@@ -0,0 +1,58 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* runTestPush.cxx
|
||||
*
|
||||
* @since 2015-09-05
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#include "FairMQLogger.h"
|
||||
#include "FairMQTestPush.h"
|
||||
|
||||
#ifdef NANOMSG
|
||||
#include "FairMQTransportFactoryNN.h"
|
||||
#else
|
||||
#include "FairMQTransportFactoryZMQ.h"
|
||||
#endif
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
FairMQTestPush testPush;
|
||||
testPush.CatchSignals();
|
||||
|
||||
#ifdef NANOMSG
|
||||
testPush.SetTransport(new FairMQTransportFactoryNN());
|
||||
#else
|
||||
testPush.SetTransport(new FairMQTransportFactoryZMQ());
|
||||
#endif
|
||||
|
||||
testPush.SetProperty(FairMQTestPush::Id, "testPush");
|
||||
|
||||
FairMQChannel pushChannel("push", "bind", "tcp://127.0.0.1:5557");
|
||||
testPush.fChannels["data"].push_back(pushChannel);
|
||||
|
||||
testPush.ChangeState("INIT_DEVICE");
|
||||
testPush.WaitForEndOfState("INIT_DEVICE");
|
||||
|
||||
testPush.ChangeState("INIT_TASK");
|
||||
testPush.WaitForEndOfState("INIT_TASK");
|
||||
|
||||
testPush.ChangeState("RUN");
|
||||
testPush.WaitForEndOfState("RUN");
|
||||
|
||||
testPush.ChangeState("RESET_TASK");
|
||||
testPush.WaitForEndOfState("RESET_TASK");
|
||||
|
||||
testPush.ChangeState("RESET_DEVICE");
|
||||
testPush.WaitForEndOfState("RESET_DEVICE");
|
||||
|
||||
testPush.ChangeState("END");
|
||||
|
||||
return 0;
|
||||
}
|
36
fairmq/test/req-rep/FairMQTestRep.cxx
Normal file
36
fairmq/test/req-rep/FairMQTestRep.cxx
Normal file
@@ -0,0 +1,36 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQTestRep.cpp
|
||||
*
|
||||
* @since 2015-09-05
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#include <memory> // unique_ptr
|
||||
|
||||
#include "FairMQTestRep.h"
|
||||
#include "FairMQLogger.h"
|
||||
|
||||
FairMQTestRep::FairMQTestRep()
|
||||
{
|
||||
}
|
||||
|
||||
void FairMQTestRep::Run()
|
||||
{
|
||||
std::unique_ptr<FairMQMessage> request(fTransportFactory->CreateMessage());
|
||||
if (fChannels.at("data").at(0).Receive(request) >= 0)
|
||||
{
|
||||
std::unique_ptr<FairMQMessage> reply(fTransportFactory->CreateMessage());
|
||||
fChannels.at("data").at(0).Send(reply);
|
||||
}
|
||||
}
|
||||
|
||||
FairMQTestRep::~FairMQTestRep()
|
||||
{
|
||||
}
|
30
fairmq/test/req-rep/FairMQTestRep.h
Normal file
30
fairmq/test/req-rep/FairMQTestRep.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQTestRep.h
|
||||
*
|
||||
* @since 2015-09-05
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#ifndef FAIRMQTESTREP_H_
|
||||
#define FAIRMQTESTREP_H_
|
||||
|
||||
#include "FairMQDevice.h"
|
||||
|
||||
class FairMQTestRep : public FairMQDevice
|
||||
{
|
||||
public:
|
||||
FairMQTestRep();
|
||||
virtual ~FairMQTestRep();
|
||||
|
||||
protected:
|
||||
virtual void Run();
|
||||
};
|
||||
|
||||
#endif /* FAIRMQTESTREP_H_ */
|
38
fairmq/test/req-rep/FairMQTestReq.cxx
Normal file
38
fairmq/test/req-rep/FairMQTestReq.cxx
Normal file
@@ -0,0 +1,38 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQTestReq.cxx
|
||||
*
|
||||
* @since 2015-09-05
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#include <memory> // unique_ptr
|
||||
|
||||
#include "FairMQTestReq.h"
|
||||
#include "FairMQLogger.h"
|
||||
|
||||
FairMQTestReq::FairMQTestReq()
|
||||
{
|
||||
}
|
||||
|
||||
void FairMQTestReq::Run()
|
||||
{
|
||||
std::unique_ptr<FairMQMessage> request(fTransportFactory->CreateMessage());
|
||||
fChannels.at("data").at(0).Send(request);
|
||||
|
||||
std::unique_ptr<FairMQMessage> reply(fTransportFactory->CreateMessage());
|
||||
if (fChannels.at("data").at(0).Receive(reply) >= 0)
|
||||
{
|
||||
LOG(INFO) << "REQ-REP test successfull";
|
||||
}
|
||||
}
|
||||
|
||||
FairMQTestReq::~FairMQTestReq()
|
||||
{
|
||||
}
|
30
fairmq/test/req-rep/FairMQTestReq.h
Normal file
30
fairmq/test/req-rep/FairMQTestReq.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQTestReq.h
|
||||
*
|
||||
* @since 2015-09-05
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#ifndef FAIRMQTESTREQ_H_
|
||||
#define FAIRMQTESTREQ_H_
|
||||
|
||||
#include "FairMQDevice.h"
|
||||
|
||||
class FairMQTestReq : public FairMQDevice
|
||||
{
|
||||
public:
|
||||
FairMQTestReq();
|
||||
virtual ~FairMQTestReq();
|
||||
|
||||
protected:
|
||||
virtual void Run();
|
||||
};
|
||||
|
||||
#endif /* FAIRMQTESTREQ_H_ */
|
60
fairmq/test/req-rep/runTestRep.cxx
Normal file
60
fairmq/test/req-rep/runTestRep.cxx
Normal file
@@ -0,0 +1,60 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* runTestRep.cxx
|
||||
*
|
||||
* @since 2015-09-05
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "FairMQLogger.h"
|
||||
#include "FairMQTestRep.h"
|
||||
|
||||
#ifdef NANOMSG
|
||||
#include "FairMQTransportFactoryNN.h"
|
||||
#else
|
||||
#include "FairMQTransportFactoryZMQ.h"
|
||||
#endif
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
FairMQTestRep testRep;
|
||||
testRep.CatchSignals();
|
||||
|
||||
#ifdef NANOMSG
|
||||
testRep.SetTransport(new FairMQTransportFactoryNN());
|
||||
#else
|
||||
testRep.SetTransport(new FairMQTransportFactoryZMQ());
|
||||
#endif
|
||||
|
||||
testRep.SetProperty(FairMQTestRep::Id, "testRep");
|
||||
|
||||
FairMQChannel repChannel("rep", "connect", "tcp://127.0.0.1:5558");
|
||||
testRep.fChannels["data"].push_back(repChannel);
|
||||
|
||||
testRep.ChangeState("INIT_DEVICE");
|
||||
testRep.WaitForEndOfState("INIT_DEVICE");
|
||||
|
||||
testRep.ChangeState("INIT_TASK");
|
||||
testRep.WaitForEndOfState("INIT_TASK");
|
||||
|
||||
testRep.ChangeState("RUN");
|
||||
testRep.WaitForEndOfState("RUN");
|
||||
|
||||
testRep.ChangeState("RESET_TASK");
|
||||
testRep.WaitForEndOfState("RESET_TASK");
|
||||
|
||||
testRep.ChangeState("RESET_DEVICE");
|
||||
testRep.WaitForEndOfState("RESET_DEVICE");
|
||||
|
||||
testRep.ChangeState("END");
|
||||
|
||||
return 0;
|
||||
}
|
60
fairmq/test/req-rep/runTestReq.cxx
Normal file
60
fairmq/test/req-rep/runTestReq.cxx
Normal file
@@ -0,0 +1,60 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* runTestReq.cxx
|
||||
*
|
||||
* @since 2015-09-05
|
||||
* @author A. Rybalchenko
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "FairMQLogger.h"
|
||||
#include "FairMQTestReq.h"
|
||||
|
||||
#ifdef NANOMSG
|
||||
#include "FairMQTransportFactoryNN.h"
|
||||
#else
|
||||
#include "FairMQTransportFactoryZMQ.h"
|
||||
#endif
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
FairMQTestReq testReq;
|
||||
testReq.CatchSignals();
|
||||
|
||||
#ifdef NANOMSG
|
||||
testReq.SetTransport(new FairMQTransportFactoryNN());
|
||||
#else
|
||||
testReq.SetTransport(new FairMQTransportFactoryZMQ());
|
||||
#endif
|
||||
|
||||
testReq.SetProperty(FairMQTestReq::Id, "testReq");
|
||||
|
||||
FairMQChannel reqChannel("req", "bind", "tcp://127.0.0.1:5558");
|
||||
testReq.fChannels["data"].push_back(reqChannel);
|
||||
|
||||
testReq.ChangeState("INIT_DEVICE");
|
||||
testReq.WaitForEndOfState("INIT_DEVICE");
|
||||
|
||||
testReq.ChangeState("INIT_TASK");
|
||||
testReq.WaitForEndOfState("INIT_TASK");
|
||||
|
||||
testReq.ChangeState("RUN");
|
||||
testReq.WaitForEndOfState("RUN");
|
||||
|
||||
testReq.ChangeState("RESET_TASK");
|
||||
testReq.WaitForEndOfState("RESET_TASK");
|
||||
|
||||
testReq.ChangeState("RESET_DEVICE");
|
||||
testReq.WaitForEndOfState("RESET_DEVICE");
|
||||
|
||||
testReq.ChangeState("END");
|
||||
|
||||
return 0;
|
||||
}
|
12
fairmq/test/test-fairmq-pub-sub.sh.in
Executable file
12
fairmq/test/test-fairmq-pub-sub.sh.in
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
trap 'kill -TERM $PUB_PID; kill -TERM $SUB1_PID; kill -TERM $SUB2_PID; wait $PUB_PID; wait $SUB1_PID; wait $SUB2_PID;' TERM
|
||||
@CMAKE_BINARY_DIR@/bin/test-fairmq-pub &
|
||||
PUB_PID=$!
|
||||
@CMAKE_BINARY_DIR@/bin/test-fairmq-sub &
|
||||
SUB1_PID=$!
|
||||
@CMAKE_BINARY_DIR@/bin/test-fairmq-sub &
|
||||
SUB2_PID=$!
|
||||
wait $PUB_PID
|
||||
wait $SUB1_PID
|
||||
wait $SUB2_PID
|
9
fairmq/test/test-fairmq-push-pull.sh.in
Executable file
9
fairmq/test/test-fairmq-push-pull.sh.in
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
trap 'kill -TERM $PUSH_PID; kill -TERM $PULL_PID; wait $PUSH_PID; wait $PULL_PID;' TERM
|
||||
@CMAKE_BINARY_DIR@/bin/test-fairmq-push &
|
||||
PUSH_PID=$!
|
||||
@CMAKE_BINARY_DIR@/bin/test-fairmq-pull &
|
||||
PULL_PID=$!
|
||||
wait $PUSH_PID
|
||||
wait $PULL_PID
|
9
fairmq/test/test-fairmq-req-rep.sh.in
Executable file
9
fairmq/test/test-fairmq-req-rep.sh.in
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
trap 'kill -TERM $REQ_PID; kill -TERM $REP_PID; wait $REQ_PID; wait $REP_PID;' TERM
|
||||
@CMAKE_BINARY_DIR@/bin/test-fairmq-req &
|
||||
REQ_PID=$!
|
||||
@CMAKE_BINARY_DIR@/bin/test-fairmq-rep &
|
||||
REP_PID=$!
|
||||
wait $REQ_PID
|
||||
wait $REP_PID
|
Reference in New Issue
Block a user