Tests for MQ examples

This commit is contained in:
Alexey Rybalchenko
2017-08-23 11:12:29 +02:00
parent f6ee1cdf57
commit bd8be1436e
57 changed files with 658 additions and 118 deletions

View File

@@ -24,17 +24,19 @@ using namespace std;
FairMQExample5Client::FairMQExample5Client()
: fText()
, fMaxIterations(0)
, fNumIterations(0)
{
}
void FairMQExample5Client::InitTask()
{
fText = fConfig->GetValue<string>("text");
fMaxIterations = fConfig->GetValue<uint64_t>("max-iterations");
}
bool FairMQExample5Client::ConditionalRun()
{
this_thread::sleep_for(chrono::seconds(1));
string* text = new string(fText);
@@ -55,6 +57,15 @@ bool FairMQExample5Client::ConditionalRun()
if (Receive(reply, "data") >= 0)
{
LOG(INFO) << "Received reply from server: \"" << string(static_cast<char*>(reply->GetData()), reply->GetSize()) << "\"";
if (fMaxIterations > 0 && ++fNumIterations >= fMaxIterations)
{
LOG(INFO) << "Configured maximum number of iterations reached. Leaving RUNNING state.";
return false;
}
this_thread::sleep_for(chrono::seconds(1));
return true;
}
}