Add FairMQ tests (PUB-SUB, PUSH-PULL, REQ-REP).

This commit is contained in:
Alexey Rybalchenko
2015-09-04 17:04:52 +02:00
committed by Mohammad Al-Turany
parent fbf7dbf2ba
commit f13bb5995d
40 changed files with 921 additions and 47 deletions

View 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()
{
}

View 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_ */

View 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()
{
}

View 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_ */

View 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;
}

View 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;
}