Basic stat summary for testcases
[anna.git] / example / diameter / launcher / testing / TestManager.hpp
index 6a292e4..2f61501 100644 (file)
@@ -19,6 +19,7 @@
 
 // Process
 #include <TestTimer.hpp>
+#include <TestCase.hpp>
 
 
 namespace anna {
@@ -51,6 +52,24 @@ typedef std::map<unsigned int /* test case id */, TestCase*>::iterator test_pool
    Timer Manager for testing system
 */
 class TestManager : public anna::timex::TimeEventObserver, public anna::Singleton <TestManager> {
+
+  // Statistics summary:
+  class StatSummary {
+
+    unsigned int a_initializedTcs;
+    unsigned int a_inprogressTcs;
+    unsigned int a_failedTcs;
+    unsigned int a_sucessTcs;
+
+  public:
+    void newTCState(const TestCase::State::_v beginState, const TestCase::State::_v endState) throw();
+    void clear() throw();
+    unsigned int getInProgressCount() const throw() { return a_inprogressTcs; }
+    anna::xml::Node* asXML(anna::xml::Node* parent) const throw();
+  };
+
+
+
   typedef anna::Recycler <TestTimer> timer_container;
 
   anna::timex::Engine* a_timeController;
@@ -65,7 +84,6 @@ class TestManager : public anna::timex::TimeEventObserver, public anna::Singleto
   test_pool_it a_currentTestIt;
   int a_poolRepeats; // repeat pool N times
   int a_poolCycle; // current cycle, from 1 to N
-  unsigned int a_inProgressCount;
   unsigned int a_inProgressLimit; // limit load to have this value
 
   // Test clock
@@ -81,6 +99,8 @@ class TestManager : public anna::timex::TimeEventObserver, public anna::Singleto
   std::map<std::string /* session id's */, TestCase*> a_sessionIdTestCaseMap; // stores used Session-Id values within a test case.
                                                                               // No other can use them, but a test case could use more than one.
 
+  StatSummary a_statSummary; // general statistics
+
 
   TestManager();
   TestManager(const TestManager&);
@@ -89,6 +109,7 @@ class TestManager : public anna::timex::TimeEventObserver, public anna::Singleto
   void cancelTimer(TestTimer*) throw();
   void release(anna::timex::TimeEvent*) throw();
 
+
   public:
 
     void registerSessionId(const std::string &sessionId, const TestCase *testCase) throw(anna::RuntimeException);
@@ -115,8 +136,7 @@ class TestManager : public anna::timex::TimeEventObserver, public anna::Singleto
     int getPoolRepeats() const throw() { return a_poolRepeats; }
     int getPoolCycle() const throw() { return a_poolCycle; }
 
-    unsigned int getInProgressCount() const throw() { return a_inProgressCount; }
-    void setInProgressCountDelta(unsigned int delta) throw() { a_inProgressCount += delta; }
+    unsigned int getInProgressCount() const throw() { return a_statSummary.getInProgressCount(); }
     unsigned int getInProgressLimit() const throw() { return a_inProgressLimit; }
     void setInProgressLimit(unsigned int limit) throw() { a_inProgressLimit = limit; } // 0 = UINT_MAX (no limit)
 
@@ -132,6 +152,11 @@ class TestManager : public anna::timex::TimeEventObserver, public anna::Singleto
     anna::xml::Node* asXML(anna::xml::Node* parent) const throw();
     std::string asXMLString() const throw();
 
+    // stats
+    void tcsStateStats(const TestCase::State::_v beginState, const TestCase::State::_v endState) throw() {
+      a_statSummary.newTCState(beginState, endState);
+    }
+
 
   friend class anna::Singleton <TestManager>;
   friend class TestStepTimeout; // createTimer