a_clock = NULL;
//a_testPool.clear();
//a_statSummary.clear();
+
+ a_autoResetHard = false;
+
a_currentTestIt = a_testPool.end();
}
-void TestManager::registerSessionId(const std::string &sessionId, const TestCase *testCase) throw(anna::RuntimeException) {
+void TestManager::registerKey1(const std::string &key, const TestCase *testCase) throw(anna::RuntimeException) {
- std::map<std::string /* session id's */, TestCase*>::const_iterator it = a_sessionIdTestCaseMap.find(sessionId);
- if (it != a_sessionIdTestCaseMap.end()) { // found
+ auto it = a_key1TestCaseMap.find(key);
+ if (it != a_key1TestCaseMap.end()) { // found
unsigned int id = it->second->getId();
if (id != testCase->getId()) {
- throw anna::RuntimeException(anna::functions::asString("There is another test case (id = %llu) which registered such sessionId: %s", id, sessionId.c_str()), ANNA_FILE_LOCATION);
+ throw anna::RuntimeException(anna::functions::asString("There is another test case (id = %llu) which registered such key1: %s", id, key.c_str()), ANNA_FILE_LOCATION);
}
}
else {
- a_sessionIdTestCaseMap[sessionId] = const_cast<TestCase*>(testCase);
- LOGDEBUG(anna::Logger::debug(anna::functions::asString("TestManager::registerSessionId for test case (id = %llu): %s)", testCase->getId(), sessionId.c_str()), ANNA_FILE_LOCATION));
+ a_key1TestCaseMap[key] = const_cast<TestCase*>(testCase);
+ LOGDEBUG(anna::Logger::debug(anna::functions::asString("TestManager::registerKey1 for test case (id = %llu): %s)", testCase->getId(), key.c_str()), ANNA_FILE_LOCATION));
}
}
-void TestManager::registerSubscriberId(const std::string &subscriberId, const TestCase *testCase) throw(anna::RuntimeException) {
+void TestManager::registerKey2(const std::string &key, const TestCase *testCase) throw(anna::RuntimeException) {
- std::map<std::string /* subscriber id's */, TestCase*>::const_iterator it = a_subscriberIdTestCaseMap.find(subscriberId);
- if (it != a_subscriberIdTestCaseMap.end()) { // found
+ auto it = a_key2TestCaseMap.find(key);
+ if (it != a_key2TestCaseMap.end()) { // found
unsigned int id = it->second->getId();
if (id != testCase->getId()) {
- throw anna::RuntimeException(anna::functions::asString("There is another test case (id = %llu) which registered such subscriberId: %s", id, subscriberId.c_str()), ANNA_FILE_LOCATION);
+ throw anna::RuntimeException(anna::functions::asString("There is another test case (id = %llu) which registered such key2: %s", id, key.c_str()), ANNA_FILE_LOCATION);
}
}
else {
- a_subscriberIdTestCaseMap[subscriberId] = const_cast<TestCase*>(testCase);
- LOGDEBUG(anna::Logger::debug(anna::functions::asString("TestManager::registerSubscriberId for test case (id = %llu): %s)", testCase->getId(), subscriberId.c_str()), ANNA_FILE_LOCATION));
+ a_key2TestCaseMap[key] = const_cast<TestCase*>(testCase);
+ LOGDEBUG(anna::Logger::debug(anna::functions::asString("TestManager::registerKey2 for test case (id = %llu): %s)", testCase->getId(), key.c_str()), ANNA_FILE_LOCATION));
}
}
// TODO: stop the possible command threads or there will be a core dump
a_testPool.clear();
- a_sessionIdTestCaseMap.clear();
- a_subscriberIdTestCaseMap.clear();
+ a_key1TestCaseMap.clear();
+ a_key2TestCaseMap.clear();
a_currentTestIt = a_testPool.end();
a_poolCycle = 1;
configureTTPS(0); // stop
if (it->second->reset(hard))
result = true;
}
- //a_sessionIdTestCaseMap.clear();
- //a_subscriberIdTestCaseMap.clear();
+ //a_key1TestCaseMap.clear();
+ //a_key2TestCaseMap.clear();
return result;
}
}
}
- // Soft reset to initialize already finished (in previous cycle) test cases:
- a_currentTestIt->second->reset(false);
+ // Hard reset or soft reset to initialize already finished (in previous cycle) test cases:
+ a_currentTestIt->second->reset(a_autoResetHard);
// Process test case:
LOGDEBUG(anna::Logger::debug(anna::functions::asString("Processing test case id = %llu, currently '%s' state", a_currentTestIt->first, TestCase::asText(a_currentTestIt->second->getState())), ANNA_FILE_LOCATION));
}
}
-TestCase *TestManager::getTestCaseFromSessionId(const anna::DataBlock &message, std::string &sessionId) throw() {
+TestCase *TestManager::getDiameterTestCaseFromSessionId(const anna::DataBlock &message, std::string &sessionId) throw() {
try {
sessionId = anna::diameter::helpers::base::functions::getSessionId(message);
}
LOGDEBUG(anna::Logger::debug("Cannot get the Session-Id from received DataBlock in order to identify the Test Case", ANNA_FILE_LOCATION));
return NULL;
}
- std::map<std::string /* session id's */, TestCase*>::const_iterator sessionIdIt = a_sessionIdTestCaseMap.find(sessionId);
- if (sessionIdIt != a_sessionIdTestCaseMap.end())
+ auto sessionIdIt = a_key1TestCaseMap.find(sessionId);
+ if (sessionIdIt != a_key1TestCaseMap.end())
return sessionIdIt->second;
LOGDEBUG(anna::Logger::debug(anna::functions::asString("Cannot identify the Test Case for received Session-Id: %s", sessionId.c_str()), ANNA_FILE_LOCATION));
return NULL;
}
-TestCase *TestManager::getTestCaseFromSubscriberId(const anna::DataBlock &message, std::string &subscriberId) throw() {
+TestCase *TestManager::getDiameterTestCaseFromSubscriberId(const anna::DataBlock &message, std::string &subscriberId) throw() {
try {
subscriberId = anna::diameter::helpers::dcca::functions::getSubscriptionIdData(message, anna::diameter::helpers::dcca::AVPVALUES__Subscription_Id_Type::END_USER_E164);
if (subscriberId == "") // try with IMSI
LOGDEBUG(anna::Logger::debug("Cannot get the Subscriber-Id from received DataBlock in order to identify the Test Case", ANNA_FILE_LOCATION));
return NULL;
}
- std::map<std::string /* subscriber id's */, TestCase*>::const_iterator subscriberIdIt = a_subscriberIdTestCaseMap.find(subscriberId);
- if (subscriberIdIt != a_subscriberIdTestCaseMap.end())
+ auto subscriberIdIt = a_key2TestCaseMap.find(subscriberId);
+ if (subscriberIdIt != a_key2TestCaseMap.end())
return subscriberIdIt->second;
LOGDEBUG(anna::Logger::debug(anna::functions::asString("Cannot identify the Test Case for received Subscriber-Id: %s", subscriberId.c_str()), ANNA_FILE_LOCATION));
return NULL;
}
-void TestManager::receiveMessage(const anna::DataBlock &message, const anna::diameter::comm::ClientSession *clientSession) throw(anna::RuntimeException) {
+void TestManager::receiveDiameterMessage(const anna::DataBlock &message, const anna::diameter::comm::ClientSession *clientSession) throw(anna::RuntimeException) {
// Testing disabled:
if (!tests()) return;
// Identify the test case:
std::string sessionId, subscriberId;
TestCase *tc;
- tc = getTestCaseFromSessionId(message, sessionId);
+ tc = getDiameterTestCaseFromSessionId(message, sessionId);
if (!tc)
- tc = getTestCaseFromSubscriberId(message, subscriberId);
+ tc = getDiameterTestCaseFromSubscriberId(message, subscriberId);
if (!tc) {
LOGWARNING(anna::Logger::warning(anna::comm::functions::asText("Cannot identify the Test Case for the message received from server: ", message), ANNA_FILE_LOCATION)); // this should not appear
return;
// Work with Test case:
TestStepWait *tsw = tc->searchNextWaitConditionFulfilled(message, true /* comes from entity */);
if (!tsw) { // store as 'uncovered'
- std::string hint = "Uncovered condition for received message from entity over Session-Id '"; hint += sessionId; hint += "':";
+ std::string hint = "Uncovered condition for received message from entity over Session-Id '"; hint += sessionId; hint += "'; ";
try {
static anna::diameter::codec::Message codecMsg;
codecMsg.decode(message);
- hint += "\n"; hint += codecMsg.asXMLString();
+ hint += "HEX Message: '"; hint += anna::functions::asHexString(message);
+ hint += "'; XML Message:\n"; hint += codecMsg.asXMLString();
}
catch (anna::RuntimeException &ex) {
ex.trace();
- hint += "\n"; hint += ex.asString();
+ hint += ex.asString();
}
- hint += "\n"; hint += clientSession->asString();
+ hint += "\nClient Session: "; hint += clientSession->asString();
tc->addDebugSummaryHint(hint);
}
}
}
-void TestManager::receiveMessage(const anna::DataBlock &message, const anna::diameter::comm::ServerSession *serverSession) throw(anna::RuntimeException) {
+void TestManager::receiveDiameterMessage(const anna::DataBlock &message, const anna::diameter::comm::ServerSession *serverSession) throw(anna::RuntimeException) {
// Testing disabled:
if (!tests()) return;
// Identify the test case:
std::string sessionId, subscriberId;
TestCase *tc;
- tc = getTestCaseFromSessionId(message, sessionId);
+ tc = getDiameterTestCaseFromSessionId(message, sessionId);
if (!tc)
- tc = getTestCaseFromSubscriberId(message, subscriberId);
+ tc = getDiameterTestCaseFromSubscriberId(message, subscriberId);
if (!tc) {
LOGWARNING(anna::Logger::warning(anna::comm::functions::asText("Cannot identify the Test Case for the message received from client: ", message), ANNA_FILE_LOCATION)); // this should not appear
return;
// Work with Test case:
TestStepWait *tsw = tc->searchNextWaitConditionFulfilled(message, false /* comes from client */);
if (!tsw) { // store as 'uncovered'
- std::string hint = "Uncovered condition for received message from client over Session-Id '"; hint += sessionId; hint += "':";
+ std::string hint = "Uncovered condition for received message from client over Session-Id '"; hint += sessionId; hint += "'; ";
try {
static anna::diameter::codec::Message codecMsg;
codecMsg.decode(message);
- hint += "\n"; hint += codecMsg.asXMLString();
+ hint += "HEX Message: '"; hint += anna::functions::asHexString(message);
+ hint += "'; XML Message:\n"; hint += codecMsg.asXMLString();
}
catch (anna::RuntimeException &ex) {
ex.trace();
- hint += "\n"; hint += ex.asString();
+ hint += ex.asString();
}
- hint += "\n"; hint += serverSession->asString();
+ hint += "\nServer Session: "; hint += serverSession->asString();
tc->addDebugSummaryHint(hint);
}
result->createAttribute("DumpFailedReports", (a_dumpFailedReports ? "yes":"no"));
result->createAttribute("DumpSuccessReports", (a_dumpSuccessReports ? "yes":"no"));
result->createAttribute("DumpHexMessages", (a_dumpHexMessages ? "yes":"no"));
+ result->createAttribute("AutoResetHard", (a_autoResetHard ? "yes":"no"));
result->createAttribute("ReportsDirectory", a_reportsDirectory);
if (a_clock) {
result->createAttribute("AsynchronousSendings", a_synchronousAmount);