Improvements from anna fork
[anna.git] / example / diameter / launcher / Launcher.cpp
index 9517372..2175263 100644 (file)
@@ -12,6 +12,8 @@
 #include <math.h> // ceil
 #include <climits>
 #include <unistd.h> // chdir
+//#include <regex> TODO: use this from gcc4.9.0: http://stackoverflow.com/questions/8060025/is-this-c11-regex-error-me-or-the-compiler
+#include <stdio.h>
 
 // Project
 #include <anna/timex/Engine.hpp>
 #include <anna/diameter/helpers/base/functions.hpp>
 #include <anna/time/functions.hpp>
 #include <anna/diameter.comm/ApplicationMessageOamModule.hpp>
+#include <anna/testing/defines.hpp>
 #include <anna/xml/xml.hpp>
+#include <anna/diameter.comm/OriginHost.hpp>
+#include <anna/diameter.comm/OriginHostManager.hpp>
+#include <Procedure.hpp>
 
 // Process
 #include <Launcher.hpp>
-#include <OriginHost.hpp>
 #include <MyDiameterEngine.hpp>
-#include <TestManager.hpp>
-#include <TestCase.hpp>
+#include <anna/testing/TestManager.hpp>
+#include <anna/testing/TestCase.hpp>
 
 
 #define SIGUSR2_TASKS_INPUT_FILENAME "sigusr2.in"
@@ -137,7 +142,6 @@ Launcher::Launcher() : anna::comm::Application("launcher", "DiameterLauncher", "
   //a_admlMinResolution = (anna::Millisecond)100;
   a_counterRecorderClock = NULL;
 
-  // a_originHosts.clear();
   a_workingNode = NULL;
 
   a_httpServerSocket = NULL;
@@ -298,8 +302,9 @@ void Launcher::servicesFromXML(const anna::xml::Node* servicesNode, bool eventOp
       burstLog = (*it)->getAttribute("burstLog", false /* no exception */); // (yes | no)
 
       // Basic checkings:
-      origin_hosts_it nodeIt = a_originHosts.find(originHost->getValue());
-      if (nodeIt != a_originHosts.end()) {
+      anna::diameter::comm::OriginHostManager &ohm = anna::diameter::comm::OriginHostManager::instantiate();
+      anna::diameter::comm::OriginHost *oh = ohm.getOriginHost(originHost->getValue());
+      if (oh) {
         std::string msg = "Already registered such Origin-Host: "; msg += originHost->getValue();
         throw anna::RuntimeException(msg, ANNA_FILE_LOCATION);
       }
@@ -325,11 +330,24 @@ void Launcher::servicesFromXML(const anna::xml::Node* servicesNode, bool eventOp
 
       // Checking command line parameters
       std::string sessionBasedModelsType;
+      anna::diameter::comm::Entity::SessionBasedModelsType::_v sessionBasedModelsTypeEnum;
       if(sessionBasedModelsClientSocketSelection) {
         sessionBasedModelsType = sessionBasedModelsClientSocketSelection->getValue();
-        if((sessionBasedModelsType != "SessionIdHighPart") && (sessionBasedModelsType != "SessionIdOptionalPart") && (sessionBasedModelsType != "RoundRobin")) {
-          throw anna::RuntimeException("Parameter 'sessionBasedModelsClientSocketSelection' only accepts 'SessionIdHighPart'/'SessionIdOptionalPart'/'RoundRobin' as parameter values", ANNA_FILE_LOCATION);
-        }
+       if (sessionBasedModelsType == "RoundRobin") {
+          sessionBasedModelsTypeEnum = anna::diameter::comm::Entity::SessionBasedModelsType::RoundRobin;
+       }
+       else if (sessionBasedModelsType == "SessionIdOptionalPart") {
+          sessionBasedModelsTypeEnum = anna::diameter::comm::Entity::SessionBasedModelsType::SessionIdOptionalPart;
+       }
+       else if (sessionBasedModelsType == "SessionIdHighPart") {
+          sessionBasedModelsTypeEnum = anna::diameter::comm::Entity::SessionBasedModelsType::SessionIdHighPart;
+       }
+       else if (sessionBasedModelsType == "SessionIdLowPart") {
+          sessionBasedModelsTypeEnum = anna::diameter::comm::Entity::SessionBasedModelsType::SessionIdLowPart;
+       }
+       else {
+          throw anna::RuntimeException("Parameter 'sessionBasedModelsClientSocketSelection' only accepts 'SessionIdLowPart'/'SessionIdHighPart'/'SessionIdOptionalPart'/'RoundRobin' as parameter values", ANNA_FILE_LOCATION);
+       }
       }
 
       int retransmissions = retries ? retries->getIntegerValue() : 0;
@@ -337,18 +355,21 @@ void Launcher::servicesFromXML(const anna::xml::Node* servicesNode, bool eventOp
         throw anna::RuntimeException("Parameter 'retries' must be non-negative", ANNA_FILE_LOCATION);
       }
 
-      // Create new Node instance /////////////////////////////////////////////////////////////////
-      a_workingNode = new OriginHost(originHost->getValue(), applicationId, bpd);
-      MyDiameterEngine *commEngine = a_workingNode->getMyDiameterEngine();
       /////////////////////////////////////////////////////////////////////////////////////////////
-
-      // Assignments:
+      // Diameter communication engine:
+      std::string commEngineName = originHost->getValue() + "_DiameterCommEngine";
+      MyDiameterEngine *commEngine = new MyDiameterEngine(commEngineName.c_str(), bpd);
+      commEngine->setAutoBind(false);  // allow to create client-sessions without binding them, in order to set timeouts.
       commEngine->setMaxConnectionDelay(tcpConnectDelayMs);
       commEngine->setWatchdogPeriod(watchdogPeriodMs);
+      commEngine->setOriginHostName(originHost->getValue());
+      if (originRealm) commEngine->setOriginRealmName(originRealm->getValue());
+
+      // Origin host node:
+      a_workingNode = new anna::diameter::comm::OriginHost((anna::diameter::comm::Engine*)commEngine, applicationId);
+      a_workingNode->setRequestRetransmissions(retransmissions);
+      /////////////////////////////////////////////////////////////////////////////////////////////
 
-      // Realm information:
-      commEngine->setOriginHost(originHost->getValue());
-      if (originRealm) commEngine->setOriginRealm(originRealm->getValue());
 
       // Diameter entity:
       if(entity) {
@@ -365,8 +386,7 @@ void Launcher::servicesFromXML(const anna::xml::Node* servicesNode, bool eventOp
 
           // Register one entity for this engine:
           a_workingNode->createEntity(entity->getValue(), ceaTimeoutMs, answersTimeoutMs);
-          a_workingNode->setRequestRetransmissions(retransmissions);
-          a_workingNode->getEntity()->setSessionBasedModelsType(sessionBasedModelsType);
+          a_workingNode->getEntity()->setSessionBasedModelsType(sessionBasedModelsTypeEnum);
           a_workingNode->getEntity()->setBalance(balance ? (balance->getValue() == "yes") : false); // for sendings
           if (eventOperation) a_workingNode->getEntity()->bind();
         }
@@ -378,12 +398,12 @@ void Launcher::servicesFromXML(const anna::xml::Node* servicesNode, bool eventOp
         std::string ceaPathfile = cea ? cea->getValue() : "";
 
         int sessions = diameterServerSessions ? diameterServerSessions->getIntegerValue() : 1;
-        a_workingNode->startDiameterServer(diameterServer->getValue(), sessions, allowedInactivityTimeMs, answersTimeoutMs, ceaPathfile);
+        a_workingNode->createDiameterServer(diameterServer->getValue(), sessions, allowedInactivityTimeMs, answersTimeoutMs, ceaPathfile);
       }
 
       // Logs:
       if (!allLogsDisabled) {
-        std::string host = commEngine->getOriginHost();
+        std::string host = commEngine->getOriginHostName();
         std::string s_log = host + ".launcher.log"; if (log) s_log = log->getValue();
         bool b_splitLog = (splitLog ? (splitLog->getValue() == "yes") : false);
         bool b_detailedLog = (detailedLog ? (detailedLog->getValue() == "yes") : false);
@@ -397,7 +417,7 @@ void Launcher::servicesFromXML(const anna::xml::Node* servicesNode, bool eventOp
       if (eventOperation) commEngine->lazyInitialize();
 
       // Node and Codec Engine registration ///////////////////////////////////////////////////////
-      a_originHosts[originHost->getValue()] = a_workingNode;
+      ohm.registerOriginHost(originHost->getValue(), a_workingNode);
       /////////////////////////////////////////////////////////////////////////////////////////////
     }
   }
@@ -496,38 +516,51 @@ anna::Millisecond Launcher::checkTimeMeasure(const std::string &parameter, const
 bool Launcher::setWorkingNode(const std::string &name) throw() {
   bool result = false;
 
-  origin_hosts_it nodeIt = a_originHosts.find(name);
-  if (nodeIt == a_originHosts.end()) {
-    LOGWARNING(
-        std::string msg = "Unknown node with name '"; msg += name; msg += "'. Ignoring ...";
-    anna::Logger::warning(msg, ANNA_FILE_LOCATION);
-    );
-  }
-  else {
-    a_workingNode = const_cast<OriginHost*>(nodeIt->second);
+  anna::diameter::comm::OriginHostManager &ohm = anna::diameter::comm::OriginHostManager::instantiate();
+  anna::diameter::comm::OriginHost *oh = ohm.getOriginHost(name);
+
+  if (oh) {
+    a_workingNode = const_cast<anna::diameter::comm::OriginHost*>(oh);
     result = true;
   }
 
   return result;
 }
 
-OriginHost *Launcher::getOriginHost(const std::string &oh) const throw(anna::RuntimeException) {
-  origin_hosts_it it = a_originHosts.find(oh);
-  if (it != a_originHosts.end()) return it->second;
-  throw anna::RuntimeException(anna::functions::asString("There is no origin host registered as '%s' (set Origin-Host avp correctly or force a specific host with 'node' operation)", oh.c_str()), ANNA_FILE_LOCATION);
+anna::diameter::comm::OriginHost *Launcher::getOriginHost(const std::string &name) const throw(anna::RuntimeException) {
+  anna::diameter::comm::OriginHostManager &ohm = anna::diameter::comm::OriginHostManager::instantiate();
+  anna::diameter::comm::OriginHost *result = ohm.getOriginHost(name);
+
+  if (!result)
+  throw anna::RuntimeException(anna::functions::asString("There is no origin host registered as '%s' (set Origin-Host avp correctly or force a specific host with 'node' operation)", name.c_str()), ANNA_FILE_LOCATION);
+
+  return result;
 }
 
-OriginHost *Launcher::getOriginHost(const anna::diameter::codec::Message &message) const throw(anna::RuntimeException) {
+anna::diameter::comm::OriginHost *Launcher::getOriginHost(const anna::diameter::codec::Message &message) const throw(anna::RuntimeException) {
   std::string originHost = message.getAvp(anna::diameter::helpers::base::AVPID__Origin_Host)->getDiameterIdentity()->getValue();
   return (getOriginHost(originHost));
 }
 
+bool Launcher::uniqueOriginHost() const throw() {
+  anna::diameter::comm::OriginHostManager &ohm = anna::diameter::comm::OriginHostManager::instantiate();
+  return (ohm.size() == 1);
+}
+
+
 void Launcher::updateOperatedOriginHostWithMessage(const anna::diameter::codec::Message &message) throw(anna::RuntimeException) {
   if (!a_operatedHost) // priority for working node by mean 'node' operation
     a_operatedHost = getOriginHost(message);
 }
 
-OriginHost *Launcher::getOperatedHost() const throw(anna::RuntimeException) {
+anna::diameter::comm::OriginHost *Launcher::getWorkingNode() const throw(anna::RuntimeException) {
+  if(!a_workingNode)
+    throw anna::RuntimeException("Working node not identified (try to load services)", ANNA_FILE_LOCATION);
+
+  return a_workingNode;
+}
+
+anna::diameter::comm::OriginHost *Launcher::getOperatedHost() const throw(anna::RuntimeException) {
   if(!a_operatedHost)
     throw anna::RuntimeException("Node not identified (try to force a specific Origin-Host with 'node' operation)", ANNA_FILE_LOCATION);
 
@@ -535,21 +568,21 @@ OriginHost *Launcher::getOperatedHost() const throw(anna::RuntimeException) {
 }
 
 MyDiameterEntity *Launcher::getOperatedEntity() const throw(anna::RuntimeException) {
-  MyDiameterEntity *result = getOperatedHost()->getEntity();
+  MyDiameterEntity *result = (MyDiameterEntity *)(getOperatedHost()->getEntity());
   if (!result)
     throw anna::RuntimeException("No entity configured for the operated node", ANNA_FILE_LOCATION);
   return result;
 }
 
 MyLocalServer *Launcher::getOperatedServer() const throw(anna::RuntimeException) {
-  MyLocalServer *result = getOperatedHost()->getDiameterServer();
+  MyLocalServer *result = (MyLocalServer *)(getOperatedHost()->getDiameterServer());
   if (!result)
     throw anna::RuntimeException("No local server configured for the operated node", ANNA_FILE_LOCATION);
   return result;
 }
 
 MyDiameterEngine *Launcher::getOperatedEngine() const throw(anna::RuntimeException) {
-  return getOperatedHost()->getMyDiameterEngine(); // never will be NULL
+  return (MyDiameterEngine *)getOperatedHost()->getCommEngine(); // never will be NULL
 }
 
 void Launcher::initialize()
@@ -559,11 +592,18 @@ throw(anna::RuntimeException) {
   anna::comm::Communicator::WorkMode::_v workMode(anna::comm::Communicator::WorkMode::Single);
   a_communicator = new MyCommunicator(workMode);
   a_timeEngine = new anna::timex::Engine((anna::Millisecond)600000, a_admlMinResolution);
-  TestManager::instantiate().setTimerController(a_timeEngine);
+  anna::testing::TestManager::instantiate().setTimerController(a_timeEngine);
 
   // Counters record procedure:
   const char *varname = "cntRecordPeriod";
-  anna::Millisecond cntRecordPeriod = (cl.exists(varname)) ? checkTimeMeasure(varname, cl.getValue(varname)) : (anna::Millisecond)300000;
+  anna::Millisecond cntRecordPeriod;
+  try {
+    cntRecordPeriod = (cl.exists(varname)) ? checkTimeMeasure(varname, cl.getValue(varname)) : (anna::Millisecond)300000;
+  }
+  catch(anna::RuntimeException &ex) {
+    if (cntRecordPeriod != 0) throw ex;
+  }
+
   if(cntRecordPeriod != 0) {
     a_counterRecorderClock = new MyCounterRecorderClock("Counters record procedure clock", cntRecordPeriod); // clock
     std::string cntDir = ".";
@@ -574,7 +614,7 @@ throw(anna::RuntimeException) {
   // Testing framework:
   std::string tmDir = ".";
   if(cl.exists("tmDir")) tmDir = cl.getValue("tmDir");
-  TestManager::instantiate().setReportsDirectory(tmDir);
+  anna::testing::TestManager::instantiate().setReportsDirectory(tmDir);
 
   // Tracing:
   if(cl.exists("trace"))
@@ -588,7 +628,7 @@ void Launcher::run()
 throw(anna::RuntimeException) {
   LOGMETHOD(anna::TraceMethod tm("Launcher", "run", ANNA_FILE_LOCATION));
   CommandLine& cl(anna::CommandLine::instantiate());
-  anna::diameter::stack::Engine &stackEngine = anna::diameter::stack::Engine::instantiate();
+  anna::diameter::stack::Engine::instantiate();
 
   // Start time:
   a_start_time.setNow();
@@ -745,39 +785,17 @@ throw(anna::RuntimeException) {
     a_timeEngine->activate(a_counterRecorderClock); // start clock
   }
 
-  // Log statistics concepts
-  if(cl.exists("logStatisticSamples")) {
-    std::string list = cl.getValue("logStatisticSamples");
-    anna::statistics::Engine &statEngine = anna::statistics::Engine::instantiate();
-
-    if(list == "all") {
-      if(statEngine.enableSampleLog(/* -1: all concepts */))
-        LOGDEBUG(anna::Logger::debug("Sample log activation for all statistic concepts", ANNA_FILE_LOCATION));
-    } else {
-      anna::Tokenizer lst;
-      lst.apply(cl.getValue("logStatisticSamples"), ",");
-
-      if(lst.size() >= 1) {
-        anna::Tokenizer::const_iterator tok_min(lst.begin());
-        anna::Tokenizer::const_iterator tok_max(lst.end());
-        anna::Tokenizer::const_iterator tok_iter;
-        int conceptId;
-
-        for(tok_iter = tok_min; tok_iter != tok_max; tok_iter++) {
-          conceptId = atoi(anna::Tokenizer::data(tok_iter));
-
-          if(statEngine.enableSampleLog(conceptId))
-            LOGDEBUG(anna::Logger::debug(anna::functions::asString("Sample log activation for statistic concept id = %d", conceptId), ANNA_FILE_LOCATION));
-        }
-      }
-    }
-  }
-
+  /////////////////////////////
+  // Log statistics concepts //
+  /////////////////////////////
+  if(cl.exists("logStatisticSamples"))
+    logStatisticsSamples(cl.getValue("logStatisticSamples"));
 
   // Start client connections //////////////////////////////////////////////////////////////////////////////////
   MyDiameterEntity *entity;
-  for (origin_hosts_it it = a_originHosts.begin(); it != a_originHosts.end(); it++) {
-    entity = it->second->getEntity();
+  anna::diameter::comm::OriginHostManager &ohm = anna::diameter::comm::OriginHostManager::instantiate();
+  for (diameter::comm::origin_hosts_it it = ohm.begin(); it != ohm.end(); it++) {
+    entity = (MyDiameterEntity *)(it->second->getEntity());
     if (entity) entity->bind();
   }
 
@@ -791,8 +809,7 @@ throw(anna::RuntimeException) {
   a_communicator->accept();
 }
 
-
-bool Launcher::getDataBlockFromHexFile(const std::string &pathfile, anna::DataBlock &db) const throw() {
+bool Launcher::getDataBlockFromHexFile(const std::string &pathfile, anna::DataBlock &db) const throw(anna::RuntimeException) {
   // Get hex string
   static char buffer[8192];
   std::ifstream infile(pathfile.c_str(), std::ifstream::in);
@@ -807,7 +824,8 @@ bool Launcher::getDataBlockFromHexFile(const std::string &pathfile, anna::DataBl
     msg += hexString;
     anna::Logger::debug(msg, ANNA_FILE_LOCATION);
     );
-    anna::functions::fromHexString(hexString, db);
+
+    anna::functions::fromHexString(hexString, db); // could launch exception
     // Close file
     infile.close();
     return true;
@@ -816,13 +834,29 @@ bool Launcher::getDataBlockFromHexFile(const std::string &pathfile, anna::DataBl
   return false;
 }
 
+bool Launcher::getContentFromFile(const std::string &pathfile, std::string &content) const throw(anna::RuntimeException) {
+
+  std::ifstream inFile(pathfile.c_str(), std::ifstream::in);
+  if(!inFile.good()) {
+    throw RuntimeException(anna::functions::asString("Unable to open file '%s'", pathfile.c_str()), ANNA_FILE_LOCATION);
+  }
+
+  std::stringstream strStream;
+  strStream << inFile.rdbuf(); //read the file
+  content = strStream.str(); // holds the content of the file
+  inFile.close();
+
+  return true;
+}
+
 void Launcher::resetStatistics() throw() {
   if (a_workingNode) {
-    a_workingNode->getMyDiameterEngine()->resetStatistics();
+    a_workingNode->getCommEngine()->resetStatistics();
   }
   else {
-    for (origin_hosts_it it = a_originHosts.begin(); it != a_originHosts.end(); it++) {
-      it->second->getMyDiameterEngine()->resetStatistics();
+    anna::diameter::comm::OriginHostManager &ohm = anna::diameter::comm::OriginHostManager::instantiate();
+    for (diameter::comm::origin_hosts_it it = ohm.begin(); it != ohm.end(); it++) {
+      it->second->getCommEngine()->resetStatistics();
     }
   }
 }
@@ -833,6 +867,15 @@ void Launcher::resetCounters() throw() {
   anna::diameter::codec::OamModule::instantiate().resetCounters();
 }
 
+void Launcher::signalTerminate() throw(anna::RuntimeException) {
+  LOGMETHOD(anna::TraceMethod tm("Launcher", "signalTerminate", ANNA_FILE_LOCATION));
+
+  forceCountersRecord();
+
+  a_communicator->terminate ();
+  comm::Application::signalTerminate ();
+}
+
 void Launcher::signalUSR2() throw(anna::RuntimeException) {
 
   std::string inputFile = getSignalUSR2InputFile();
@@ -1036,6 +1079,11 @@ std::string Launcher::help() const throw() {
   result += "\n                                     This operation applies over all the registered host nodes";
   result += "\n                                      except if one specific working node has been set.";
   result += "\nforceCountersRecord                  Forces dump to file the current counters of the process.";
+  result += "\nlog-statistics-samples|<list>        Log statistics samples for the provided comma-separated concept id";
+  result += "\n                                      list, over './sample.<concept id>.csv' files. For example: \"1,2\"";
+  result += "\n                                      will log concepts 1 and 2. Reserved words \"all\"/\"none\" activates/";
+  result += "\n                                      deactivates all registered statistics concept identifiers. That ids";
+  result += "\n                                      are shown at context dump.";
   result += "\nchange-dir[|directory]               Changes the execution point which could be fine to ease some";
   result += "\n                                     file system interaction tasks. Be care about some requirements";
   result += "\n                                     (for example if you have a user defined counters directory as";
@@ -1181,7 +1229,17 @@ std::string Launcher::help() const throw() {
   result += "\n                                 values (Session-Id, Subscriber-Id, etc.).";
   result += "\n";
   result += "\n                           <command>: commands to be executed for the test id provided. Each command programmed";
-  result += "\n                                      constitutes a test case 'step', numbered from 1 to N.";
+  result += "\n                                      constitutes a test case 'step', numbered from 1 to N, with an exception for";
+  result += "\n                                      'description' which is used to describe the test case:";
+  result += "\n";
+  result += "\n                              description|<description>  Sets a test case description. Test cases by default are";
+  result += "\n                                                          constructed with description 'Testcase_<id>'.";
+  result += "\n";
+  result += "\n                              ip-limit[|amount]          In-progress limit of test cases controlled from this test.";
+  result += "\n                                                         No new test cases will be launched over this value (test";
+  result += "\n                                                         manager tick work will be ignored). Zero-value is equivalent";
+  result += "\n                                                         to stop the clock tick, -1 is used to specify 'no limit' which";
+  result += "\n                                                         is the default. For missing amount, value of 1 is applied.";
   result += "\n";
   result += "\n                              timeout|<msecs>            Sets an asynchronous timer to restrict the maximum timeout";
   result += "\n                                                          until last test step. Normally, this command is invoked";
@@ -1216,16 +1274,6 @@ std::string Launcher::help() const throw() {
   result += "\n                              delay|<msecs>              Blocking step until the time lapse expires. Useful to give ";
   result += "\n                                                          some cadence control and time schedule for a specific case.";
   result += "\n                                                         A value of 0 could be used as a dummy step.";
-  result += "\n                              wait<fe/fc>|<condition>    Blocking step until condition is fulfilled. The message could";
-  result += "\n                                                          received from entity (waitfe) or from client (waitfc).";
-  result += "\n";
-  result += "\n                              wait<fe/fc>-regexp|<regexp>";
-  result += "\n                                                         Wait condition, from entity (waitfe-regexp) or client (waitfc-regexp)";
-  result += "\n                                                          to match the serialized xml content for received messages. CPU cost";
-  result += "\n                                                          is bigger than the former ones because the whole message must be";
-  result += "\n                                                          decoded and converted to xml instead of doing a direct hexadecimal";
-  result += "\n                                                          buffer search. The main advantage is the great flexibility to identify";
-  result += "\n                                                          any content with a regular expression.";
   result += "\n";
   result += "\n                              sh-command|<script>        External execution for script/executable via shell through a dedicated";
   result += "\n                                                          thread, providing the command and parameters. You could use dynamic";
@@ -1244,12 +1292,36 @@ std::string Launcher::help() const throw() {
   result += "\n                                                          with the possible outputs from the scripts. You could also put your";
   result += "\n                                                          job in background although sh-command will return 0-value immediately.";
   result += "\n";
-  result += "\n                           <condition>: Optional parameters which must be fulfilled to continue through the next step.";
-  result += "\n                                        Any received message over diameter interfaces will be evaluated against the";
-  result += "\n                                         corresponding test case starting from the current step until the first one";
-  result += "\n                                         whose condition is fulfilled. If no condition is fulfilled the event will be";
-  result += "\n                                         classified as 'uncovered' (normally a test case bad configuration, or perhaps";
-  result += "\n                                         a real unexpected message).";
+  result += "\n                              wait<fe/fc>-hex|<source_file>[|strict]";
+  result += "\n                                                         Wait condition, from entity (waitfe-hex) or client (waitfc-hex) to";
+  result += "\n                                                          match the hexadecimal representation for received messages against";
+  result += "\n                                                          source file (hex format). Fix mode must be enabled to avoid unexpected";
+  result += "\n                                                          matching behaviour. Specify 'strict' to use the hex content 'as is'.";
+  result += "\n                                                          If not, the hex content will be understood as whole message and then,";
+  result += "\n                                                          borders will be added (^<content>$) and sequence information bypassed";
+  result += "\n                                                          even for diameter answers.";
+  result += "\n";
+  result += "\n                              wait<fe/fc>-xml|<source_file>[|strict]";
+  result += "\n                                                         Wait condition from entity (waitfe-xml) or client (waitfc-xml) to";
+  result += "\n                                                          match the serialized xml content for received messages against";
+  result += "\n                                                          source file (xml representation). Fix mode must be enabled to avoid";
+  result += "\n                                                          unexpected matching behaviour. If you need a strict matching you";
+  result += "\n                                                          must add parameter 'strict', if not, regexp is built ignoring sequence";
+  result += "\n                                                          information (hop-by-hop-id=\"[0-9]+\" end-to-end-id=\"[0-9]+\") and";
+  result += "\n                                                          Origin-State-Id value.";
+  result += "\n                                                          All LF codes will be internally removed when comparison is executed";
+  result += "\n                                                          in order to ease xml content configuration.";
+  result += "\n";
+  result += "\n                              wait<fe/fc>|<condition>    Blocking step until condition is fulfilled. The message could";
+  result += "\n                                                          received from entity (waitfe) or from client (waitfc).";
+  result += "\n                                                         CPU cost is lower than former 'wait<fe/fc>-<xml|hex>' variants.";
+  result += "\n";
+  result += "\n                                          <condition>: Optional parameters which must be fulfilled to continue through the next step.";
+  result += "\n                                                       Any received message over diameter interfaces will be evaluated against the";
+  result += "\n                                                        corresponding test case starting from the current step until the first one";
+  result += "\n                                                        whose condition is fulfilled. If no condition is fulfilled the event will be";
+  result += "\n                                                        classified as 'uncovered' (normally a test case bad configuration, or perhaps";
+  result += "\n                                                        a real unexpected message).";
 
   // TODO(***)
   //  result += "\n                                        The way to identify the test case, is through registered Session-Id values for";
@@ -1262,50 +1334,50 @@ std::string Launcher::help() const throw() {
   //  result += "\n                                         comply with the incoming message, and reactivates it.";
   // The other solution: register Session-Id values for answers send to client from a local diameter server.
 
-  result += "\n                                        How to answer: a wait condition for a request will store the incoming message";
-  result += "\n                                         which fulfills that condition. This message is useful together with the peer";
-  result += "\n                                         connection source in a further send step configured with the corresponding";
-  result += "\n                                         response. You could also insert a delay between wait and send steps to be";
-  result += "\n                                         more realistic (processing time simulation in a specific ADML host node).";
-  result += "\n                                         Always, a response send step will get the needed information from the most";
-  result += "\n                                         recent wait step finding in reverse order (note that some race conditions";
-  result += "\n                                         could happen if your condition is not specific enough).";
+  result += "\n                                                       How to answer: a wait condition for a request will store the incoming message";
+  result += "\n                                                        which fulfills that condition. This message is useful together with the peer";
+  result += "\n                                                        connection source in a further send step configured with the corresponding";
+  result += "\n                                                        response. You could also insert a delay between wait and send steps to be";
+  result += "\n                                                        more realistic (processing time simulation in a specific ADML host node).";
+  result += "\n                                                        Always, a response send step will get the needed information from the most";
+  result += "\n                                                        recent wait step finding in reverse order (note that some race conditions";
+  result += "\n                                                        could happen if your condition is not specific enough).";
 
   result += "\n";
-  result += "\n                                        Condition format:";
+  result += "\n                                                       Condition format:";
   result += "\n";
-  result += "\n                                           [code]|[bitR]|[hopByHop]|[applicationId]|[sessionId]|[resultCode]|[msisdn]|[imsi]|[serviceContextId]";
+  result += "\n                                                          [code]|[bitR]|[hopByHop]|[applicationId]|[sessionId]|[resultCode]|[msisdn]|[imsi]|[serviceContextId]";
   result += "\n";
-  result += "\n                                             code: integer number";
-  result += "\n                                             bitR: 1 (request), 0 (answer)";
-  result += "\n                                             hopByHop: integer number or request send step reference: #<step number>";
+  result += "\n                                                            code: integer number";
+  result += "\n                                                            bitR: 1 (request), 0 (answer)";
+  result += "\n                                                            hopByHop: integer number or request send step reference: #<step number>";
   result += "\n";
-  result += "\n                                                       Using the hash reference, you would indicate a specific wait condition";
-  result += "\n                                                        for answers. The step number provided must correspond to any of the";
-  result += "\n                                                        previous send commands (sendxml2e/sendxml2c) configured for a request.";
-  result += "\n                                                       This 'hop-by-hop' variant eases the wait condition for answers in the";
-  result += "\n                                                        safest way.";
+  result += "\n                                                                      Using the hash reference, you would indicate a specific wait condition";
+  result += "\n                                                                       for answers. The step number provided must correspond to any of the";
+  result += "\n                                                                       previous send commands (sendxml2e/sendxml2c) configured for a request.";
+  result += "\n                                                                      This 'hop-by-hop' variant eases the wait condition for answers in the";
+  result += "\n                                                                       safest way.";
   result += "\n";
-  result += "\n                                             applicationId: integer number";
-  result += "\n                                             sessionId: string";
-  result += "\n                                             resultCode: integer number";
-  result += "\n                                             msisdn: string";
-  result += "\n                                             imsi: string";
-  result += "\n                                             serviceContextId: string";
+  result += "\n                                                            applicationId: integer number";
+  result += "\n                                                            sessionId: string";
+  result += "\n                                                            resultCode: integer number";
+  result += "\n                                                            msisdn: string";
+  result += "\n                                                            imsi: string";
+  result += "\n                                                            serviceContextId: string";
   result += "\n";
-  result += "\n                                        Take into account these rules, useful in general:";
+  result += "\n                                                       Take into account these rules, useful in general:";
   result += "\n";
-  result += "\n                                           - Be as much specific as possible defining conditions to avoid ambiguity sending";
-  result += "\n                                             messages out of context due to race conditions. Although you could program several";
-  result += "\n                                             times similar conditions, some risky practices will throw a warning trace (if you";
-  result += "\n                                             repeat the same condition within the same test case).";
-  result += "\n                                           - Adding a ResultCode and/or HopByHop to the condition are only valid waiting answers.";
-  result += "\n                                           - Requests hop-by-hop values must be different for all the test case requests.";
-  result += "\n                                             RFC says that a hop by hop must be unique for a specific connection, something that";
-  result += "\n                                             could be difficult to manage if we have multiple available connections from client";
-  result += "\n                                             side endpoint (entity or local server), even if we would have only one connection but";
-  result += "\n                                             several host interfaces. It is enough to configure different hop-by-hop values within";
-  result += "\n                                             each test case, because on reception, the Session-Id is used to identify that test case.";
+  result += "\n                                                          - Be as much specific as possible defining conditions to avoid ambiguity sending";
+  result += "\n                                                            messages out of context due to race conditions. Although you could program several";
+  result += "\n                                                            times similar conditions, some risky practices will throw a warning trace (if you";
+  result += "\n                                                            repeat the same condition within the same test case).";
+  result += "\n                                                          - Adding a ResultCode and/or HopByHop to the condition are only valid waiting answers.";
+  result += "\n                                                          - Requests hop-by-hop values must be different for all the test case requests.";
+  result += "\n                                                            RFC says that a hop by hop must be unique for a specific connection, something that";
+  result += "\n                                                            could be difficult to manage if we have multiple available connections from client";
+  result += "\n                                                            side endpoint (entity or local server), even if we would have only one connection but";
+  result += "\n                                                            several host interfaces. It is enough to configure different hop-by-hop values within";
+  result += "\n                                                            each test case, because on reception, the Session-Id is used to identify that test case.";
   result += "\n";
   result += "\n";
   result += "\n";
@@ -1380,10 +1452,10 @@ std::string Launcher::help() const throw() {
   result += "\n                                 next programmed test cases (1 by default). This event works regardless the timer tick";
   result += "\n                                 function, but it is normally used with the test manager tick stopped.";
   result += "\n";
-  result += "\n   test|ip-limit[|amount]        In-progress limit of test cases. No new test cases will be launched over this value";
-  result += "\n                                 (test Manager tick work will be ignored). Zero-value is equivalent to stop the clock.";
-  result += "\n                                 tick, -1 is used to specify 'no limit' which is the default. If missing amount, the";
-  result += "\n                                 limit and current amount of in-progress test cases will be shown.";
+  result += "\n   test|ip-limit[|amount]        In-progress limit of test cases established from global context. This value will be";
+  result += "\n                                 overwritten if used at test case level when the corresponding test step is executed.";
+  result += "\n                                 Anyway, the meaning is the same in both contexts. But now, when the amount is missing,";
+  result += "\n                                 the limit and current amount of in-progress test cases will be shown.";
   result += "\n";
   result += "\n   test|goto|<id>                Updates current test pointer position.";
   result += "\n";
@@ -1391,13 +1463,14 @@ std::string Launcher::help() const throw() {
   result += "\n                                 Test cases reports are not dumped on process context (too many information in general).";
   result += "\n                                 The report contains context information in every moment: this operation acts as a snapshot.";
   result += "\n";
-  result += "\n   test|interact|amount|id       Makes interactive a specific test case id. The amount is the margin of execution steps";
-  result += "\n                                 to be done. Normally, we will execute 'test|interact|0|<test case id>', which means that";
+  result += "\n   test|interact|amount[|id]     Makes interactive a specific test case id. The amount is the margin of execution steps";
+  result += "\n                                 to be done. Normally, we will execute 'test|interact|0[|<test case id>]', which means that";
   result += "\n                                 the test case is selected to be interactive, but no step is executed. Then you have to";
   result += "\n                                 interact with positive amounts (usually 1), executing the provided number of steps if";
   result += "\n                                 they are ready and fulfill the needed conditions. The value of 0, implies no execution";
   result += "\n                                 steps margin, which could be useful to 'freeze' a test in the middle of its execution.";
   result += "\n                                 You could also provide -1 to make it non-interactive resuming it from the current step.";
+  result += "\n                                 By default, current test case id is selected for interaction.";
   result += "\n";
   result += "\n   test|reset|<[soft]/hard>[|id] Reset the test case for id provided, all the tests when missing. It could be hard/soft:";
   result += "\n                                 - hard: you probably may need to stop the load rate before. This operation initializes";
@@ -1411,8 +1484,23 @@ std::string Launcher::help() const throw() {
   result += "\n                                 been done before. Test cases state & data will be reset (when achieved again), but general";
   result += "\n                                 statistics and counters will continue measuring until reset with 'collect' operation.";
   result += "\n";
+  result += "\n   test|auto-reset|<soft|hard>   When cycling, current test cases can be soft (default) or hard reset. If no timeout has";
+  result += "\n                                 been configured for the test case, hard reset could prevent stuck on the next cycle for";
+  result += "\n                                 those test cases still in progress.";
+  result += "\n";
+  result += "\n   test|initialized              Shows the number of initialized test cases. Zero-value means that everything was processed";
+  result += "                                   or not initiated yet.\n";
+  result += "\n";
+  result += "\n   test|finished                 Shows the number of finished (successful or failed) test cases.";
+  result += "\n";
   result += "\n   test|clear                    Clears all the programmed test cases and stop testing (if in progress).";
   result += "\n";
+  result += "\n   test|junit                    Shows the junit report in the moment of execution.";
+  result += "\n";
+  result += "\n   test|summary-counts           Test manager counts report. Counts by state and prints total verdict.";
+  result += "\n";
+  result += "\n   test|summary-states           Test manager states report.";
+  result += "\n";
   result += "\n   test|summary                  Test manager general report (number of test cases, counts by state, global configuration,";
   result += "\n                                 forced in-progress limitation, reports visibility, etc.). Be careful when you have reports";
   result += "\n                                 enabled because the programmed test cases dumps could be heavy (anyway you could enable the";
@@ -1435,6 +1523,29 @@ std::string Launcher::help() const throw() {
   result += "\n";
   result += "\n   test|report-hex[|[yes]|no]    Reports could include the diameter messages in hexadecimal format. Disabled by default.";
   result += "\n";
+  result += "\n   test|dump-stdout[|[yes]|no]   Test manager information is dumped into stdout.";
+  result += "\n";
+  result += "\n";
+  result += "\n------------------------------------------------------------------------------------- Dynamic procedure";
+  result += "\n";
+  result += "\ndynamic[|args]                   This launch an internal operation implemented in 'Procedure' class.";
+  result += "\n                                 Its default implementation does nothing, but you could create a dynamic";
+  result += "\n                                 library 'libanna_launcherDynamic.so' and replace the one in this project.";
+  result += "\n                                 One interesting application consists in the use of the diameter API and";
+  result += "\n                                 event operation to create a set of libraries as the testing framework.";
+  result += "\n                                 To execute each test case, the ADML process would be executed with a";
+  result += "\n                                 specific library path. But the main use would be the stress programming";
+  result += "\n                                 to achieve a great amount of cloned (even mixed) tests without using";
+  result += "\n                                 the management operation interface by mean http or signals: a single";
+  result += "\n                                 call to 'dynamic' would be enough to start a cascade of internally";
+  result += "\n                                 implemented operations.";
+  result += "\n                                 This operation accepts a generic string argument (piped or not, as you";
+  result += "\n                                 desire and depending on your procedure implementation).";
+  result += "\n";
+  result += "\n                                 This operation requires advanced programming and knowlegde of ANNA Diameter";
+  result += "\n                                 stack and testing framework, to take advantage of all the possibilities.";
+  result += "\n";
+  result += "\n";
   result += "\n";
   result += "\nUSING OPERATIONS INTERFACE";
   result += "\n--------------------------";
@@ -1476,10 +1587,42 @@ std::string Launcher::help() const throw() {
   return result;
 }
 
+
+void Launcher::logStatisticsSamples(const std::string &conceptsList) throw() {
+  anna::statistics::Engine &statEngine = anna::statistics::Engine::instantiate();
+
+  if(conceptsList == "all") {
+    if(statEngine.enableSampleLog(/* -1: all concepts */))
+      LOGDEBUG(anna::Logger::debug("Sample log activation for all statistic concepts", ANNA_FILE_LOCATION));
+  }
+  else if(conceptsList == "none") {
+      if(statEngine.disableSampleLog(/* -1: all concepts */))
+        LOGDEBUG(anna::Logger::debug("Sample log deactivation for all statistic concepts", ANNA_FILE_LOCATION));
+  } else {
+    anna::Tokenizer lst;
+    lst.apply(conceptsList, ",");
+
+    if(lst.size() >= 1) {
+      anna::Tokenizer::const_iterator tok_min(lst.begin());
+      anna::Tokenizer::const_iterator tok_max(lst.end());
+      anna::Tokenizer::const_iterator tok_iter;
+      int conceptId;
+
+      for(tok_iter = tok_min; tok_iter != tok_max; tok_iter++) {
+        conceptId = atoi(anna::Tokenizer::data(tok_iter));
+
+        if(statEngine.enableSampleLog(conceptId))
+          LOGDEBUG(anna::Logger::debug(anna::functions::asString("Sample log activation for statistic concept id = %d", conceptId), ANNA_FILE_LOCATION));
+      }
+    }
+  }
+}
+
+
 void Launcher::eventOperation(const std::string &operation, std::string &response_content) throw(anna::RuntimeException) {
   LOGMETHOD(anna::TraceMethod tm("Launcher", "eventOperation", ANNA_FILE_LOCATION));
   if (operation == "") return; // ignore
-  LOGDEBUG(anna::Logger::debug(operation, ANNA_FILE_LOCATION));
+  LOGDEBUG(anna::Logger::debug(anna::functions::asString("Operation: %s", operation.c_str()), ANNA_FILE_LOCATION));
 
   // Default response:
   response_content = "Operation processed with exception: ";
@@ -1489,13 +1632,30 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons
   anna::diameter::codec::Message codecMsg; // auxiliary codec message
 
   // Singletons:
-  CommandLine& cl(anna::CommandLine::instantiate());
-  TestManager &testManager = TestManager::instantiate();
+  anna::testing::TestManager &testManager = anna::testing::TestManager::instantiate();
 
 
   ///////////////////////////////////////////////////////////////////
   // Simple operations without arguments:
 
+  // Dynamic operation:
+  if(operation.find("dynamic") == 0) {
+    Procedure p(this);
+    int op_size = operation.size();
+    std::string args = ((operation.find("dynamic|") == 0) && (op_size > 8)) ? operation.substr(8) : "";
+    if (args == "" && op_size != 7)
+      throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION);
+    try {
+      p.execute(args, response_content);
+    }
+    catch(anna::RuntimeException &ex) {
+      ex.trace();
+      response_content = ex.asString();
+      return;
+    }
+    return;
+  }
+
   // Help:
   if(operation == "help") {
     response_content = help();
@@ -1573,6 +1733,7 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons
   bool wrongBody = false;
 
   if((opType == "change-dir") && (numParams > 1)) wrongBody = true;
+  if((opType == "log-statistics-samples") && (numParams != 1)) wrongBody = true;
   if((opType == "node") && (numParams > 1)) wrongBody = true;
 
   if((opType == "node_auto") && (numParams > 0)) wrongBody = true;
@@ -1603,6 +1764,12 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons
     return;
   }
 
+  if(opType == "log-statistics-samples") {
+    logStatisticsSamples(param1);
+    response_content = anna::functions::asString("Log statistics samples for '%s' concepts", param1.c_str());
+    return;
+  }
+
   // Change execution directory:
   if(opType == "change-dir") {
     if (param1 == "") param1 = a_initialWorkingDirectory;
@@ -1735,7 +1902,7 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons
       try { if(getOperatedHost()->logEnabled()) codecMsg.decode(db_aux); } catch(anna::RuntimeException &ex) { ex.trace(); }
     }
 
-    bool success = getOperatedEntity()->send(msg, cl.exists("balance"));
+    bool success = getOperatedEntity()->send(msg);
     getOperatedHost()->releaseCommMessage(msg);
 
     // Detailed log:
@@ -1855,6 +2022,7 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons
     // test|look[|id]                           Show programmed test case for id provided, current when missing ...
     // test|interact|amount|id                  Makes interactive a specific test case id. The amount is the margin of execution steps ...
     // test|reset|<[soft]/hard>[|id]            Reset the test case for id provided, all the tests when missing ...
+    // test|auto-reset|<soft|hard>              When cycling, current test cases can be soft (default) or hard reset ...
     // test|clear                               Clears all the programmed test cases.
     // test|summary                             Test manager general report (number of test cases, counts by state ...
 
@@ -1959,6 +2127,14 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons
       testManager.setDumpHex((param2 == "yes"));
       opt_response_content += (testManager.getDumpHex() ? "report includes hexadecimal messages" : "report excludes hexadecimal messages");
     }
+    else if(param1 == "dump-stdout") {
+      if (numParams > 2)
+        throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION);
+
+      if(param2 == "") param2 = "yes";
+      testManager.setDumpStdout((param2 == "yes"));
+      opt_response_content += (testManager.getDumpHex() ? "test manager dumps progress into stdout" : "test manager does not dump progress into stdout");
+    }
     else if(param1 == "goto") {
       if (numParams > 2)
         throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION);
@@ -1979,7 +2155,7 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons
         throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION);
 
       int id = ((param2 != "") ? atoi(param2.c_str()) : -1);
-      TestCase *testCase = testManager.findTestCase(id);
+      anna::testing::TestCase *testCase = testManager.findTestCase(id);
 
       if (testCase) {
         response_content = testCase->asXMLString();
@@ -1997,15 +2173,15 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons
       }
     }
     else if (param1 == "interact") {
-      if (numParams != 3)
+      if (numParams != 2)
         throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION);
 
       int amount = atoi(param2.c_str());
       if (amount < -1)
         throw anna::RuntimeException("Interactive amount must be -1 (to disable interactive mode) or a positive number.", ANNA_FILE_LOCATION);
 
-      int id = atoi(param3.c_str());
-      TestCase *testCase = testManager.findTestCase(id);
+      int id = ((param3 != "") ? atoi(param3.c_str()) : -1);
+      anna::testing::TestCase *testCase = testManager.findTestCase(id);
       if (testCase) {
         if (amount == -1) {
           testCase->makeInteractive(false);
@@ -2036,10 +2212,10 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons
         throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION);
 
       int id = ((param3 != "") ? atoi(param3.c_str()) : -1);
-      TestCase *testCase = ((id != -1) ? testManager.findTestCase(id) : NULL);
+      anna::testing::TestCase *testCase = ((id != -1) ? testManager.findTestCase(id) : NULL);
 
       if (testCase) {
-        bool done = testCase->reset((param2 == "hard") ? true:false);
+        bool done = testCase->reset(param2 == "hard");
         opt_response_content = "test ";
         opt_response_content += param2;
         opt_response_content += " reset for id ";
@@ -2048,7 +2224,7 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons
       }
       else {
         if (id == -1) {
-          bool anyReset = testManager.resetPool((param2 == "hard") ? true:false);
+          bool anyReset = testManager.resetPool(param2 == "hard");
           opt_response_content = param2; opt_response_content += " reset have been sent to all programmed tests: "; opt_response_content += anyReset ? "some/all have been reset" : "nothing was reset";
         }
         else {
@@ -2058,6 +2234,28 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons
         }
       }
     }
+    else if(param1 == "auto-reset") {
+      if (numParams != 2)
+        throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION);
+
+      if (param2 != "soft" && param2 != "hard")
+        throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION);
+
+      testManager.setAutoResetHard(param2 == "hard");
+      opt_response_content += anna::functions::asString("Auto-reset configured to '%s'", param2.c_str());
+    }
+    else if(param1 == "initialized") {
+      if (numParams > 1)
+        throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION);
+
+      opt_response_content = anna::functions::asString("%lu", testManager.getInitializedCount());
+    }
+    else if(param1 == "finished") {
+      if (numParams > 1)
+        throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION);
+
+      opt_response_content = anna::functions::asString("%lu", testManager.getFinishedCount());
+    }
     else if(param1 == "clear") {
       if (numParams > 1)
         throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION);
@@ -2069,6 +2267,18 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons
         opt_response_content = "there are not programmed test cases to be removed";
       }
     }
+    else if(param1 == "junit") {
+      response_content = testManager.junitAsXMLString();
+      return;
+    }
+    else if(param1 == "summary-counts") {
+      response_content = testManager.summaryCounts();
+      return;
+    }
+    else if(param1 == "summary-states") {
+      response_content = testManager.summaryStates();
+      return;
+    }
     else if(param1 == "summary") {
       response_content = testManager.asXMLString();
       return;
@@ -2080,17 +2290,32 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons
 
       // PARAM: 1     2            3      4          5           6             7           8          9       10         11
       // test|<id>|<command>
+      //             description|<description>
+      //             ip-limit[|<iplimit>]
       //             timeout|    <msecs>
       //             sendxml2e|  <file>[|<step number>]
       //             sendxml2c|  <file>[|<step number>]
       //             delay|      [msecs]
       //             wait<fe/fc>|[code]|[bitR]|[hopByHop]|[applicationId]|[sessionId]|[resultCode]|[msisdn]|[imsi]|[serviceContextId]
       //      wait<fe/fc>-answer|<step number>
-      //      wait<fe/fc>-regexp|<regexp>
+      //      wait<fe/fc>-xml   |<source_file>[|strict]
+      //      wait<fe/fc>-hex   |<source_file>[|strict]
       if(param2 == "") throw anna::RuntimeException("Missing command for test id operation", ANNA_FILE_LOCATION);
 
       // Commands:
-      if (param2 == "timeout") {
+      if (param2 == "description") {
+        if (numParams > 3)
+          throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION);
+        if(param3 == "") throw anna::RuntimeException("Missing description for test case", ANNA_FILE_LOCATION);
+        testManager.getTestCase(id)->setDescription(param3); // creates / reuses
+      }
+      else if (param2 == "ip-limit") {
+        if (numParams > 3)
+          throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION);
+        unsigned int limit = (param3 == "") ? 1 : atoi(param3.c_str());
+        testManager.getTestCase(id)->addIpLimit(limit); // creates / reuses
+      }
+      else if (param2 == "timeout") {
         if (numParams > 3)
           throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION);
         if(param3 == "") throw anna::RuntimeException("Missing milliseconds for 'timeout' command in test id operation", ANNA_FILE_LOCATION);
@@ -2111,9 +2336,9 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons
         int stepNumber = ((param4 != "") ? atoi(param4.c_str()):-1);
 
         if (param2 == "sendxml2e")
-          testManager.getTestCase(id)->addSendxml2e(codecMsg.code(), getOperatedHost(), stepNumber); // creates / reuses
+          testManager.getTestCase(id)->addSendDiameterXml2e(codecMsg.code(), getOperatedHost(), stepNumber); // creates / reuses
         else
-          testManager.getTestCase(id)->addSendxml2c(codecMsg.code(), getOperatedHost(), stepNumber); // creates / reuses
+          testManager.getTestCase(id)->addSendDiameterXml2c(codecMsg.code(), getOperatedHost(), stepNumber); // creates / reuses
       }
       else if (param2 == "delay") {
         if (numParams > 3)
@@ -2127,22 +2352,96 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons
           throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION);
         if (param3 != "" || param4 != "" || param5 != "" || param6 != "" || param7 != "" || param8 != "" || param9 != "" || param10 != "" || param11 != "") {
           bool fromEntity = (param2.substr(4,2) == "fe");
-          testManager.getTestCase(id)->addWait(fromEntity, param3, param4, param5, param6, param7, param8, param9, param10, param11);
+          testManager.getTestCase(id)->addWaitDiameter(fromEntity, param3, param4, param5, param6, param7, param8, param9, param10, param11);
         }
         else {
           throw anna::RuntimeException(anna::functions::asString("Missing condition for '%s' command in test id operation", param2.c_str()), ANNA_FILE_LOCATION);
         }
       }
-      else if ((param2 == "waitfe-regexp")||(param2 == "waitfc-regexp")) {
-        if (numParams > 3)
+      else if ((param2 == "waitfe-hex")||(param2 == "waitfc-hex")) {
+        if (numParams > 4)
           throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION);
-        if (param3 != "") {
-          bool fromEntity = (param2.substr(4,2) == "fe");
-          testManager.getTestCase(id)->addWaitRegexp(fromEntity, param3);
+        if(param3 == "") throw anna::RuntimeException(anna::functions::asString("Missing hex file for '%s' command in test id operation", param2.c_str()), ANNA_FILE_LOCATION);
+
+        // Get DataBlock from file with hex content:
+        if(!getDataBlockFromHexFile(param3, db_aux))
+          throw anna::RuntimeException("Error reading hex content from file provided", ANNA_FILE_LOCATION);
+
+        // Hexadecimal representation read from file:
+        std::string regexp = anna::functions::asHexString(db_aux);
+
+        // optional 'full':
+        if(param4 != "strict") {
+          //// If request, we will ignore sequence data:
+          //if (anna::diameter::codec::functions::requestBit(db_aux))
+            regexp.replace (24, 16, "[0-9A-Fa-f]{16}");
+
+          regexp.insert(0, "^");
+          regexp += "$";
         }
-        else {
-          throw anna::RuntimeException(anna::functions::asString("Missing condition for '%s' command in test id operation", param2.c_str()), ANNA_FILE_LOCATION);
+
+        bool fromEntity = (param2.substr(4,2) == "fe");
+        testManager.getTestCase(id)->addWaitDiameterRegexpHex(fromEntity, regexp);
+      }
+      else if ((param2 == "waitfe-xml")||(param2 == "waitfc-xml")) {
+        if (numParams > 4)
+          throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION);
+        if(param3 == "") throw anna::RuntimeException(anna::functions::asString("Missing xml file for '%s' command in test id operation", param2.c_str()), ANNA_FILE_LOCATION);
+
+        // Get xml content from file:
+        std::string regexp;
+        if(!getContentFromFile(param3, regexp))
+          throw anna::RuntimeException("Error reading xml content from file provided", ANNA_FILE_LOCATION);
+
+        // optional 'full':
+        if(param4 != "strict") {
+
+          // TODO: use this from gcc4.9.0: http://stackoverflow.com/questions/8060025/is-this-c11-regex-error-me-or-the-compiler
+/*
+          std::string s_from = "hop-by-hop-id=\"[0-9]+\" end-to-end-id=\"[0-9]+\"";
+          std::string s_to = s_from;
+          std::string s_from2 = "avp name=\"Origin-State-Id\" data=\"[0-9]+\"";
+          std::string s_to2 = s_from2;
+
+          try {
+            regexp = std::regex_replace (regexp, std::regex(s_from), s_to);
+            regexp = std::regex_replace (regexp, std::regex(s_from2), s_to2);
+          }
+          catch (const std::regex_error& e) {
+            throw anna::RuntimeException(e.what(), ANNA_FILE_LOCATION);
+          }
+
+*/
+          std::string::size_type pos, pos_1, pos_2;
+
+          pos = regexp.find("hop-by-hop-id=", 0u);
+          pos = regexp.find("\"", pos);
+          pos_1 = pos;
+          pos = regexp.find("\"", pos+1);
+          pos_2 = pos;
+          regexp.replace(pos_1 + 1, pos_2 - pos_1 - 1, "[0-9]+");
+
+          pos = regexp.find("end-to-end-id=", 0u);
+          pos = regexp.find("\"", pos);
+          pos_1 = pos;
+          pos = regexp.find("\"", pos+1);
+          pos_2 = pos;
+          regexp.replace(pos_1 + 1, pos_2 - pos_1 - 1, "[0-9]+");
+
+          pos = regexp.find("Origin-State-Id", 0u);
+          pos = regexp.find("\"", pos);
+          pos = regexp.find("\"", pos+1);
+          pos_1 = pos;
+          pos = regexp.find("\"", pos+1);
+          pos_2 = pos;
+          regexp.replace(pos_1 + 1, pos_2 - pos_1 - 1, "[0-9]+");
+
+          //regexp.insert(0, "^");
+          //regexp += "$";
         }
+
+        bool fromEntity = (param2.substr(4,2) == "fe");
+        testManager.getTestCase(id)->addWaitDiameterRegexpXml(fromEntity, regexp);
       }
       else if (param2 == "sh-command") {
         // Allow pipes in command:
@@ -2205,7 +2504,7 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons
     } else if (param1 == "clear") {
       getOperatedServer()->getReactingAnswers()->clear();
     } else if (param1 == "dump") {
-      getOperatedServer()->getReactingAnswers()->dump();
+      getOperatedServer()->getReactingAnswers()->dump("programmed_answer");
     } else {
       codecMsg.loadXML(param1);
       updateOperatedOriginHostWithMessage(codecMsg);
@@ -2231,7 +2530,7 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons
     } else if (param1 == "clear") {
       getOperatedEntity()->getReactingAnswers()->clear();
     } else if (param1 == "dump") {
-      getOperatedEntity()->getReactingAnswers()->dump();
+      getOperatedEntity()->getReactingAnswers()->dump("programmed_answer");
     } else {
       codecMsg.loadXML(param1);
       updateOperatedOriginHostWithMessage(codecMsg);
@@ -2266,7 +2565,8 @@ throw() {
   result->createAttribute("InitialWorkingDirectory", a_initialWorkingDirectory);
   result->createAttribute("SecondsLifeTime", anna::time::functions::lapsedMilliseconds() / 1000);
   // Diameter:
-  for (origin_hosts_it it = a_originHosts.begin(); it != a_originHosts.end(); it++) {
+  anna::diameter::comm::OriginHostManager &ohm = anna::diameter::comm::OriginHostManager::instantiate();
+  for (diameter::comm::origin_hosts_it it = ohm.begin(); it != ohm.end(); it++) {
     it->second->asXML(result);
   }
 
@@ -2279,7 +2579,7 @@ throw() {
   statsAsXML(result);
 
   // Testing: could be heavy if test case reports are enabled
-  TestManager::instantiate().asXML(result);
+  anna::testing::TestManager::instantiate().asXML(result);
 
   return result;
 }