X-Git-Url: https://git.teslayout.com/public/public/public/?p=anna.git;a=blobdiff_plain;f=example%2Fdiameter%2Flauncher%2FLauncher.cpp;h=d0151cd6f241281282b8cb81f1162d8d744238ca;hp=19404029e855a253294c81ad730196a9265a4b21;hb=c881c12ed7e116f1d43760a0d9873f860c10a357;hpb=af14877201a9856708ec43086a229777d9cb3da7 diff --git a/example/diameter/launcher/Launcher.cpp b/example/diameter/launcher/Launcher.cpp index 1940402..d0151cd 100644 --- a/example/diameter/launcher/Launcher.cpp +++ b/example/diameter/launcher/Launcher.cpp @@ -150,15 +150,15 @@ Launcher::Launcher() : anna::comm::Application("launcher", "DiameterLauncher", " std::string Launcher::getSignalUSR2InputFile() const throw() { - return (a_initialWorkingDirectory + "/" + SIGUSR2_TASKS_INPUT_FILENAME); + return (getInitialWorkingDirectory() + "/" + SIGUSR2_TASKS_INPUT_FILENAME); } std::string Launcher::getSignalUSR2OutputFile() const throw() { - return (a_initialWorkingDirectory + "/" + SIGUSR2_TASKS_OUTPUT_FILENAME); + return (getInitialWorkingDirectory() + "/" + SIGUSR2_TASKS_OUTPUT_FILENAME); } -void Launcher::servicesFromXML(const anna::xml::Node* servicesNode, bool eventOperation) throw(anna::RuntimeException) { +void Launcher::servicesFromXML(const anna::xml::Node* servicesNode, bool bindResources) throw(anna::RuntimeException) { CommandLine& cl(anna::CommandLine::instantiate()); bool allLogsDisabled = cl.exists("disableLogs"); @@ -203,6 +203,9 @@ void Launcher::servicesFromXML(const anna::xml::Node* servicesNode, bool eventOp if (stackEngine.getDictionary(id_value)) { // Ignore (but don't fail) dictionary load with same stack id already registered LOGWARNING(anna::Logger::warning(anna::functions::asString("Ignore dictionary load for stack id already registered: %llu", id_value), ANNA_FILE_LOCATION)); + // Delta loads, in case we provide base protocol already registered (comm::Engine will need 'bpd') + if (id_value == 0) + bpd = stackEngine.getDictionary(0); continue; } @@ -389,7 +392,7 @@ void Launcher::servicesFromXML(const anna::xml::Node* servicesNode, bool eventOp a_workingNode->createEntity(entity->getValue(), ceaTimeoutMs, answersTimeoutMs); a_workingNode->getEntity()->setSessionBasedModelsType(sessionBasedModelsTypeEnum); a_workingNode->getEntity()->setBalance(balance ? (balance->getValue() == "yes") : false); // for sendings - if (eventOperation) a_workingNode->getEntity()->bind(); + if (bindResources) a_workingNode->getEntity()->bind(); } } @@ -415,7 +418,7 @@ void Launcher::servicesFromXML(const anna::xml::Node* servicesNode, bool eventOp // Lazy initialization for comm engine: - if (eventOperation) commEngine->lazyInitialize(); + if (bindResources) commEngine->lazyInitialize(); // Node and Codec Engine registration /////////////////////////////////////////////////////// ohm.registerOriginHost(originHost->getValue(), a_workingNode); @@ -432,7 +435,7 @@ void Launcher::servicesFromXML(const anna::xml::Node* servicesNode, bool eventOp } -void Launcher::loadServices(const std::string & xmlPathFile, bool eventOperation) throw(anna::RuntimeException) { +void Launcher::loadServicesFromFile(const std::string & xmlPathFile, bool bindResources) throw(anna::RuntimeException) { if (xmlPathFile == "null" || xmlPathFile == "") { LOGWARNING(anna::Logger::warning("Ignoring services configuration on start: empty or 'null' string provided as xml file. Use management interface (operation 'services') in order to add services", ANNA_FILE_LOCATION)); @@ -469,7 +472,35 @@ void Launcher::loadServices(const std::string & xmlPathFile, bool eventOperation trace += anna::xml::Compiler().apply(rootNode); anna::Logger::debug(trace, ANNA_FILE_LOCATION); ); - servicesFromXML(rootNode, eventOperation); + servicesFromXML(rootNode, bindResources); +} + + +void Launcher::loadServicesFromXMLString(const std::string & xmlString, bool bindResources) throw(anna::RuntimeException) { + + anna::xml::DocumentMemory xmlDocument; // has private copy constructor defined but not implemented to avoid inhenrit/copy (is very heavy) + anna::xml::DTDMemory xmlDTD; + const anna::xml::Node *rootNode; + xmlDocument.initialize(xmlString.c_str()); + xmlDTD.initialize(ServicesDTD); + try { + rootNode = xmlDocument.parse(xmlDTD); // Parsing: fail here if xml violates dtd + } + catch (anna::RuntimeException &ex) { + LOGWARNING( + std::string msg = "Services DTD schema:\n\n"; + msg += ServicesDTD; + anna::Logger::warning(msg, ANNA_FILE_LOCATION); + ); + throw ex; + } + + LOGDEBUG( + std::string trace = "Loaded XML String:\n"; + trace += anna::xml::Compiler().apply(rootNode); + anna::Logger::debug(trace, ANNA_FILE_LOCATION); + ); + servicesFromXML(rootNode, bindResources); } @@ -568,6 +599,10 @@ anna::diameter::comm::OriginHost *Launcher::getOperatedHost() const throw(anna:: return a_operatedHost; } +void Launcher::setOperatedHost(anna::diameter::comm::OriginHost *op) { + a_operatedHost = op; +} + MyDiameterEntity *Launcher::getOperatedEntity() const throw(anna::RuntimeException) { MyDiameterEntity *result = (MyDiameterEntity *)(getOperatedHost()->getEntity()); if (!result) @@ -622,7 +657,7 @@ throw(anna::RuntimeException) { anna::Logger::setLevel(anna::Logger::asLevel(cl.getValue("trace"))); // Load launcher services: - loadServices(cl.getValue("services")); // before run (have components to be created) + loadServicesFromFile(cl.getValue("services"), false /* no bind at the moment */); // before run (have components to be created) } void Launcher::run() @@ -941,7 +976,7 @@ void Launcher::logStatisticsSamples(const std::string &conceptsList) throw() { } -bool Launcher::eventOperation(const std::string &operation, std::string &response_content) throw(anna::RuntimeException) { +bool Launcher::eventOperation(const std::string &operation, std::string &response) throw(anna::RuntimeException) { bool result = true; @@ -949,10 +984,13 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons if (operation == "") return result; // ignore LOGDEBUG(anna::Logger::debug(anna::functions::asString("Operation: %s", operation.c_str()), ANNA_FILE_LOCATION)); + EventOperation eop(false /* not HTTP, it is SIGUSR2 */); + // Default response: - response_content = "Operation processed with exception: "; - response_content += operation; - std::string opt_response_content = ""; // aditional response content + //response = "Operation processed with exception: "; + response = "Internal error (check ADML traces): "; + response += operation; + std::string opt_response = ""; // aditional response content anna::DataBlock db_aux(true); anna::diameter::codec::Message codecMsg; // auxiliary codec message @@ -971,11 +1009,11 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons if (args == "" && op_size != 7) throw anna::RuntimeException("Wrong body content format on HTTP Request. Check 'HELP.md' for more information.", ANNA_FILE_LOCATION); try { - p.execute(args, response_content); + p.execute(args, response); } catch(anna::RuntimeException &ex) { ex.trace(); - response_content = ex.asString(); + response = ex.asString(); return false; } return true; // OK @@ -983,29 +1021,20 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons // Reset performance data: if(operation == "collect") { - resetCounters(); - resetStatistics(); - response_content = "All process counters & statistic information have been reset"; - return true; // OK + return eop.collect(response); } // Counters dump on demand: if(operation == "forceCountersRecord") { - forceCountersRecord(); - response_content = "Current counters have been dump to disk"; - return true; // OK + return eop.forceCountersRecord(response); } // OAM & statistics: if(operation == "show-oam") { - anna::xml::Node root("root"); - response_content = anna::xml::Compiler().apply(oamAsXML(&root)); - return true; // OK + return eop.show_oam(response); } if(operation == "show-stats") { - anna::xml::Node root("root"); - response_content = anna::xml::Compiler().apply(statsAsXML(&root)); - return true; // OK + return eop.show_stats(response); } /////////////////////////////////////////////////////////////////// @@ -1055,7 +1084,7 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons if((opType == "log-statistics-samples") && (numParams != 1)) wrongBody = true; if((opType == "node") && (numParams > 1)) wrongBody = true; - if((opType == "node_auto") && (numParams > 0)) wrongBody = true; + if((opType == "node-auto") && (numParams > 0)) wrongBody = true; if(((opType == "code") || (opType == "decode")) && (numParams != 2)) wrongBody = true; @@ -1077,76 +1106,40 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons // Operations: if(opType == "context") { - std::string contextFile = ((numParams == 1) ? param1 : anna::functions::asString("/var/tmp/anna.context.%05d", getPid())); - writeContext(contextFile); - response_content = anna::functions::asString("Context dumped on file '%s'", contextFile.c_str()); - return true; // OK + return eop.context(response, (numParams == 1) ? param1 : ""); } if(opType == "log-statistics-samples") { - logStatisticsSamples(param1); - response_content = anna::functions::asString("Log statistics samples for '%s' concepts", param1.c_str()); - return true; // OK + return eop.log_statistics_samples(response, param1); } // Change execution directory: if(opType == "change-dir") { - if (param1 == "") param1 = a_initialWorkingDirectory; - result = (chdir(param1.c_str()) == 0); - - if (result) - response_content = "New execution directory configured: "; - else - response_content = "Cannot assign provided execution directory: "; - - response_content += param1; - return result; + return eop.change_dir(response, param1); } if(opType == "services") { std::string servicesFile = ((numParams == 1) ? param1 : "services.xml"); try { - loadServices(servicesFile, true /* bind entities */); + loadServicesFromFile(servicesFile, true /* bind entities */); } catch(anna::RuntimeException &ex) { ex.trace(); - response_content = anna::functions::asString("Loaded services from file '%s' with errors", servicesFile.c_str()); + response = anna::functions::asString("Loaded services from file '%s' with errors", servicesFile.c_str()); return false; } - response_content = anna::functions::asString("Loaded services from file '%s'", servicesFile.c_str()); + response = anna::functions::asString("Loaded services from file '%s'", servicesFile.c_str()); return true; // OK } // Host switch: if(opType == "node") { - if (param1 != "") { - if (setWorkingNode(param1)) response_content = anna::functions::asString("Forced node is now '%s'", param1.c_str()); - } - else { - if (a_workingNode) { - response_content = "Working node is forced to be: \n\n"; - response_content += a_workingNode->asXMLString(); - } - else { - response_content = "Working node is automatic"; - } - } - return true; // OK + return eop.node(response, param1); } - if(opType == "node_auto") { - a_workingNode = NULL; - response_content = "Working node has been set to automatic"; - return true; // OK + else if(opType == "node-auto") { + return eop.node_auto(response); } - // Operated host from possible forced-working node: - a_operatedHost = a_workingNode ? a_workingNode /* priority */: NULL /* auto */; - // Use later: - // If any message is managed: updateOperatedOriginHostWithMessage(codecMessage) - // To operate, use the exception-protected methods which never will return NULL: - // getOperatedHost(), getOperatedEntity(), getOperatedServer(), getOperatedEngine() - - if(opType == "code") { codecMsg.loadXMLFile(param1); std::string hexString = anna::functions::asHexString(codecMsg.code()); @@ -1168,42 +1161,8 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons outfile.write(xmlString.c_str(), xmlString.size()); outfile.close(); } else if((opType == "hide") || (opType == "show") || (opType == "hidden") || (opType == "shown")) { + return eop.visibility(opt_response, opType, param1, (param2 != "") ? atoi(param2.c_str()) : -1); - if(param1 != "") { - if(param2 != "") { - std::string key = param1; - key += "|"; - key += param2; - - if(opType == "hide") getOperatedEngine()->findClientSession(key)->hide(); - - if(opType == "show") getOperatedEngine()->findClientSession(key)->show(); - - if(opType == "hidden") opt_response_content = getOperatedEngine()->findClientSession(key)->hidden() ? "true" : "false"; - - if(opType == "shown") opt_response_content = getOperatedEngine()->findClientSession(key)->shown() ? "true" : "false"; - } else { - std::string address; - int port; - anna::functions::getAddressAndPortFromSocketLiteral(param1, address, port); - - if(opType == "hide") getOperatedEngine()->findServer(address, port)->hide(); - - if(opType == "show") getOperatedEngine()->findServer(address, port)->show(); - - if(opType == "hidden") opt_response_content = getOperatedEngine()->findServer(address, port)->hidden() ? "true" : "false"; - - if(opType == "shown") opt_response_content = getOperatedEngine()->findServer(address, port)->shown() ? "true" : "false"; - } - } else { - if(opType == "hide") getOperatedEntity()->hide(); - - if(opType == "show") getOperatedEntity()->show(); - - if(opType == "hidden") opt_response_content = getOperatedEntity()->hidden() ? "true" : "false"; - - if(opType == "shown") opt_response_content = getOperatedEntity()->shown() ? "true" : "false"; - } } else if((opType == "sendxml2e") || (opType == "sendhex2e")) { anna::diameter::comm::Message *msg; @@ -1252,9 +1211,9 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons // burst|look| Show programmed burst message for order provided, current when missing. if(param1 == "clear") { - opt_response_content = "removed "; - opt_response_content += anna::functions::asString(getOperatedHost()->clearBurst()); - opt_response_content += " elements"; + opt_response = "removed "; + opt_response += anna::functions::asString(getOperatedHost()->clearBurst()); + opt_response += " elements"; } else if(param1 == "load") { if(param2 == "") throw anna::RuntimeException("Missing xml path file for burst load operation", ANNA_FILE_LOCATION); @@ -1263,10 +1222,10 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons 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 = getOperatedHost()->loadBurstMessage(codecMsg.code()); - opt_response_content = "loaded '"; - opt_response_content += param2; - opt_response_content += "' file into burst list position "; - opt_response_content += anna::functions::asString(position); + opt_response = "loaded '"; + opt_response += param2; + opt_response += "' file into burst list position "; + opt_response += anna::functions::asString(position); } else if(param1 == "start") { if(param2 == "") throw anna::RuntimeException("Missing initial load for burst start operation", ANNA_FILE_LOCATION); @@ -1274,8 +1233,8 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons int processed = getOperatedHost()->startBurst(initialLoad); if(processed > 0) { - opt_response_content = "initial load completed for "; - opt_response_content += anna::functions::entriesAsString(processed, "message"); + opt_response = "initial load completed for "; + opt_response += anna::functions::entriesAsString(processed, "message"); } } else if(param1 == "push") { if(param2 == "") throw anna::RuntimeException("Missing load amount for burst push operation", ANNA_FILE_LOCATION); @@ -1283,8 +1242,8 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons int pushed = getOperatedHost()->pushBurst(atoi(param2.c_str())); if(pushed > 0) { - opt_response_content = "pushed "; - opt_response_content += anna::functions::entriesAsString(pushed, "message"); + opt_response = "pushed "; + opt_response += anna::functions::entriesAsString(pushed, "message"); } } else if(param1 == "pop") { if(param2 == "") throw anna::RuntimeException("Missing amount for burst pop operation", ANNA_FILE_LOCATION); @@ -1293,39 +1252,39 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons int popped = getOperatedHost()->popBurst(releaseLoad); if(popped > 0) { - opt_response_content = "burst popped for "; - opt_response_content += anna::functions::entriesAsString(popped, "message"); + opt_response = "burst popped for "; + opt_response += anna::functions::entriesAsString(popped, "message"); } } else if(param1 == "stop") { int left = getOperatedHost()->stopBurst(); if(left != -1) { - opt_response_content += anna::functions::entriesAsString(left, "message"); - opt_response_content += " left to the end of the cycle"; + opt_response += anna::functions::entriesAsString(left, "message"); + opt_response += " left to the end of the cycle"; } } else if(param1 == "repeat") { if(param2 == "") param2 = "yes"; bool repeat = (param2 == "yes"); getOperatedHost()->repeatBurst(repeat); - opt_response_content += (repeat ? "repeat enabled" : "repeat disabled"); + opt_response += (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 = getOperatedHost()->sendBurst(atoi(param2.c_str())); if(sent > 0) { - opt_response_content = "sent "; - opt_response_content += anna::functions::entriesAsString(sent, "message"); + opt_response = "sent "; + opt_response += anna::functions::entriesAsString(sent, "message"); } } else if(param1 == "goto") { if(param2 == "") throw anna::RuntimeException("Missing order position for burst goto operation", ANNA_FILE_LOCATION); - opt_response_content = getOperatedHost()->gotoBurst(atoi(param2.c_str())); + opt_response = 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 += getOperatedHost()->lookBurst(order); + opt_response = "\n\n"; + opt_response += getOperatedHost()->lookBurst(order); } else { throw anna::RuntimeException("Wrong body content format on HTTP Request for 'burst' operation (unexpected action parameter). Check 'HELP.md' for more information.", ANNA_FILE_LOCATION); } @@ -1340,6 +1299,7 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons // 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|run| Executes the given test case // test|look[|id] Show programmed test case for id provided, current when missing ... // test|state[|id] Show test case state for id provided, current when missing ... // test|interact|amount|id Makes interactive a specific test case id. The amount is the margin of execution steps ... @@ -1355,12 +1315,12 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons bool success = ((param2 != "") ? testManager.configureTTPS(atoi(param2.c_str())) : false); if (success) { - opt_response_content = "assigned new test launch rate to "; - opt_response_content += anna::functions::asString(atoi(param2.c_str())); - opt_response_content += " events per second"; + opt_response = "assigned new test launch rate to "; + opt_response += anna::functions::asString(atoi(param2.c_str())); + opt_response += " events per second"; } else { - opt_response_content += "unable to configure the test rate provided"; + opt_response += "unable to configure the test rate provided"; } } else if (param1 == "next") { @@ -1374,10 +1334,10 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons bool success = testManager.execTestCases(sync_amount); - opt_response_content = (success ? "" : "not completely " /* completed cycle and no repeats, rare case */); - opt_response_content += "processed "; - opt_response_content += anna::functions::asString(sync_amount); - opt_response_content += ((sync_amount > 1) ? " test cases synchronously" : " test case"); + opt_response = (success ? "" : "not completely " /* completed cycle and no repeats, rare case */); + opt_response += "processed "; + opt_response += anna::functions::asString(sync_amount); + opt_response += ((sync_amount > 1) ? " test cases synchronously" : " test case"); } else if(param1 == "ip-limit") { if (numParams > 2) @@ -1387,16 +1347,16 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons if (param2 != "") { limit = atoi(param2.c_str()); testManager.setInProgressLimit(limit); - opt_response_content = "new in-progress limit: "; - opt_response_content += (limit != UINT_MAX) ? anna::functions::asString(limit) : ""; + opt_response = "new in-progress limit: "; + opt_response += (limit != UINT_MAX) ? anna::functions::asString(limit) : ""; } else { - opt_response_content = "in-progress limit amount: "; + opt_response = "in-progress limit amount: "; limit = testManager.getInProgressLimit(); - opt_response_content += (limit != UINT_MAX) ? anna::functions::asString(limit) : ""; - opt_response_content += "; currently there are "; - opt_response_content += anna::functions::asString(testManager.getInProgressCount()); - opt_response_content += " test cases running"; + opt_response += (limit != UINT_MAX) ? anna::functions::asString(limit) : ""; + opt_response += "; currently there are "; + opt_response += anna::functions::asString(testManager.getInProgressCount()); + opt_response += " test cases running"; } } else if(param1 == "repeats") { @@ -1406,7 +1366,7 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons if (repeats < 0) repeats = -1; testManager.setPoolRepeats(repeats); std::string nolimit = (repeats != -1) ? "":" [no limit]"; - opt_response_content += anna::functions::asString("Pool repeats: %d%s (current cycle: %d)", repeats, nolimit.c_str(), testManager.getPoolCycle()); + opt_response += anna::functions::asString("Pool repeats: %d%s (current cycle: %d)", repeats, nolimit.c_str(), testManager.getPoolCycle()); } else if(param1 == "report") { if (numParams > 3) @@ -1436,10 +1396,10 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons else throw anna::RuntimeException("Wrong body content format on HTTP Request. Check 'HELP.md' for more information.", ANNA_FILE_LOCATION); - opt_response_content += (enable ? "report enabled " : "report disabled "); - opt_response_content += "for tests in '"; - opt_response_content += param2; - opt_response_content += "' state"; + opt_response += (enable ? "report enabled " : "report disabled "); + opt_response += "for tests in '"; + opt_response += param2; + opt_response += "' state"; } else if(param1 == "report-hex") { if (numParams > 2) @@ -1447,7 +1407,7 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons if(param2 == "") param2 = "yes"; testManager.setDumpHex((param2 == "yes")); - opt_response_content += (testManager.getDumpHex() ? "report includes hexadecimal messages" : "report excludes hexadecimal messages"); + opt_response += (testManager.getDumpHex() ? "report includes hexadecimal messages" : "report excludes hexadecimal messages"); } else if(param1 == "dump-stdout") { if (numParams > 2) @@ -1455,7 +1415,7 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons if(param2 == "") param2 = "yes"; testManager.setDumpStdout((param2 == "yes")); - opt_response_content += (testManager.getDumpHex() ? "test manager dumps progress into stdout" : "test manager does not dump progress into stdout"); + opt_response += (testManager.getDumpHex() ? "test manager dumps progress into stdout" : "test manager does not dump progress into stdout"); } else if(param1 == "goto") { if (numParams > 2) @@ -1464,13 +1424,13 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons if(param2 == "") throw anna::RuntimeException("Missing id for test goto operation", ANNA_FILE_LOCATION); int id = atoi(param2.c_str()); if (testManager.gotoTestCase(id)) { - opt_response_content = "position updated for id provided ("; + opt_response = "position updated for id provided ("; } else { - opt_response_content = "cannot found test id ("; + opt_response = "cannot found test id ("; } - opt_response_content += anna::functions::asString(id); - opt_response_content += ")"; + opt_response += anna::functions::asString(id); + opt_response += ")"; } else if(param1 == "run") { if (numParams > 2) @@ -1479,13 +1439,13 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons if(param2 == "") throw anna::RuntimeException("Missing id for test run operation", ANNA_FILE_LOCATION); int id = atoi(param2.c_str()); if (testManager.runTestCase(id)) { - opt_response_content = "test executed for id provided ("; + opt_response = "test executed for id provided ("; } else { - opt_response_content = "cannot found test id ("; + opt_response = "cannot found test id ("; } - opt_response_content += anna::functions::asString(id); - opt_response_content += ")"; + opt_response += anna::functions::asString(id); + opt_response += ")"; } else if(param1 == "look") { if (numParams > 2) @@ -1495,18 +1455,18 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons anna::testing::TestCase *testCase = testManager.findTestCase(id); if (testCase) { - response_content = testCase->asXMLString(); + response = testCase->asXMLString(); return true; // OK } else { result = false; if (id == -1) { - opt_response_content = "no current test case detected (testing started ?)"; + opt_response = "no current test case detected (testing started ?)"; } else { - opt_response_content = "cannot found test id ("; - opt_response_content += anna::functions::asString(id); - opt_response_content += ")"; + opt_response = "cannot found test id ("; + opt_response += anna::functions::asString(id); + opt_response += ")"; } } } @@ -1518,18 +1478,18 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons anna::testing::TestCase *testCase = testManager.findTestCase(id); if (testCase) { - response_content = anna::testing::TestCase::asText(testCase->getState()); + response = anna::testing::TestCase::asText(testCase->getState()); return testCase->isSuccess(); } else { result = false; if (id == -1) { - opt_response_content = "no current test case detected (testing started ?)"; + opt_response = "no current test case detected (testing started ?)"; } else { - opt_response_content = "cannot found test id ("; - opt_response_content += anna::functions::asString(id); - opt_response_content += ")"; + opt_response = "cannot found test id ("; + opt_response += anna::functions::asString(id); + opt_response += ")"; } } } @@ -1546,23 +1506,23 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons if (testCase) { if (amount == -1) { testCase->makeInteractive(false); - opt_response_content = "interactive mode disabled"; + opt_response = "interactive mode disabled"; } else { testCase->addInteractiveAmount(amount); - opt_response_content = "added interactive amount of "; - opt_response_content += anna::functions::asString(amount); - opt_response_content += " units"; - if (amount == 0) opt_response_content += " (0: freezing a non-interactive testcase, no effect on already interactive)"; + opt_response = "added interactive amount of "; + opt_response += anna::functions::asString(amount); + opt_response += " units"; + if (amount == 0) opt_response += " (0: freezing a non-interactive testcase, no effect on already interactive)"; } - opt_response_content += " for test case id "; - opt_response_content += anna::functions::asString(id); + opt_response += " for test case id "; + opt_response += anna::functions::asString(id); } else { result = false; - opt_response_content = "cannot found test id ("; - opt_response_content += anna::functions::asString(id); - opt_response_content += ")"; + opt_response = "cannot found test id ("; + opt_response += anna::functions::asString(id); + opt_response += ")"; } } else if(param1 == "reset") { @@ -1578,22 +1538,22 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons if (testCase) { bool done = testCase->reset(param2 == "hard"); - opt_response_content = "test "; - opt_response_content += param2; - opt_response_content += " reset for id "; - opt_response_content += anna::functions::asString(id); - opt_response_content += done ? ": done": ": not done"; + opt_response = "test "; + opt_response += param2; + opt_response += " reset for id "; + opt_response += anna::functions::asString(id); + opt_response += done ? ": done": ": not done"; } else { if (id == -1) { bool anyReset = testManager.resetPool(param2 == "hard"); - opt_response_content = param2; opt_response_content += " reset have been sent to all programmed tests: "; opt_response_content += anyReset ? "some/all have been reset" : "nothing was reset"; + opt_response = param2; opt_response += " reset have been sent to all programmed tests: "; opt_response += anyReset ? "some/all have been reset" : "nothing was reset"; } else { result = false; - opt_response_content = "cannot found test id ("; - opt_response_content += anna::functions::asString(id); - opt_response_content += ")"; + opt_response = "cannot found test id ("; + opt_response += anna::functions::asString(id); + opt_response += ")"; } } } @@ -1605,45 +1565,45 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons throw anna::RuntimeException("Wrong body content format on HTTP Request. Check 'HELP.md' for more information.", ANNA_FILE_LOCATION); testManager.setAutoResetHard(param2 == "hard"); - opt_response_content += anna::functions::asString("Auto-reset configured to '%s'", param2.c_str()); + opt_response += anna::functions::asString("Auto-reset configured to '%s'", param2.c_str()); } else if(param1 == "initialized") { if (numParams > 1) throw anna::RuntimeException("Wrong body content format on HTTP Request. Check 'HELP.md' for more information.", ANNA_FILE_LOCATION); - opt_response_content = anna::functions::asString("%lu", testManager.getInitializedCount()); + opt_response = anna::functions::asString("%lu", testManager.getInitializedCount()); } else if(param1 == "finished") { if (numParams > 1) throw anna::RuntimeException("Wrong body content format on HTTP Request. Check 'HELP.md' for more information.", ANNA_FILE_LOCATION); - opt_response_content = anna::functions::asString("%lu", testManager.getFinishedCount()); + opt_response = anna::functions::asString("%lu", testManager.getFinishedCount()); } else if(param1 == "clear") { if (numParams > 1) throw anna::RuntimeException("Wrong body content format on HTTP Request. Check 'HELP.md' for more information.", ANNA_FILE_LOCATION); if (testManager.clearPool()) { - opt_response_content = "all the programmed test cases have been dropped"; + opt_response = "all the programmed test cases have been dropped"; } else { - opt_response_content = "there are not programmed test cases to be removed"; + opt_response = "there are not programmed test cases to be removed"; } } else if(param1 == "junit") { - response_content = testManager.junitAsXMLString(); + response = testManager.junitAsXMLString(); return true; // OK } else if(param1 == "summary-counts") { - response_content = testManager.summaryCounts(); + response = testManager.summaryCounts(); return true; // OK } else if(param1 == "summary-states") { - response_content = testManager.summaryStates(); + response = testManager.summaryStates(); return true; // OK } else if(param1 == "summary") { - response_content = testManager.asXMLString(); + response = testManager.asXMLString(); return true; // OK } else { @@ -1854,7 +1814,7 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons } } else if(opType == "loadxml") { codecMsg.loadXMLFile(param1); - response_content = codecMsg.asXMLString(); + response = codecMsg.asXMLString(); return true; // OK } else if(opType == "diameterServerSessions") { int diameterServerSessions = atoi(param1.c_str()); @@ -1862,7 +1822,7 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons } else if(opType == "answerxml2c") { if(param1 == "") { // programmed answers FIFO's to stdout - response_content = getOperatedServer()->getReactingAnswers()->asString("ANSWERS TO CLIENT"); + response = getOperatedServer()->getReactingAnswers()->asString("ANSWERS TO CLIENT"); return true; // OK } else if (param1 == "rotate") { getOperatedServer()->getReactingAnswers()->rotate(true); @@ -1888,7 +1848,7 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons } else if(opType == "answerxml2e") { if(param1 == "") { // programmed answers FIFO's to stdout - response_content = getOperatedEntity()->getReactingAnswers()->asString("ANSWERS TO ENTITY"); + response = getOperatedEntity()->getReactingAnswers()->asString("ANSWERS TO ENTITY"); return true; // OK } else if (param1 == "rotate") { getOperatedEntity()->getReactingAnswers()->rotate(true); @@ -1916,10 +1876,10 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons } // HTTP response - response_content = "Operation correctly processed: "; response_content += operation; - if (opt_response_content != "") { - response_content += " => "; - response_content += opt_response_content; + response = "Operation correctly processed: "; response += operation; + if (opt_response != "") { + response += " => "; + response += opt_response; } return result;