X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=example%2Fdiameter%2Flauncher%2Ftesting%2FTestCase.cpp;h=087e29bb0de31fed7d7fcb412f8d897c7ba7668e;hb=51a6c4b326153804233788bd8fda4966052d4288;hp=0b26170aebedbef8dfab069a1415a3360e8af8ff;hpb=38f67dae313f5b4b988a11804cfee52f74e16e33;p=anna.git diff --git a/example/diameter/launcher/testing/TestCase.cpp b/example/diameter/launcher/testing/TestCase.cpp index 0b26170..087e29b 100644 --- a/example/diameter/launcher/testing/TestCase.cpp +++ b/example/diameter/launcher/testing/TestCase.cpp @@ -132,7 +132,8 @@ void TestCase::setState(const State::_v &state) throw() { if (isFinished()) { - if (!testManager.getDumpReports()) return; + if ((getState() == State::Failed) && (!testManager.getDumpFailedReports())) return; + if ((getState() == State::Success) && (!testManager.getDumpSuccessReports())) return; // report file name: cycle-.testcase-.xml // FORMAT: We tabulate the cycle and test case in order to ease ordering of files by mean ls: @@ -222,16 +223,18 @@ bool TestCase::reset(bool hard) throw() { } void TestCase::assertInitialized() const throw(anna::RuntimeException) { - if (a_state != State::Initialized) - throw anna::RuntimeException(anna::functions::asString("Cannot program anymore. The test case %llu was started. You must reset it to append new steps.", a_id), ANNA_FILE_LOCATION); + if (isFinished()) + throw anna::RuntimeException(anna::functions::asString("Cannot program anymore. The test case %llu has finished. You must reset it to append new steps (or do it during execution, which is also allowed).", a_id), ANNA_FILE_LOCATION); } void TestCase::assertMessage(const anna::DataBlock &db, bool toEntity) throw(anna::RuntimeException) { bool isRequest = anna::diameter::codec::functions::isRequest(db); - bool registerSessionId = ((isRequest && toEntity) || (!isRequest && !toEntity) /* (*) */); - // (*) we register answers Session-Id assuming that we will know the Session-Id values created by the client (OCS) - // This is another solution for TODO(***) regarding diameter server testing. No tsure about the final implementation. + bool registerKeys = ((isRequest && toEntity) || (!isRequest && !toEntity) /* (*) */); + // (*) we register answers Session-Id "assuming" that we will know the Session-Id values created by the client. + // This is another solution regarding diameter server testing. No sure about the final implementation. + // We will help registering also subscriber data, because certain messages (i.e. SLR) coming from clients could + // have specific Session-Id value (unknown at test programming), and normally are identified by subscriber. // Check hop-by-hop: if (isRequest) { @@ -241,15 +244,17 @@ void TestCase::assertMessage(const anna::DataBlock &db, bool toEntity) throw(ann a_hopByHops[hbh] = NULL; // may be assigned to a wait condition } - if (registerSessionId) { - try { - std::string sid = anna::diameter::helpers::base::functions::getSessionId(db); - TestManager::instantiate().registerSessionId(sid, this); - } - catch (anna::RuntimeException &ex) { - //ex.trace(); - // if we don't have session-id ... don't worry - } + if (registerKeys) { + TestManager &testManager = TestManager::instantiate(); + testManager.registerSessionId(anna::diameter::helpers::base::functions::getSessionId(db), this); + + + std::string subscriberId = anna::diameter::helpers::dcca::functions::getSubscriptionIdData(db, anna::diameter::helpers::dcca::AVPVALUES__Subscription_Id_Type::END_USER_E164); + if (subscriberId == "") // try with IMSI + subscriberId = anna::diameter::helpers::dcca::functions::getSubscriptionIdData(db, anna::diameter::helpers::dcca::AVPVALUES__Subscription_Id_Type::END_USER_IMSI); + + if (subscriberId != "") + testManager.registerSubscriberId(subscriberId, this); } } @@ -260,7 +265,7 @@ void TestCase::addTimeout(const anna::Millisecond &timeout) throw(anna::RuntimeE addStep(step); } -void TestCase::addSendxml2e(const anna::DataBlock &db, RealmNode *realm, int stepNumber) throw(anna::RuntimeException) { +void TestCase::addSendxml2e(const anna::DataBlock &db, OriginHost *host, int stepNumber) throw(anna::RuntimeException) { assertInitialized(); assertMessage(db, true /* to entity */); @@ -280,18 +285,18 @@ void TestCase::addSendxml2e(const anna::DataBlock &db, RealmNode *realm, int ste TestStepSendxml2e *step = new TestStepSendxml2e(this); step->setMsgDataBlock(db); - step->setRealmNode(realm); + step->setOriginHost(host); step->setWaitForRequestStepNumber(stepNumber); // -1 means, no reference addStep(step); } -void TestCase::addSendxml2c(const anna::DataBlock &db, RealmNode *realm, int stepNumber) throw(anna::RuntimeException) { +void TestCase::addSendxml2c(const anna::DataBlock &db, OriginHost *host, int stepNumber) throw(anna::RuntimeException) { assertInitialized(); assertMessage(db, false /* to client */); TestStepSendxml2c *step = new TestStepSendxml2c(this); step->setMsgDataBlock(db); - step->setRealmNode(realm); + step->setOriginHost(host); addStep(step); } @@ -349,9 +354,9 @@ void TestCase::addWait(bool fromEntity, if (!step) step = new TestStepWait(this); step->setCondition(fromEntity, code, bitR, usedHopByHop, applicationId, sessionId, resultCode, msisdn, imsi, serviceContextId); - LOGWARNING( + LOGINFORMATION( if (hasSameCondition(step->getCondition())) - anna::Logger::warning(anna::functions::asString("The same wait condition has already been programmed in this test case (%llu). Are you sure ?", a_id), ANNA_FILE_LOCATION); + anna::Logger::information(anna::functions::asString("The same wait condition has already been programmed in this test case (%llu). Are you sure ?", a_id), ANNA_FILE_LOCATION); ); addStep(step); @@ -363,9 +368,9 @@ void TestCase::addWaitRegexp(bool fromEntity, const std::string ®exp) throw(a TestStepWait *step = new TestStepWait(this); step->setCondition(fromEntity, regexp); - LOGWARNING( + LOGINFORMATION( if (hasSameCondition(step->getCondition())) - anna::Logger::warning(anna::functions::asString("The same wait condition has already been programmed in this test case (%llu). Are you sure ?", a_id), ANNA_FILE_LOCATION); + anna::Logger::information(anna::functions::asString("The same wait condition has already been programmed in this test case (%llu). Are you sure ?", a_id), ANNA_FILE_LOCATION); ); addStep(step);