X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=include%2Fanna%2Ftesting%2FTestManager.hpp;h=916177a2dd72cc68797aaa7d66a4d39d88004358;hb=5a6cba5fde2b2f538a7515f8293cc0a8d9589dfa;hp=a1cf8eddefd13c17f3006eab0c21b1d14881936d;hpb=d723d5bf571eb48c641b092058eaa38bb6c4fcc8;p=anna.git diff --git a/include/anna/testing/TestManager.hpp b/include/anna/testing/TestManager.hpp index a1cf8ed..916177a 100644 --- a/include/anna/testing/TestManager.hpp +++ b/include/anna/testing/TestManager.hpp @@ -61,10 +61,16 @@ class TestManager : public anna::timex::TimeEventObserver, public anna::Singleto 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(); + void newTCState(const TestCase::State::_v beginState, const TestCase::State::_v endState) ; + void clear() ; + unsigned int getInitializedCount() const { return a_initializedTcs; } + unsigned int getInProgressCount() const { return a_inprogressTcs; } + unsigned int getFailedCount() const { return a_failedTcs; } + unsigned int getSuccessCount() const { return a_sucessTcs; } + unsigned int getFinishedCount() const { return a_sucessTcs + a_failedTcs; } + unsigned int getTotal() const { return (a_initializedTcs + a_inprogressTcs + a_failedTcs + a_sucessTcs); } + + anna::xml::Node* asXML(anna::xml::Node* parent) const ; }; @@ -77,6 +83,7 @@ class TestManager : public anna::timex::TimeEventObserver, public anna::Singleto std::string a_reportsDirectory; bool a_dumpInitializedReports, a_dumpInProgressReports, a_dumpFailedReports, a_dumpSuccessReports; bool a_dumpHexMessages; + bool a_dumpStdout; // Pool of test cases test_pool_t a_testPool; @@ -84,98 +91,115 @@ class TestManager : public anna::timex::TimeEventObserver, public anna::Singleto 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 + bool a_autoResetHard; // automatic reset on next cycle (soft by default, false) // Test clock int a_synchronousAmount; TestClock *a_clock; - bool tick() throw(); - bool nextTestCase() throw(); + bool tick() ; + bool nextTestCase() ; // 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. - + // Test case identifiers: key1 (strong); key2 (alternative) + std::map a_key1TestCaseMap; + std::map a_key2TestCaseMap; + // Diameter shall use: key1 -> sessionId, key2 -> subscriberId + // StatSummary a_statSummary; // general statistics TestManager(); TestManager(const TestManager&); + virtual ~TestManager() {;} - TestTimer* createTimer(TestCaseStep*, const anna::Millisecond &, const TestTimer::Type::_v type) throw(anna::RuntimeException); - void cancelTimer(TestTimer*) throw(); - void release(anna::timex::TimeEvent*) throw(); + TestTimer* createTimer(TestCaseStep*, const anna::Millisecond &, const TestTimer::Type::_v type) noexcept(false); + void cancelTimer(TestTimer*) ; + void release(anna::timex::TimeEvent*) ; 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); + void registerKey1(const std::string &key, const TestCase *testCase) noexcept(false); + void registerKey2(const std::string &key, const TestCase *testCase) noexcept(false); - int tests() const throw() { return a_testPool.size(); } - void setTimerController(anna::timex::Engine *engine) throw() { a_timeController = engine; } + int tests() const { return a_testPool.size(); } + void setTimerController(anna::timex::Engine *engine) { a_timeController = engine; } - void setReportsDirectory(const std::string &rd) throw() { a_reportsDirectory = rd; } - const std::string &getReportsDirectory() const throw() { return a_reportsDirectory; } + void setReportsDirectory(const std::string &rd) { a_reportsDirectory = rd; } + const std::string &getReportsDirectory() const { return a_reportsDirectory; } - void setDumpHex(bool dh) throw() { a_dumpHexMessages = dh; } - bool getDumpHex() const throw() { return a_dumpHexMessages; } + void setDumpHex(bool dh) { a_dumpHexMessages = dh; } + bool getDumpHex() const { return a_dumpHexMessages; } + void setDumpStdout(bool ds) { a_dumpStdout = ds; } + bool getDumpStdout() const { return a_dumpStdout; } - 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() { + void setDumpInitializedReports(bool enable) { a_dumpInitializedReports = enable; } + void setDumpInProgressReports(bool enable) { a_dumpInProgressReports = enable; } + void setDumpFailedReports(bool enable) { a_dumpFailedReports = enable; } + void setDumpSuccessReports(bool enable) { a_dumpSuccessReports = enable; } + void setDumpAllReports(bool enable) { 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; } + bool getDumpInitializedReports() const { return a_dumpInitializedReports; } + bool getDumpInProgressReports() const { return a_dumpInProgressReports; } + bool getDumpFailedReports() const { return a_dumpFailedReports; } + bool getDumpSuccessReports() const { 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. The first call to this method will start the time trigger system and check for new test cases to be launched. - bool configureTTPS(int testTicksPerSecond) throw(); + bool configureTTPS(int testTicksPerSecond) ; + + bool clearPool(std::string &result) ; + bool resetPool(bool hard /* hard reset includes in-progress test cases */) ; + void setPoolRepeats(int repeats) { a_poolRepeats = repeats; } + int getPoolRepeats() const { return a_poolRepeats; } + int getPoolCycle() const { return a_poolCycle; } + + bool getAutoResetHard() const { return a_autoResetHard; } + void setAutoResetHard(bool hard = true) { a_autoResetHard = hard; } + - bool clearPool() throw(); - bool resetPool(bool hard /* hard reset includes in-progress test cases */) throw(); - 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 { return a_statSummary.getInProgressCount(); } + unsigned int getInitializedCount() const { return a_statSummary.getInitializedCount(); } + unsigned int getFinishedCount() const { return a_statSummary.getFinishedCount(); } + unsigned int getInProgressLimit() const { return a_inProgressLimit; } + void setInProgressLimit(unsigned int limit) { a_inProgressLimit = limit; } // -1 = UINT_MAX (no limit) - 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) + bool gotoTestCase(unsigned int id) ; + bool runTestCase(unsigned int id) ; + TestCase *findTestCase(unsigned int id) const ; // id = -1 provides current test case triggered + TestCase *getTestCase(unsigned int id, const std::string &description = "") ; // creates/reuses a test case - bool gotoTestCase(unsigned int id) throw(); - TestCase *findTestCase(unsigned int id) const throw(); // id = -1 provides current test case triggered - TestCase *getTestCase(unsigned int id) throw(); // creates/reuses a test case + // Diameter-specific + TestCase *getDiameterTestCaseFromSessionId(const anna::DataBlock &message, std::string &sessionId) ; + TestCase *getDiameterTestCaseFromSubscriberId(const anna::DataBlock &message, std::string &subscriberId) ; + void receiveDiameterMessage(const anna::DataBlock &message, const anna::diameter::comm::ClientSession *clientSession) noexcept(false); + void receiveDiameterMessage(const anna::DataBlock &message, const anna::diameter::comm::ServerSession *serverSession) noexcept(false); - // Main logic - TestCase *getTestCaseFromSessionId(const anna::DataBlock &message, std::string &sessionId) throw(); - TestCase *getTestCaseFromSubscriberId(const anna::DataBlock &message, std::string &subscriberId) 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); + // Non-trasactional (kafka) + // + // - bool execTestCases(int sync_amount) throw(); + bool execTestCases(int sync_amount) ; - anna::xml::Node* asXML(anna::xml::Node* parent) const throw(); - std::string asXMLString() const throw(); + anna::xml::Node* asXML(anna::xml::Node* parent) const ; + anna::xml::Node* junitAsXML(anna::xml::Node* parent) const ; + std::string asXMLString() const ; + std::string junitAsXMLString() const ; + std::string summaryCounts() const ; + std::string summaryStates() const ; // stats - void tcsStateStats(const TestCase::State::_v beginState, const TestCase::State::_v endState) throw() { + void tcsStateStats(const TestCase::State::_v beginState, const TestCase::State::_v endState) { a_statSummary.newTCState(beginState, endState); }