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" *
********************************************************************************/
/**
* 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()
{
}

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

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

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

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

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