X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=example%2Fdiameter%2Flauncher%2FLauncher.cpp;h=67343fffcaf47912e96146eb9c9540a1783bbfa9;hb=122ba50424fc9f659834d6186d1279a31e73c096;hp=a6e5ab9ddb46e6e9ef2ff54002a5c7c0f7993c91;hpb=9ec374517954efc1b34694c7ed801231f035d7f7;p=anna.git diff --git a/example/diameter/launcher/Launcher.cpp b/example/diameter/launcher/Launcher.cpp index a6e5ab9..67343ff 100644 --- a/example/diameter/launcher/Launcher.cpp +++ b/example/diameter/launcher/Launcher.cpp @@ -27,7 +27,7 @@ // Process #include -#include +#include #include #include #include @@ -59,14 +59,13 @@ const char *ServicesDTD = "\ -->\n\ \n\ \n\ -\n\ +\n\ "; - result += "\n "; + result += "\n "; result += "\n"; result += "\n"; result += "\nServer configuration:"; @@ -908,13 +907,13 @@ std::string Launcher::help() const throw() { result += "\n "; result += "\n"; result += "\n "; - result += "\n "; + result += "\n "; result += "\n"; result += "\n"; result += "\nIf you act as a proxy or a translation agent, you need to combine both former setups, and probably"; result += "\n will need to program the answers to be replied through the operations interface. To balance the"; result += "\n traffic at your client side you shall use '--balance' and '--sessionBasedModelsClientSocketSelection'"; - result += "\n arguments in order to define the balancing behaviour. To make hybrid setups you only must mix the realms:"; + result += "\n arguments in order to define the balancing behaviour. To make hybrid setups you only must mix the nodes:"; result += "\n"; result += "\nClient and server configuration:"; result += "\n"; @@ -925,8 +924,8 @@ std::string Launcher::help() const throw() { result += "\n "; result += "\n"; result += "\n "; - result += "\n "; - result += "\n "; + result += "\n "; + result += "\n "; result += "\n"; result += "\n"; result += "\n"; @@ -948,7 +947,7 @@ std::string Launcher::help() const throw() { result += "\n"; result += "\n--------------------------------------------------------------------------------------- Node management"; result += "\n"; - result += "\nnode[|] Selects a context working node by mean a registered name."; + result += "\nnode[|] Selects a context working node by mean a registered name (origin-host)."; result += "\n All the subsequent operations will be forced to work with"; result += "\n this node, which makes possible some rare scenarios like"; result += "\n sending unexpected messages on remote peers. This is also"; @@ -958,12 +957,12 @@ std::string Launcher::help() const throw() { result += "\n"; result += "\nnode_auto Returns to the default behaviour (smart node selection)."; result += "\n Depending on the operation, this could imply a global"; - result += "\n action scope, affecting to all the registered realms."; + result += "\n action scope, affecting to all the registered hosts."; result += "\n This should be the normal configuration. Take into"; result += "\n account that if you fix the working node, this could"; result += "\n affect to things like test programming: communication"; result += "\n resources will override those which would be inferred"; - result += "\n from programmed messages Origin-Realm avps."; + result += "\n from programmed messages Origin-Host avps."; result += "\n"; result += "\n------------------------------------------------------------------------------------ Parsing operations"; result += "\n"; @@ -979,7 +978,7 @@ std::string Launcher::help() const throw() { result += "\n line '--services' parameter was used or not. Those services which"; result += "\n are not correctly loaded will be ignored to keep the process alive."; result += "\n If you need to load services as deltas, you must firstly load the"; - result += "\n diameter base dictionary with stack id 0, because all the realms"; + result += "\n diameter base dictionary with stack id 0, because all the nodes"; result += "\n will use this dictionary to encode/decode base protocol messages"; result += "\n managed by the communication engine."; result += "\n"; @@ -992,7 +991,7 @@ std::string Launcher::help() const throw() { result += "\n performance measurement. Context data can be written at"; result += "\n '/var/tmp/anna.context.' by mean 'kill -10 '."; result += "\n or sending operation 'context|[target file]'."; - result += "\n This operation applies over all the registered realm nodes"; + result += "\n This operation applies over all the registered host nodes"; result += "\n except if one specific working node has been set."; result += "\nforceCountersRecord Forces dump to file the current counters of the process."; result += "\nshow-oam Dumps current counters of the process. This is also done at"; @@ -1081,10 +1080,10 @@ std::string Launcher::help() const throw() { result += "\n"; result += "\n------------------------------------------------------------------------------------------- Burst tests"; result += "\n"; - result += "\nIn order to simplify user experience, burst category operations are only allowed in single realm node"; - result += "\n configuration. Indeed, you could send messages with incorrect Origin-Realm, and no warning is shown."; - result += "\nAll the operations are performed through the unique realm: if you need to use more interfaces, you may"; - result += "\n launch different ADML instances. Is nonsense to allow burst in a multi-realm configured ADML, because"; + result += "\nIn order to simplify user experience, burst category operations are only allowed in single host node"; + result += "\n configuration. Indeed, you could send messages with unmatched Origin-Host, and no warning is shown."; + result += "\nAll the operations are performed through the unique host: if you need to use more interfaces, you may"; + result += "\n launch different ADML instances. Is nonsense to allow burst in a multi-host configured ADML, because"; result += "\n this feature is not able to coordinate the messages."; result += "\n"; result += "\nburst|[|parameter] Used for performance testing, we first program diameter requests"; @@ -1117,7 +1116,7 @@ std::string Launcher::help() const throw() { result += "\n-------------------------------------------------------------------------------------- Advanced testing"; result += "\n"; result += "\n Burst mode only allows single interface interaction. For multiple interface"; - result += "\n (realm) coordination, you could use the advanced test cases programming:"; + result += "\n (origin-host) coordination, you could use the advanced test cases programming:"; result += "\n"; result += "\n"; result += "\n test||[|parameters]"; @@ -1215,7 +1214,7 @@ std::string Launcher::help() const throw() { result += "\n which fulfills that condition. This message is useful together with the peer"; result += "\n connection source in a further send step configured with the corresponding"; result += "\n response. You could also insert a delay between wait and send steps to be"; - result += "\n more realistic (processing time simulation in a specific ADML realm node)."; + result += "\n more realistic (processing time simulation in a specific ADML host node)."; result += "\n Always, a response send step will get the needed information from the most"; result += "\n recent wait step finding in reverse order (note that some race conditions"; result += "\n could happen if your condition is not specific enough)."; @@ -1253,7 +1252,7 @@ std::string Launcher::help() const throw() { result += "\n RFC says that a hop by hop must be unique for a specific connection, something that"; result += "\n could be difficult to manage if we have multiple available connections from client"; result += "\n side endpoint (entity or local server), even if we would have only one connection but"; - result += "\n several realm interfaces. It is enough to configure different hop-by-hop values within"; + result += "\n several host interfaces. It is enough to configure different hop-by-hop values within"; result += "\n each test case, because on reception, the Session-Id is used to identify that test case."; result += "\n"; result += "\n"; @@ -1340,19 +1339,6 @@ std::string Launcher::help() const throw() { result += "\n Test cases reports are not dumped on process context (too many information in general)."; result += "\n The report contains context information in every moment: this operation acts as a snapshot."; result += "\n"; - result += "\n test|report|[|[yes]|no]"; - result += "\n"; - result += "\n Every time a test case is finished, its xml representation will be dump on a file under"; - result += "\n the execution directory (or the one configured in process command-line 'tmDir') with"; - result += "\n the name 'cycle-.testcase-.xml'. The third parameter represents"; - result += "\n the test result condition to dump the information. By default, neither failed nor successful"; - result += "\n test cases are written to avoid IO overload (in most of cases not all the tests are going to"; - result += "\n fail and you could enable only such dumps, but you can enable both types if you want)."; - result += "\n Better, you can use the 'look' operation to see the desired report(s) and its result state,"; - result += "\n in case that you miss the xml files or you disabled all the dumps during testing."; - result += "\n"; - result += "\n test|report-hex[|[yes]|no] Reports could include the diameter messages in hexadecimal format. Disabled by default."; - result += "\n"; result += "\n test|interact|amount|id Makes interactive a specific test case id. The amount is the margin of execution steps"; result += "\n to be done. Normally, we will execute 'test|interact|0|', which means that"; result += "\n the test case is selected to be interactive, but no step is executed. Then you have to"; @@ -1377,8 +1363,24 @@ std::string Launcher::help() const throw() { result += "\n"; result += "\n test|summary Test manager general report (number of test cases, counts by state, global configuration,"; result += "\n forced in-progress limitation, reports visibility, etc.). Be careful when you have reports"; - result += "\n enabled because the programmed test cases dumps could be heavy (try to disable both failed"; - result += "\n and successful dumps)."; + result += "\n enabled because the programmed test cases dumps could be heavy (anyway you could enable the"; + result += "\n dumps separately, for any of the possible states: Initialized, InProgress, Failed, Success)."; + result += "\n"; + result += "\n test|report|[|[yes]|no]"; + result += "\n"; + result += "\n Enables/disables report generation for a certain test case state: initialized, in-progress,"; + result += "\n failed or success. This applies to report summary (former described operation) and automatic"; + result += "\n dumps during testing where only failed or success states will appear: every time a test case"; + result += "\n is finished its xml representation will be dump on a file under the execution directory (or"; + result += "\n the one configured in process command-line 'tmDir') with the name:"; + result += "\n"; + result += "\n 'cycle-.testcase-.xml'."; + result += "\n"; + result += "\n By default, all the states are disabled to avoid IO overload. In most of cases not all the"; + result += "\n tests are going to fail and you could enable only such failed dumps, but you can enable all"; + result += "\n the types if you want (use reserved word 'all' for this)."; + result += "\n"; + result += "\n test|report-hex[|[yes]|no] Reports could include the diameter messages in hexadecimal format. Disabled by default."; result += "\n"; result += "\n"; result += "\nUSING OPERATIONS INTERFACE"; @@ -1560,7 +1562,7 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons return; } - // Realm switch: + // Host switch: if(opType == "node") { if (param1 != "") { if (setWorkingNode(param1)) response_content = anna::functions::asString("Forced node is now '%s'", param1.c_str()); @@ -1582,12 +1584,12 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons return; } - // Operated realm from possible forced-working node: - a_operatedRealm = a_workingNode ? a_workingNode /* priority */: NULL /* auto */; + // Operated host from possible forced-working node: + a_operatedHost = a_workingNode ? a_workingNode /* priority */: NULL /* auto */; // Use later: - // If any message is managed: updateOperatedRealmNodeWithMessage(codecMessage) + // If any message is managed: updateOperatedOriginHostWithMessage(codecMessage) // To operate, use the exception-protected methods which never will return NULL: - // getOperatedRealm(), getOperatedEntity(), getOperatedServer(), getOperatedEngine() + // getOperatedHost(), getOperatedEntity(), getOperatedServer(), getOperatedEngine() if(opType == "code") { @@ -1652,8 +1654,8 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons if(opType == "sendxml2e") { codecMsg.loadXML(param1); - updateOperatedRealmNodeWithMessage(codecMsg); - msg = getOperatedRealm()->createCommMessage(); + updateOperatedOriginHostWithMessage(codecMsg); + msg = getOperatedHost()->createCommMessage(); msg->clearBody(); try { codecMsg.valid(); } catch(anna::RuntimeException &ex) { ex.trace(); } // at least we need to see validation errors although it will continue sending (see validation mode configured in launcher) msg->setBody(codecMsg.code()); @@ -1661,25 +1663,25 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons // Get DataBlock from file with hex content: if(!getDataBlockFromHexFile(param1, db_aux)) throw anna::RuntimeException("Error reading hex file provided", ANNA_FILE_LOCATION); - msg = getOperatedRealm()->createCommMessage(); + msg = getOperatedHost()->createCommMessage(); msg->setBody(db_aux); - try { if(getOperatedRealm()->logEnabled()) codecMsg.decode(db_aux); } catch(anna::RuntimeException &ex) { ex.trace(); } + try { if(getOperatedHost()->logEnabled()) codecMsg.decode(db_aux); } catch(anna::RuntimeException &ex) { ex.trace(); } } bool success = getOperatedEntity()->send(msg, cl.exists("balance")); - getOperatedRealm()->releaseCommMessage(msg); + getOperatedHost()->releaseCommMessage(msg); // Detailed log: - if(getOperatedRealm()->logEnabled()) { + if(getOperatedHost()->logEnabled()) { anna::diameter::comm::Server *usedServer = getOperatedEntity()->getLastUsedResource(); anna::diameter::comm::ClientSession *usedClientSession = usedServer ? usedServer->getLastUsedResource() : NULL; std::string detail = usedClientSession ? usedClientSession->asString() : ""; // shouldn't happen - getOperatedRealm()->writeLogFile(codecMsg, (success ? "sent2e" : "send2eError"), detail); + getOperatedHost()->writeLogFile(codecMsg, (success ? "sent2e" : "send2eError"), detail); } } else if((opType == "burst")) { - if (!uniqueRealm()) - throw anna::RuntimeException("Burst category operations are only allowed in single realm node configuration. This is only to simplify user experience.", ANNA_FILE_LOCATION); + if (!uniqueOriginHost()) + throw anna::RuntimeException("Burst category operations are only allowed in single host node configuration. This is only to simplify user experience.", ANNA_FILE_LOCATION); // burst|clear clears all loaded burst messages. // burst|load| loads the next diameter message into launcher burst. @@ -1696,7 +1698,7 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons if(param1 == "clear") { opt_response_content = "removed "; - opt_response_content += anna::functions::asString(getOperatedRealm()->clearBurst()); + opt_response_content += anna::functions::asString(getOperatedHost()->clearBurst()); opt_response_content += " elements"; } else if(param1 == "load") { if(param2 == "") throw anna::RuntimeException("Missing xml path file for burst load operation", ANNA_FILE_LOCATION); @@ -1705,7 +1707,7 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons if(codecMsg.isAnswer()) throw anna::RuntimeException("Cannot load diameter answers for burst feature", ANNA_FILE_LOCATION); try { codecMsg.valid(); } catch(anna::RuntimeException &ex) { ex.trace(); } // at least we need to see validation errors although it will continue loading (see validation mode configured in launcher) - int position = getOperatedRealm()->loadBurstMessage(codecMsg.code()); + int position = getOperatedHost()->loadBurstMessage(codecMsg.code()); opt_response_content = "loaded '"; opt_response_content += param2; opt_response_content += "' file into burst list position "; @@ -1714,7 +1716,7 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons if(param2 == "") throw anna::RuntimeException("Missing initial load for burst start operation", ANNA_FILE_LOCATION); int initialLoad = atoi(param2.c_str()); - int processed = getOperatedRealm()->startBurst(initialLoad); + int processed = getOperatedHost()->startBurst(initialLoad); if(processed > 0) { opt_response_content = "initial load completed for "; @@ -1723,7 +1725,7 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons } else if(param1 == "push") { if(param2 == "") throw anna::RuntimeException("Missing load amount for burst push operation", ANNA_FILE_LOCATION); - int pushed = getOperatedRealm()->pushBurst(atoi(param2.c_str())); + int pushed = getOperatedHost()->pushBurst(atoi(param2.c_str())); if(pushed > 0) { opt_response_content = "pushed "; @@ -1733,14 +1735,14 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons if(param2 == "") throw anna::RuntimeException("Missing amount for burst pop operation", ANNA_FILE_LOCATION); int releaseLoad = atoi(param2.c_str()); - int popped = getOperatedRealm()->popBurst(releaseLoad); + int popped = getOperatedHost()->popBurst(releaseLoad); if(popped > 0) { opt_response_content = "burst popped for "; opt_response_content += anna::functions::entriesAsString(popped, "message"); } } else if(param1 == "stop") { - int left = getOperatedRealm()->stopBurst(); + int left = getOperatedHost()->stopBurst(); if(left != -1) { opt_response_content += anna::functions::entriesAsString(left, "message"); @@ -1750,12 +1752,12 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons if(param2 == "") param2 = "yes"; bool repeat = (param2 == "yes"); - getOperatedRealm()->repeatBurst(repeat); + getOperatedHost()->repeatBurst(repeat); opt_response_content += (repeat ? "repeat enabled" : "repeat disabled"); } else if(param1 == "send") { if(param2 == "") throw anna::RuntimeException("Missing amount for burst send operation", ANNA_FILE_LOCATION); - int sent = getOperatedRealm()->sendBurst(atoi(param2.c_str())); + int sent = getOperatedHost()->sendBurst(atoi(param2.c_str())); if(sent > 0) { opt_response_content = "sent "; @@ -1764,11 +1766,11 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons } else if(param1 == "goto") { if(param2 == "") throw anna::RuntimeException("Missing order position for burst goto operation", ANNA_FILE_LOCATION); - opt_response_content = getOperatedRealm()->gotoBurst(atoi(param2.c_str())); + opt_response_content = getOperatedHost()->gotoBurst(atoi(param2.c_str())); } else if(param1 == "look") { int order = ((param2 != "") ? atoi(param2.c_str()) : -1); opt_response_content = "\n\n"; - opt_response_content += getOperatedRealm()->lookBurst(order); + opt_response_content += getOperatedHost()->lookBurst(order); } else { throw anna::RuntimeException("Wrong body content format on HTTP Request for 'burst' operation (unexpected action parameter). See help", ANNA_FILE_LOCATION); } @@ -1779,7 +1781,8 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons // test|next[|] Forces the execution of the next test case(s) without waiting for test manager tick ... // test|ip-limit[|amount] In-progress limit of test cases. No new test cases will be launched over this value ... // test|repeats| Restarts the whole programmed test list when finished the amount number of times ... - // test|report|[|[yes]|no] Every time a test case is finished a report file in xml format will be created under ... + // test|report|[|[yes]|no] + // Enables/disables report generation for a certain test case state: initialized, in-progress ... // test|report-hex[|[yes]|no] Reports could include the diameter messages in hexadecimal format. Disabled by default. // test|goto| Updates current test pointer position. // test|look[|id] Show programmed test case for id provided, current when missing ... @@ -1852,16 +1855,22 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons if (numParams > 3) throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION); - if(param2 != "failed" && param2 != "success") + if(param2 != "initialized" && param2 != "in-progress" && param2 != "failed" && param2 != "success" && param2 != "all") throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION); if(param3 == "") param3 = "yes"; bool enable = (param3 == "yes"); - if(param2 == "success") - testManager.setDumpSuccessfulReports(enable); - else + if(param2 == "initialized") + testManager.setDumpInitializedReports(enable); + else if(param2 == "in-progress") + testManager.setDumpInProgressReports(enable); + else if(param2 == "failed") testManager.setDumpFailedReports(enable); + else if(param2 == "success") + testManager.setDumpSuccessReports(enable); + else // all + testManager.setDumpAllReports(enable); opt_response_content += (enable ? "report enabled " : "report disabled "); opt_response_content += "for tests in '"; @@ -2025,13 +2034,13 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons else { if (param4 == "") LOGWARNING(anna::Logger::warning("Step number has not been provided. Take into account that this answer message will be sent 'as is' and sequence information could be wrong at the remote peer", ANNA_FILE_LOCATION)); } - updateOperatedRealmNodeWithMessage(codecMsg); + updateOperatedOriginHostWithMessage(codecMsg); int stepNumber = ((param4 != "") ? atoi(param4.c_str()):-1); if (param2 == "sendxml2e") - testManager.getTestCase(id)->addSendxml2e(codecMsg.code(), getOperatedRealm(), stepNumber); // creates / reuses + testManager.getTestCase(id)->addSendxml2e(codecMsg.code(), getOperatedHost(), stepNumber); // creates / reuses else - testManager.getTestCase(id)->addSendxml2c(codecMsg.code(), getOperatedRealm(), stepNumber); // creates / reuses + testManager.getTestCase(id)->addSendxml2c(codecMsg.code(), getOperatedHost(), stepNumber); // creates / reuses } else if (param2 == "delay") { if (numParams > 3) @@ -2078,8 +2087,8 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons if(opType == "sendxml2c") { codecMsg.loadXML(param1); - updateOperatedRealmNodeWithMessage(codecMsg); - msg = getOperatedRealm()->createCommMessage(); + updateOperatedOriginHostWithMessage(codecMsg); + msg = getOperatedHost()->createCommMessage(); msg->clearBody(); try { codecMsg.valid(); } catch(anna::RuntimeException &ex) { ex.trace(); } // at least we need to see validation errors although it will continue sending (see validation mode configured in launcher) @@ -2088,18 +2097,18 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons // Get DataBlock from file with hex content: if(!getDataBlockFromHexFile(param1, db_aux)) throw anna::RuntimeException("Error reading hex file provided", ANNA_FILE_LOCATION); - msg = getOperatedRealm()->createCommMessage(); + msg = getOperatedHost()->createCommMessage(); msg->setBody(db_aux); } bool success = getOperatedServer()->send(msg); - getOperatedRealm()->releaseCommMessage(msg); + getOperatedHost()->releaseCommMessage(msg); // Detailed log: - if(getOperatedRealm()->logEnabled()) { + if(getOperatedHost()->logEnabled()) { anna::diameter::comm::ServerSession *usedServerSession = getOperatedServer()->getLastUsedResource(); std::string detail = usedServerSession ? usedServerSession->asString() : ""; // shouldn't happen - getOperatedRealm()->writeLogFile(codecMsg, (success ? "sent2c" : "send2cError"), detail); + getOperatedHost()->writeLogFile(codecMsg, (success ? "sent2c" : "send2cError"), detail); } } else if(opType == "loadxml") { codecMsg.loadXML(param1); @@ -2123,8 +2132,8 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons getOperatedServer()->getReactingAnswers()->dump(); } else { codecMsg.loadXML(param1); - updateOperatedRealmNodeWithMessage(codecMsg); - anna::diameter::codec::Message *message = getOperatedRealm()->getCodecEngine()->createMessage(param1); // loads xml again, lesser of two evils + updateOperatedOriginHostWithMessage(codecMsg); + anna::diameter::codec::Message *message = getOperatedHost()->getCodecEngine()->createMessage(param1); // loads xml again, lesser of two evils LOGDEBUG(anna::Logger::debug(message->asXMLString(), ANNA_FILE_LOCATION)); if(message->isRequest()) @@ -2149,8 +2158,8 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons getOperatedEntity()->getReactingAnswers()->dump(); } else { codecMsg.loadXML(param1); - updateOperatedRealmNodeWithMessage(codecMsg); - anna::diameter::codec::Message *message = getOperatedRealm()->getCodecEngine()->createMessage(param1); // loads xml again, lesser of two evils + updateOperatedOriginHostWithMessage(codecMsg); + anna::diameter::codec::Message *message = getOperatedHost()->getCodecEngine()->createMessage(param1); // loads xml again, lesser of two evils LOGDEBUG(anna::Logger::debug(message->asXMLString(), ANNA_FILE_LOCATION)); if(message->isRequest()) @@ -2180,7 +2189,7 @@ throw() { result->createAttribute("StartTime", a_start_time.asString()); result->createAttribute("SecondsLifeTime", anna::time::functions::lapsedMilliseconds() / 1000); // Diameter: - for (realm_nodes_it it = a_nodes.begin(); it != a_nodes.end(); it++) { + for (origin_hosts_it it = a_originHosts.begin(); it != a_originHosts.end(); it++) { it->second->asXML(result); }