X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=example%2Fdiameter%2Flauncher%2Ftesting%2FTestManager.hpp;h=d1cc1c184d3fe369840458400d81d2ce17b3eb9e;hb=51a6c4b326153804233788bd8fda4966052d4288;hp=614cb1e2031aaad7dc9b0608d8f68a64ead65180;hpb=2921c651c9945cefec0715167201596aaa079e8d;p=anna.git diff --git a/example/diameter/launcher/testing/TestManager.hpp b/example/diameter/launcher/testing/TestManager.hpp index 614cb1e..d1cc1c1 100644 --- a/example/diameter/launcher/testing/TestManager.hpp +++ b/example/diameter/launcher/testing/TestManager.hpp @@ -19,6 +19,7 @@ // Process #include +#include namespace anna { @@ -39,6 +40,8 @@ namespace anna { class TestClock; class TestCase; class TestCaseStep; +class OriginHost; + typedef std::map test_pool_t; typedef std::map::const_iterator test_pool_it; @@ -49,33 +52,61 @@ typedef std::map::iterator test_pool Timer Manager for testing system */ class TestManager : public anna::timex::TimeEventObserver, public anna::Singleton { + + // Statistics summary: + class StatSummary { + + unsigned int a_initializedTcs; + unsigned int a_inprogressTcs; + unsigned int a_failedTcs; + unsigned int a_sucessTcs; + + public: + StatSummary() { clear(); } + 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 timer_container; anna::timex::Engine* a_timeController; // reports std::string a_reportsDirectory; - bool a_dumpReports; + bool a_dumpInitializedReports, a_dumpInProgressReports, a_dumpFailedReports, a_dumpSuccessReports; + bool a_dumpHexMessages; // Pool of test cases test_pool_t a_testPool; test_pool_it a_currentTestIt; - bool a_poolRepeat; // repeat pool when finish - unsigned int a_inProgressCount; + int a_poolRepeats; // repeat pool N times + int a_poolCycle; // current cycle, from 1 to N unsigned int a_inProgressLimit; // limit load to have this value // Test clock int a_synchronousAmount; TestClock *a_clock; bool tick() throw(); + bool execTestCases(int sync_amount) throw(); bool nextTestCase() throw(); // Test timers timer_container a_timers; + // Test case identifiers: // Session-Id's std::map 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. + // Subscriber's + std::map a_subscriberIdTestCaseMap; // stores used Subscriber-Id values within a test case. + + + + StatSummary a_statSummary; // general statistics TestManager(); @@ -85,9 +116,11 @@ 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); + void registerSubscriberId(const std::string &subscriberId, const TestCase *testCase) throw(anna::RuntimeException); int tests() const throw() { return a_testPool.size(); } void setTimerController(anna::timex::Engine *engine) throw() { a_timeController = engine; } @@ -95,8 +128,25 @@ class TestManager : public anna::timex::TimeEventObserver, public anna::Singleto void setReportsDirectory(const std::string &rd) throw() { a_reportsDirectory = rd; } const std::string &getReportsDirectory() const throw() { return a_reportsDirectory; } - void setDumpReports(bool dr) throw() { a_dumpReports = dr; } - bool getDumpReports() const throw() { return a_dumpReports; } + void setDumpHex(bool dh) throw() { a_dumpHexMessages = dh; } + bool getDumpHex() const throw() { return a_dumpHexMessages; } + + + void setDumpInitializedReports(bool enable) throw() { a_dumpInitializedReports = enable; } + void setDumpInProgressReports(bool enable) throw() { a_dumpInProgressReports = enable; } + void setDumpFailedReports(bool enable) throw() { a_dumpFailedReports = enable; } + void setDumpSuccessReports(bool enable) throw() { a_dumpSuccessReports = enable; } + void setDumpAllReports(bool enable) throw() { + setDumpInitializedReports(enable); + setDumpInProgressReports(enable); + setDumpFailedReports(enable); + setDumpSuccessReports(enable); + } + + bool getDumpInitializedReports() const throw() { return a_dumpInitializedReports; } + bool getDumpInProgressReports() const throw() { return a_dumpInProgressReports; } + bool getDumpFailedReports() const throw() { return a_dumpFailedReports; } + bool getDumpSuccessReports() const throw() { return a_dumpSuccessReports; } // Helper to calculate time interval and synchronous amount of execution tests to guarantee the input rate (tests per second) // through the time manager which has a minimum resolution of ADML minimum resolution. The first call to this method will @@ -105,10 +155,11 @@ class TestManager : public anna::timex::TimeEventObserver, public anna::Singleto bool clearPool() throw(); bool resetPool(bool hard /* hard reset includes in-progress test cases */) throw(); - void setPoolRepeat(bool repeat) throw() { a_poolRepeat = repeat; } - bool getPoolRepeat() const throw() { return a_poolRepeat; } - unsigned int getInProgressCount() const throw() { return a_inProgressCount; } - void setInProgressCountDelta(unsigned int delta) throw() { a_inProgressCount += delta; } + void setPoolRepeats(int repeats) throw() { a_poolRepeats = repeats; } + int getPoolRepeats() const throw() { return a_poolRepeats; } + int getPoolCycle() const throw() { return a_poolCycle; } + + 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) @@ -118,17 +169,24 @@ class TestManager : public anna::timex::TimeEventObserver, public anna::Singleto // Main logic TestCase *getTestCaseFromSessionId(const anna::DataBlock &message, std::string &sessionId) throw(); - void receiveMessage(const anna::DataBlock &message, const anna::diameter::comm::ClientSession *clientSession) throw(anna::RuntimeException); - void receiveMessage(const anna::DataBlock &message, const anna::diameter::comm::ServerSession *serverSession) throw(anna::RuntimeException); + TestCase *getTestCaseFromSubscriberId(const anna::DataBlock &message, std::string &subscriberId) throw(); + void receiveMessage(const anna::DataBlock &message, OriginHost *host, const anna::diameter::comm::ClientSession *clientSession) throw(anna::RuntimeException); + void receiveMessage(const anna::DataBlock &message, OriginHost *host, const anna::diameter::comm::ServerSession *serverSession) throw(anna::RuntimeException); 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 ; friend class TestStepTimeout; // createTimer friend class TestStepDelay; // createTimer friend class TestClock; // tick + friend class Launcher; // tick }; #endif