#include <iostream> // std::cout
#include <math.h> // ceil
#include <climits>
+#include <unistd.h> // chdir
// Project
#include <anna/timex/Engine.hpp>
// Process
#include <Launcher.hpp>
-#include <RealmNode.hpp>
+#include <OriginHost.hpp>
#include <MyDiameterEngine.hpp>
#include <TestManager.hpp>
#include <TestCase.hpp>
-#define SIGUSR2_TASKS_INPUT_FILENAME "./sigusr2.in"
-#define SIGUSR2_TASKS_OUTPUT_FILENAME "./sigusr2.out"
+#define SIGUSR2_TASKS_INPUT_FILENAME "sigusr2.in"
+#define SIGUSR2_TASKS_OUTPUT_FILENAME "sigusr2.out"
const char *ServicesDTD = "\
-->\n\
\n\
<!ELEMENT node EMPTY>\n\
-<!ATTLIST node originRealm CDATA #REQUIRED applicationId CDATA #REQUIRED originHost CDATA #IMPLIED cer CDATA #IMPLIED dwr CDATA #IMPLIED allowedInactivityTime CDATA #IMPLIED tcpConnectDelay CDATA #IMPLIED answersTimeout CDATA #IMPLIED ceaTimeout CDATA #IMPLIED watchdogPeriod CDATA #IMPLIED entity CDATA #IMPLIED entityServerSessions CDATA #IMPLIED diameterServer CDATA #IMPLIED diameterServerSessions CDATA #IMPLIED balance (yes | no) #IMPLIED sessionBasedModelsClientSocketSelection (SessionIdLowPart | SessionIdHighPart | SessionIdOptionalPart | RoundRobin) #IMPLIED retries CDATA #IMPLIED log CDATA #IMPLIED splitLog (yes | no) #IMPLIED detailedLog (yes | no) #IMPLIED dumpLog (yes | no) #IMPLIED burstLog (yes | no) #IMPLIED>\n\
+<!ATTLIST node originHost CDATA #REQUIRED applicationId CDATA #REQUIRED originRealm CDATA #IMPLIED cer CDATA #IMPLIED dwr CDATA #IMPLIED allowedInactivityTime CDATA #IMPLIED tcpConnectDelay CDATA #IMPLIED answersTimeout CDATA #IMPLIED ceaTimeout CDATA #IMPLIED watchdogPeriod CDATA #IMPLIED entity CDATA #IMPLIED entityServerSessions CDATA #IMPLIED diameterServer CDATA #IMPLIED diameterServerSessions CDATA #IMPLIED balance (yes | no) #IMPLIED sessionBasedModelsClientSocketSelection (SessionIdLowPart | SessionIdHighPart | SessionIdOptionalPart | RoundRobin) #IMPLIED retries CDATA #IMPLIED log CDATA #IMPLIED splitLog (yes | no) #IMPLIED detailedLog (yes | no) #IMPLIED dumpLog (yes | no) #IMPLIED burstLog (yes | no) #IMPLIED>\n\
<!--\n\
Node record\n\
\n\
- originRealm: Node identifier (Origin-Realm name).\n\
+ originHost: Node identifier as diameter application host name.\n\
applicationId: The Application-Id provided must exists as a registered 'stack id'.\n\
- originHost: Diameter application host name (system name). If missing, process sets o.s. hostname\n\
- Note that if you have two or more realms, the names must be different.\n\
+ originRealm: Origin-Realm (domain-name internally used by default).\n\
cer: User defined CER path file to be encoded to establish diameter connections.\n\
- If missing, will be harcoded\n\
+ If missing, will be harcoded.\n\
dwr: User defined DWR path file to be encoded for diameter protocol keep alive.\n\
- If missing, will be harcoded\n\
+ If missing, will be harcoded.\n\
allowedInactivityTime: Milliseconds for the maximum allowed inactivity time on server sessions born over the\n\
- local server before being reset. If missing, default value of 90000 will be assigned\n\
+ local server before being reset. If missing, default value of 90000 will be assigned.\n\
tcpConnectDelay: Milliseconds to wait TCP connect to any server. If missing, default value of 200 will\n\
be assigned\n\
answersTimeout: Milliseconds to wait pending application answers from diameter peers. If missing,\n\
- default value of 10000 will be assigned\n\
+ default value of 10000 will be assigned.\n\
ceaTimeout: Milliseconds to wait CEA from diameter server. If missing, default value of 'answersTimeout'\n\
- will be assigned\n\
+ will be assigned.\n\
watchdogPeriod: Milliseconds for watchdog timer (Tw) for diameter keep-alive procedure. If missing, default\n\
- value of 30000 will be assigned\n\
+ value of 30000 will be assigned.\n\
entity: Target diameter entity (comma-separated '<address>:<port>' format).\n\
- For example: 10.20.30.40:3868,10.20.30.41:3868. If missing, no entity will be enabled\n\
- entityServerSessions: Diameter entity server sessions (0: diameter entity disabled). Default value of 1\n\
+ For example: 10.20.30.40:3868,10.20.30.41:3868. If missing, no entity will be enabled.\n\
+ entityServerSessions: Diameter entity server sessions (0: diameter entity disabled). Default value of 1.\n\
diameterServer: Diameter own server address in '<address>:<port>' format. For example: 10.20.30.40:3868.\n\
- If missing, no local server will be enabled\n\
- diameterServerSessions: Diameter own server available connections (0: diameter server disabled). Default value of 1\n\
+ If missing, no local server will be enabled.\n\
+ diameterServerSessions: Diameter own server available connections (0: diameter server disabled). Default value of 1.\n\
+ Negative value implies no limit accepting incoming connections.\n\
balance: Balance over entity servers instead of doing standard behaviour (first primary, secondary\n\
- if fails, etc.). Default value 'no'\n\
+ if fails, etc.). Default value 'no'.\n\
sessionBasedModelsClientSocketSelection: By default, round-robin will be applied for IEC model (SMS/MMS), and Session-Id Low Part\n\
will be analyzed for ECUR/SCUR model (data, voice and content). You could change ECUR/SCUR\n\
analysis behaviour providing 'SessionIdHighPart', 'SessionIdOptionalPart' (atoi applied;\n\
- usually subscriber id data, i.e. MSISDN or IMSI) and 'RoundRobin' (also 'SessionIdLowPart')\n\
- retries: Expired responses will cause a number of request retransmissions. Disabled by default (0 retries)\n\
- log: Process log file (operations result, traffic log, etc.). By default '<originRealm>.launcher.log'.\n\
+ usually subscriber id data, i.e. MSISDN or IMSI) and 'RoundRobin' (also 'SessionIdLowPart').\n\
+ retries: Expired responses will cause a number of request retransmissions. Disabled by default (0 retries).\n\
+ log: Process log file (operations result, traffic log, etc.). By default '<originHost>.launcher.log'.\n\
Empty string or \"null\" name, to disable. Warning: there is no rotation for log files\n\
- (use logrotate or whatever you consider)\n\
+ (use logrotate or whatever you consider).\n\
splitLog: Splits log file (appends to log filename, extensions with the type of event: see help on\n\
startup information-level traces). No log files for code/decode and load operations are created.\n\
- Default value 'no'\n\
+ Default value 'no'.\n\
detailedLog: Insert detailed information at log files. Should be disabled on automatic tests. Useful on\n\
- 'balance' mode to know messages flow along the sockets. Default value 'no'\n\
+ 'balance' mode to know messages flow along the sockets. Default value 'no'.\n\
dumpLog: Write to disk every incoming/outcoming message named as:\n\
- '<originRealm>.<hop by hop>.<end to end>.<message code>.<request|answer>.<type of event>.xml'\n\
- Default value 'no'\n\
- burstLog: Burst operations log file. By default '<originRealm>.launcher.burst'. Empty string or \"null\" name, to disable.\n\
+ '<originHost>.<hop by hop>.<end to end>.<message code>.<request|answer>.<type of event>.xml'\n\
+ Default value 'no'.\n\
+ burstLog: Burst operations log file. By default '<originHost>.launcher.burst'. Empty string or \"null\" name, to disable.\n\
Warning: there is no rotation for log files (use logrotate or whatever). Output: dot (.) for each\n\
burst message sent/pushed, cross (x) for popped ones, and order number when multiple of 1% of burst\n\
- list size, plus OTA requests when changed\n\
+ list size, plus OTA requests when changed.\n\
\n\
-->\n\
\n\
//a_admlMinResolution = (anna::Millisecond)100;
a_counterRecorderClock = NULL;
- // a_nodes.clear();
+ // a_originHosts.clear();
a_workingNode = NULL;
a_httpServerSocket = NULL;
}
+std::string Launcher::getSignalUSR2InputFile() const throw() {
+ return (a_initialWorkingDirectory + "/" + SIGUSR2_TASKS_INPUT_FILENAME);
+}
+
+std::string Launcher::getSignalUSR2OutputFile() const throw() {
+ return (a_initialWorkingDirectory + "/" + SIGUSR2_TASKS_OUTPUT_FILENAME);
+}
void Launcher::servicesFromXML(const anna::xml::Node* servicesNode, bool eventOperation) throw(anna::RuntimeException) {
- //<!ATTLIST stack id CDATA #REQUIRED dictionary CDATA #REQUIRED>
+
+ CommandLine& cl(anna::CommandLine::instantiate());
+ bool allLogsDisabled = cl.exists("disableLogs");
+
+ //<!ATTLIST stack id CDATA #REQUIRED dictionary CDATA #REQUIRED>
const anna::xml::Attribute *id, *dictionary;
- // <!ATTLIST node originRealm CDATA #REQUIRED applicationId CDATA #REQUIRED originHost CDATA #IMPLIED cer CDATA #IMPLIED dwr CDATA #IMPLIED allowedInactivityTime CDATA #IMPLIED tcpConnectDelay CDATA #IMPLIED answersTimeout CDATA #IMPLIED ceaTimeout CDATA #IMPLIED watchdogPeriod CDATA #IMPLIED entity CDATA #IMPLIED entityServerSessions CDATA #IMPLIED diameterServer CDATA #IMPLIED diameterServerSessions CDATA #IMPLIED balance (yes | no) #IMPLIED sessionBasedModelsClientSocketSelection (SessionIdLowPart | SessionIdHighPart | SessionIdOptionalPart | RoundRobin) #IMPLIED retries CDATA #IMPLIED log CDATA #IMPLIED splitLog (yes | no) #IMPLIED detailedLog (yes | no) #IMPLIED dumpLog (yes | no) #IMPLIED burstLog (yes | no) #IMPLIED>
- const anna::xml::Attribute *originRealm, *appId, *originHost, *cer, *dwr, *allowedInactivityTime, *tcpConnectDelay,
+ // <!ATTLIST node originHost CDATA #REQUIRED applicationId CDATA #REQUIRED cer CDATA #IMPLIED dwr CDATA #IMPLIED allowedInactivityTime CDATA #IMPLIED tcpConnectDelay CDATA #IMPLIED answersTimeout CDATA #IMPLIED ceaTimeout CDATA #IMPLIED watchdogPeriod CDATA #IMPLIED entity CDATA #IMPLIED entityServerSessions CDATA #IMPLIED diameterServer CDATA #IMPLIED diameterServerSessions CDATA #IMPLIED balance (yes | no) #IMPLIED sessionBasedModelsClientSocketSelection (SessionIdLowPart | SessionIdHighPart | SessionIdOptionalPart | RoundRobin) #IMPLIED retries CDATA #IMPLIED log CDATA #IMPLIED splitLog (yes | no) #IMPLIED detailedLog (yes | no) #IMPLIED dumpLog (yes | no) #IMPLIED burstLog (yes | no) #IMPLIED>
+ const anna::xml::Attribute *originHost, *appId, *originRealm, *cer, *dwr, *allowedInactivityTime, *tcpConnectDelay,
*answersTimeout, *ceaTimeout, *watchdogPeriod, *entity, *entityServerSessions,
*diameterServer, *diameterServerSessions, *balance, *sessionBasedModelsClientSocketSelection,
*retries, *log, *splitLog, *detailedLog, *dumpLog, *burstLog;
-
// Never clear services content from here (append new data from xml). At the moment no node removing is implemented in this process
// Stacks
anna::diameter::comm::ApplicationMessageOamModule & appMsgOamModule = anna::diameter::comm::ApplicationMessageOamModule::instantiate();
appMsgOamModule.enableCounters(); // this special module is disabled by default (the only)
static int scope_id = 3;
- bool id_0_registered = false;
unsigned int id_value;
std::string codecEngineName;
dictionary = (*it)->getAttribute("dictionary");
id_value = id->getIntegerValue();
+ 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));
+ continue;
+ }
+
try {
d = stackEngine.createDictionary(id_value, dictionary->getValue());
LOGDEBUG(anna::Logger::debug(anna::functions::asString("Created dictionary (%p) for stack id %llu", d, id_value), ANNA_FILE_LOCATION));
throw ex;
}
- if (id_value == 0) {
- id_0_registered = true;
- bpd = d;
- }
+ bpd = d; // base protocol dictionary in case of monostack. If multistack, will be calculated later
// Create codec engine and register it in the codec engine manager:
codecEngineName = anna::functions::asString("CodecEngineForStackId_%llu", id_value);
// Basic checking for multistack:
bool multistack = (stackEngine.stack_size() > 1);
if (multistack) {
- if(!id_0_registered)
+ bpd = stackEngine.getDictionary(0);
+ if(!bpd)
throw anna::RuntimeException("In multistack applications is mandatory register a stack id = 0 using a dictionary which contains the needed elements to build base protocol messages (CER/A, DWR/A, DPR/A, STR/A, etc.)", ANNA_FILE_LOCATION);
}
- else { // monostack
- if (!bpd)
- bpd = ce->getDictionary(); // in mono-stack applications, we understand the existing stack as the used
- // for base protocol, regardless if it is registered with stack id 0 or not
- }
// REALMS:
for(anna::xml::Node::const_child_iterator it = servicesNode->child_begin(); it != servicesNode->child_end(); it++) {
if(nodeName == "node") {
// Input data:
- originRealm = (*it)->getAttribute("originRealm");
+ originHost = (*it)->getAttribute("originHost");
appId = (*it)->getAttribute("applicationId");
- originHost = (*it)->getAttribute("originHost", false /* no exception */);
+ originRealm = (*it)->getAttribute("originRealm", false /* no exception */);
cer = (*it)->getAttribute("cer", false /* no exception */);
dwr = (*it)->getAttribute("dwr", false /* no exception */);
allowedInactivityTime = (*it)->getAttribute("allowedInactivityTime", false /* no exception */);
burstLog = (*it)->getAttribute("burstLog", false /* no exception */); // (yes | no)
// Basic checkings:
- realm_nodes_it nodeIt = a_nodes.find(originRealm->getValue());
- if (nodeIt != a_nodes.end()) {
- std::string msg = "Already registered node name (Origin-Realm): "; msg += originRealm->getValue();
+ origin_hosts_it nodeIt = a_originHosts.find(originHost->getValue());
+ if (nodeIt != a_originHosts.end()) {
+ std::string msg = "Already registered such Origin-Host: "; msg += originHost->getValue();
throw anna::RuntimeException(msg, ANNA_FILE_LOCATION);
}
}
// Create new Node instance /////////////////////////////////////////////////////////////////
- a_workingNode = new RealmNode(originRealm->getValue(), applicationId, bpd);
+ a_workingNode = new OriginHost(originHost->getValue(), applicationId, bpd);
MyDiameterEngine *commEngine = a_workingNode->getMyDiameterEngine();
/////////////////////////////////////////////////////////////////////////////////////////////
commEngine->setWatchdogPeriod(watchdogPeriodMs);
// Realm information:
- if (originHost) commEngine->setHost(originHost->getValue());
- commEngine->setRealm(originRealm->getValue());
+ commEngine->setOriginHost(originHost->getValue());
+ if (originRealm) commEngine->setOriginRealm(originRealm->getValue());
// Diameter entity:
if(entity) {
}
// Logs:
- std::string realm = commEngine->getRealm();
- std::string s_log = realm + ".launcher.log"; if (log) s_log = log->getValue();
- bool b_splitLog = (splitLog ? (splitLog->getValue() == "yes") : false);
- bool b_detailedLog = (detailedLog ? (detailedLog->getValue() == "yes") : false);
- bool b_dumpLog = (dumpLog ? (dumpLog->getValue() == "yes") : false);
- std::string s_burstLog = realm + ".launcher.burst"; if (burstLog) s_burstLog = burstLog->getValue();
- a_workingNode->setLogs(s_log, b_splitLog, b_detailedLog, b_dumpLog, s_burstLog);
+ if (!allLogsDisabled) {
+ std::string host = commEngine->getOriginHost();
+ std::string s_log = host + ".launcher.log"; if (log) s_log = log->getValue();
+ bool b_splitLog = (splitLog ? (splitLog->getValue() == "yes") : false);
+ bool b_detailedLog = (detailedLog ? (detailedLog->getValue() == "yes") : false);
+ bool b_dumpLog = (dumpLog ? (dumpLog->getValue() == "yes") : false);
+ std::string s_burstLog = host + ".launcher.burst"; if (burstLog) s_burstLog = burstLog->getValue();
+ a_workingNode->setLogs(s_log, b_splitLog, b_detailedLog, b_dumpLog, s_burstLog);
+ }
// Lazy initialization for comm engine:
if (eventOperation) commEngine->lazyInitialize();
// Node and Codec Engine registration ///////////////////////////////////////////////////////
- a_nodes[originRealm->getValue()] = a_workingNode;
+ a_originHosts[originHost->getValue()] = a_workingNode;
/////////////////////////////////////////////////////////////////////////////////////////////
}
}
- if (!uniqueRealm())
+ if (!uniqueOriginHost())
a_workingNode = NULL; // by default, mode auto
// Diameter comm engines which are loaded after application start (via management operation 'services') are not really started,
bool Launcher::setWorkingNode(const std::string &name) throw() {
bool result = false;
- realm_nodes_it nodeIt = a_nodes.find(name);
- if (nodeIt == a_nodes.end()) {
+ origin_hosts_it nodeIt = a_originHosts.find(name);
+ if (nodeIt == a_originHosts.end()) {
LOGWARNING(
std::string msg = "Unknown node with name '"; msg += name; msg += "'. Ignoring ...";
anna::Logger::warning(msg, ANNA_FILE_LOCATION);
);
}
else {
- a_workingNode = const_cast<RealmNode*>(nodeIt->second);
+ a_workingNode = const_cast<OriginHost*>(nodeIt->second);
result = true;
}
return result;
}
-RealmNode *Launcher::getRealmNode(const std::string &realmName) const throw(anna::RuntimeException) {
- realm_nodes_it it = a_nodes.find(realmName);
- if (it != a_nodes.end()) return it->second;
- throw anna::RuntimeException(anna::functions::asString("There is no realm node registered as '%s' (set Origin-Realm avp correctly or force a specific realm with 'node' operation)", realmName.c_str()), ANNA_FILE_LOCATION);
+OriginHost *Launcher::getOriginHost(const std::string &oh) const throw(anna::RuntimeException) {
+ origin_hosts_it it = a_originHosts.find(oh);
+ if (it != a_originHosts.end()) return it->second;
+ throw anna::RuntimeException(anna::functions::asString("There is no origin host registered as '%s' (set Origin-Host avp correctly or force a specific host with 'node' operation)", oh.c_str()), ANNA_FILE_LOCATION);
}
-RealmNode *Launcher::getRealmNode(const anna::diameter::codec::Message &message) const throw(anna::RuntimeException) {
- std::string originRealm = message.getAvp(anna::diameter::helpers::base::AVPID__Origin_Realm)->getDiameterIdentity()->getValue();
- return (getRealmNode(originRealm));
+OriginHost *Launcher::getOriginHost(const anna::diameter::codec::Message &message) const throw(anna::RuntimeException) {
+ std::string originHost = message.getAvp(anna::diameter::helpers::base::AVPID__Origin_Host)->getDiameterIdentity()->getValue();
+ return (getOriginHost(originHost));
}
-void Launcher::updateOperatedRealmNodeWithMessage(const anna::diameter::codec::Message &message) throw(anna::RuntimeException) {
- if (!a_operatedRealm) // priority for working node by mean 'node' operation
- a_operatedRealm = getRealmNode(message);
+void Launcher::updateOperatedOriginHostWithMessage(const anna::diameter::codec::Message &message) throw(anna::RuntimeException) {
+ if (!a_operatedHost) // priority for working node by mean 'node' operation
+ a_operatedHost = getOriginHost(message);
}
-RealmNode *Launcher::getOperatedRealm() const throw(anna::RuntimeException) {
- if(!a_operatedRealm)
- throw anna::RuntimeException("Realm Node not identified (try to force a specific realm with 'node' operation)", ANNA_FILE_LOCATION);
+OriginHost *Launcher::getOperatedHost() const throw(anna::RuntimeException) {
+ if(!a_operatedHost)
+ throw anna::RuntimeException("Node not identified (try to force a specific Origin-Host with 'node' operation)", ANNA_FILE_LOCATION);
- return a_operatedRealm;
+ return a_operatedHost;
}
MyDiameterEntity *Launcher::getOperatedEntity() const throw(anna::RuntimeException) {
- MyDiameterEntity *result = getOperatedRealm()->getEntity();
+ MyDiameterEntity *result = getOperatedHost()->getEntity();
if (!result)
- throw anna::RuntimeException("No entity configured for the operated Realm Node", ANNA_FILE_LOCATION);
+ throw anna::RuntimeException("No entity configured for the operated node", ANNA_FILE_LOCATION);
return result;
}
MyLocalServer *Launcher::getOperatedServer() const throw(anna::RuntimeException) {
- MyLocalServer *result = getOperatedRealm()->getDiameterServer();
+ MyLocalServer *result = getOperatedHost()->getDiameterServer();
if (!result)
- throw anna::RuntimeException("No local server configured for the operated Realm Node", ANNA_FILE_LOCATION);
+ throw anna::RuntimeException("No local server configured for the operated node", ANNA_FILE_LOCATION);
return result;
}
MyDiameterEngine *Launcher::getOperatedEngine() const throw(anna::RuntimeException) {
- return getOperatedRealm()->getMyDiameterEngine(); // never will be NULL
+ return getOperatedHost()->getMyDiameterEngine(); // never will be NULL
}
void Launcher::initialize()
// Start time:
a_start_time.setNow();
+
+ // Initial working directory:
+ char cwd[1024];
+ if (getcwd(cwd, sizeof(cwd)) == NULL)
+ throw anna::RuntimeException("Cannot retrieve initial working directory !!", ANNA_FILE_LOCATION);
+ a_initialWorkingDirectory = cwd;
+
// Statistics:
anna::statistics::Engine::instantiate().enable();
// Start client connections //////////////////////////////////////////////////////////////////////////////////
MyDiameterEntity *entity;
- 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++) {
entity = it->second->getEntity();
if (entity) entity->bind();
}
a_workingNode->getMyDiameterEngine()->resetStatistics();
}
else {
- 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->getMyDiameterEngine()->resetStatistics();
}
}
}
void Launcher::signalUSR2() throw(anna::RuntimeException) {
+
+ std::string inputFile = getSignalUSR2InputFile();
+ std::string outputFile = getSignalUSR2OutputFile();
+
LOGNOTICE(
- std::string msg = "Captured signal SIGUSR2. Reading tasks at '";
- msg += SIGUSR2_TASKS_INPUT_FILENAME;
+ std::string msg = "Captured signal SIGUSR2. Reading tasks at '";
+ msg += inputFile;
msg += "' (results will be written at '";
- msg += SIGUSR2_TASKS_OUTPUT_FILENAME;
+ msg += outputFile;
msg += "')";
anna::Logger::notice(msg, ANNA_FILE_LOCATION);
);
// Operation:
std::string line;
std::string response_content;
- std::ifstream in_file(SIGUSR2_TASKS_INPUT_FILENAME);
- std::ofstream out_file(SIGUSR2_TASKS_OUTPUT_FILENAME);
+ std::ifstream in_file(inputFile);
+ std::ofstream out_file(outputFile);
if(!in_file.is_open()) throw RuntimeException("Unable to read tasks", ANNA_FILE_LOCATION);
-
if(!out_file.is_open()) throw RuntimeException("Unable to write tasks", ANNA_FILE_LOCATION);
while(getline(in_file, line)) {
+
+ // Ignore comments and blank lines:
+ if (line[0] == '#') continue;
+ if (std::string::npos == line.find_first_not_of(" \t")) continue;
+
LOGDEBUG(
std::string msg = "Processing line: ";
msg += line;
}
in_file.close();
+ out_file << "EOF\n";
out_file.close();
}
result += "\nOVERVIEW";
result += "\n--------";
result += "\n";
- result += "\nThe ADML (ANNA Diameter Multirealm Launcher) process is a multi-realm node with client and server";
+ result += "\nThe ADML (ANNA Diameter MultiHost Launcher) process is a multi-host node with client and server";
result += "\n capabilities as well as balancer (proxy) features. It could be used as diameter server (i.e. to";
result += "\n simulate PCRF nodes, OCS systems, etc.), as diameter client (GGSNs, DPIs, etc.), and balancer";
result += "\n systems to provide failover to external round-robin launchers. Also, auxiliary encoder/decoder/loader";
result += "\n establish as minimum), separate statistics analyzer per each resource, automatic CER/CEA and DWR/DWA";
result += "\n generation, expiration control and many more features.";
result += "\n";
- result += "\nThe ADML process can easily configure a many realm nodes as needed, which will have own endpoints.";
+ result += "\nThe ADML process can easily configure a many origin-host nodes as needed, which will have own endpoints.";
result += "\nYou should avoid loop configurations (client and server for that client) because automatic forwarding,";
result += "\n is implemented and this would get in a never ending cycle when a request is sent.";
result += "\n";
result += "\n <stack id=\"0\" dictionary=\"dictionary.xml\"/>";
result += "\n";
result += "\n <!-- Nodes -->";
- result += "\n <node originRealm=\"ADML-client\" applicationId=\"0\" entity=\"localhost:3868\"/>";
+ result += "\n <node originHost=\"ADML-client\" applicationId=\"0\" entity=\"localhost:3868\"/>";
result += "\n</services>";
result += "\n";
result += "\nServer configuration:";
result += "\n <stack id=\"0\" dictionary=\"dictionary.xml\"/>";
result += "\n";
result += "\n <!-- Nodes -->";
- result += "\n <node originRealm=\"ADML-server\" applicationId=\"0\" diameterServer=\"localhost:3868\"/>";
+ result += "\n <node originHost=\"ADML-server\" applicationId=\"0\" diameterServer=\"localhost:3868\"/>";
result += "\n</services>";
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";
result += "\n <stack id=\"0\" dictionary=\"dictionary_base.xml\"/>";
result += "\n";
result += "\n <!-- Nodes -->";
- result += "\n <node originRealm=\"ADML-Rx-client\" applicationId=\"16777236\" entity=\"localhost:3868\" cer=\"cer_Rx.xml\"/>";
- result += "\n <node originRealm=\"ADML-Gx-client\" applicationId=\"16777238\" entity=\"localhost:3868\" cer=\"cer_Gx.xml\"/>";
+ result += "\n <node originHost=\"ADML-Rx-client\" applicationId=\"16777236\" entity=\"localhost:3868\" cer=\"cer_Rx.xml\"/>";
+ result += "\n <node originHost=\"ADML-Gx-client\" applicationId=\"16777238\" entity=\"localhost:3868\" cer=\"cer_Gx.xml\"/>";
result += "\n</services>";
result += "\n";
result += "\n";
result += "\n";
result += "\n--------------------------------------------------------------------------------------- Node management";
result += "\n";
- result += "\nnode[|<name>] Selects a context working node by mean a registered name.";
+ result += "\nnode[|<name>] 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";
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";
result += "\n to load new nodes once the ADML is started, regardless if command";
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 nodes";
+ result += "\n will use this dictionary to encode/decode base protocol messages";
+ result += "\n managed by the communication engine.";
result += "\n";
result += "\ndiameterServerSessions|<integer> Updates the maximum number of accepted connections to diameter";
result += "\n server socket.";
result += "\n performance measurement. Context data can be written at";
result += "\n '/var/tmp/anna.context.<pid>' by mean 'kill -10 <pid>'.";
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 += "\noam-and-stats Dumps current counters and statistics of the process. This is";
- result += "\n also done at process context dump.";
+ result += "\nchange-dir[|directory] Changes the execution point which could be fine to ease some";
+ result += "\n file system interaction tasks. Be care about some requirements";
+ result += "\n (for example if you have a user defined counters directory as";
+ result += "\n relative path this must exists from the new execution directory).";
+ result += "\n If nothing provided, initial working directory will be restored.";
+ result += "\nshow-oam Dumps current counters of the process. This is also done at";
+ result += "\n process context dump.";
+ result += "\nshow-stats Dumps statistics of the process. This is also done at process";
+ result += "\n context dump.";
result += "\n";
result += "\n<visibility action>[|<address>:<port>][|socket id]";
result += "\n";
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|<action>[|parameter] Used for performance testing, we first program diameter requests";
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|<id>|<command>[|parameters]";
result += "\n";
result += "\n delay|<msecs> Blocking step until the time lapse expires. Useful to give ";
result += "\n some cadence control and time schedule for a specific case.";
+ result += "\n A value of 0 could be used as a dummy step.";
result += "\n wait<fe/fc>|<condition> Blocking step until condition is fulfilled. The message could";
result += "\n received from entity (waitfe) or from client (waitfc).";
result += "\n";
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).";
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";
result += "\n";
result += "\n Provide 0 in order to stop the timer triggering.";
result += "\n";
- result += "\n There timer manager resolution currently harcoded allows a maximum of ";
+ result += "\n The timer manager resolution currently harcoded allows a maximum of ";
result += anna::functions::asString(1000/a_admlMinResolution); result += " events";
result += "\n per second. To reach greater rates ADML will join synchronously the needed number of";
result += "\n new time-triggered test cases per a single event, writting a warning-level trace to";
result += "\n advice about the risk of burst sendings and recommend launching multiple instances";
result += "\n to achieve such load with a lower rate per instance.";
result += "\n";
+ result += "\n test|next[|<sync-amount>] Forces the execution of the next test case(s) without waiting for test manager tick.";
+ result += "\n Provide an integer value for 'sync-amount' to send a burst synchronous amount of the";
+ result += "\n next programmed test cases (1 by default). This event works regardless the timer tick";
+ result += "\n function, but it is normally used with the test manager tick stopped.";
+ result += "\n";
result += "\n test|ip-limit[|amount] In-progress limit of test cases. No new test cases will be launched over this value";
result += "\n (test Manager tick work will be ignored). Zero-value is equivalent to stop the clock.";
result += "\n tick, -1 is used to specify 'no limit' which is the default. If missing amount, the";
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] 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-<cycle id>.testcase-<test case id>.xml'. This option is disabled by";
- result += "\n default reducing IO. ADML process context won't show test manager whole information";
- result += "\n because it could be a huge amount of data to write. Anyway, you could use the 'look'";
- result += "\n operation to see the desired report(s).";
- 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|<test case id>', which means that";
result += "\n the test case is selected to be interactive, but no step is executed. Then you have to";
result += "\n steps margin, which could be useful to 'freeze' a test in the middle of its execution.";
result += "\n You could also provide -1 to make it non-interactive resuming it from the current step.";
result += "\n";
- result += "\n test|reset|<soft/hard>[|id] Reset the test case for id provided, all the tests when missing. It could be hard/soft:";
+ result += "\n test|reset|<[soft]/hard>[|id] Reset the test case for id provided, all the tests when missing. It could be hard/soft:";
result += "\n - hard: you probably may need to stop the load rate before. This operation initializes";
result += "\n all test cases regardless their states.";
result += "\n - soft: only for finished cases (those with 'Success' or 'Failed' states). It does not";
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 dumps enabled because all the programmed test cases will be dump and that could be heavy.";
+ 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|<initialized/in-progress/failed/success/[all]/none>[|[yes]|no]";
+ result += "\n";
+ result += "\n Enables/disables report generation for a certain test case state: initialized, in-progress,";
+ result += "\n failed or success (also 'all' and 'none' reserved words could be used). This applies to report";
+ result += "\n summary (former described operation) and automatic dumps during testing where only failed or";
+ result += "\n successful states will appear: every time a test case is finished its xml representation will";
+ result += "\n be dump on a file under the execution directory (or the one configured in process command-line";
+ result += "\n 'tmDir') with the name:";
+ result += "\n";
+ result += "\n 'cycle-<cycle id>.testcase-<test case id>.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 then you could enable only such failed dumps. Anyway you could set";
+ result += "\n the reports visibility to fit your needs in a given situation.";
+ 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";
result += "\n";
result += "\nThe alternative using SIGUSR2 signal requires the creation of the task(s) file which will be read at";
result += "\n signal event:";
- result += "\n echo \"<<operation>\" > "; result += SIGUSR2_TASKS_INPUT_FILENAME;
+ result += "\n echo \"<<operation>\" > "; result += getSignalUSR2InputFile();
result += "\n then";
result += "\n kill -12 <pid>";
result += "\n or";
result += "\n kill -s SIGUSR2 <pid>";
result += "\n and then see the results:";
- result += "\n cat "; result += SIGUSR2_TASKS_OUTPUT_FILENAME;
+ result += "\n cat "; result += getSignalUSR2OutputFile();
+ result += "\n";
+ result += "\n (this file is ended with EOF final line, useful managing huge batch files to ensure the job completion)";
result += "\n";
result += "\nYou could place more than one line (task) in the input file. Output reports will be appended in that";
result += "\n case over the output file. Take into account that all the content of the task file will be executed";
LOGDEBUG(anna::Logger::debug(operation, ANNA_FILE_LOCATION));
// Default response:
- response_content = "Operation processed with exception (see traces): ";
+ response_content = "Operation processed with exception: ";
response_content += operation;
std::string opt_response_content = ""; // aditional response content
anna::DataBlock db_aux(true);
}
// OAM & statistics:
- if(operation == "oam-and-stats") {
+ if(operation == "show-oam") {
+ anna::xml::Node root("root");
+ response_content = anna::xml::Compiler().apply(oamAsXML(&root));
+ return;
+ }
+ if(operation == "show-stats") {
anna::xml::Node root("root");
- response_content = anna::xml::Compiler().apply(oamAndStatsAsXML(&root));
+ response_content = anna::xml::Compiler().apply(statsAsXML(&root));
return;
}
// Check the number of parameters:
bool wrongBody = false;
+ if((opType == "change-dir") && (numParams > 1)) wrongBody = true;
if((opType == "node") && (numParams > 1)) wrongBody = true;
+
if((opType == "node_auto") && (numParams > 0)) wrongBody = true;
if(((opType == "code") || (opType == "decode")) && (numParams != 2)) wrongBody = true;
return;
}
+ // Change execution directory:
+ if(opType == "change-dir") {
+ if (param1 == "") param1 = a_initialWorkingDirectory;
+ if (chdir(param1.c_str()) == 0)
+ response_content = "New execution directory configured: ";
+ else
+ response_content = "Cannot assign provided execution directory: ";
+
+ response_content += param1;
+ return;
+ }
+
if(opType == "services") {
std::string servicesFile = ((numParams == 1) ? param1 : "services.xml");
try {
}
catch(anna::RuntimeException &ex) {
ex.trace();
- response_content = anna::functions::asString("Loaded services from file '%s' with some problems (ignored ones)", servicesFile.c_str());
+ response_content = anna::functions::asString("Loaded services from file '%s' with errors", servicesFile.c_str());
return;
}
response_content = anna::functions::asString("Loaded services from file '%s'", servicesFile.c_str());
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());
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") {
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());
// 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() : "<null client session>"; // 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|<source_file> loads the next diameter message into launcher burst.
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);
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 ";
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 ";
} 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 ";
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");
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 ";
} 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);
}
} else if((opType == "test")) {
- // test|<id>|<command>[|parameters] Add a new step to the test case ...
- // test|ttps|<amount> Starts/resume the provided number of time ticks per second (ttps). The ADML starts ...
- // test|ip-limit[|amount] In-progress limit of test cases. No new test cases will be launched over this value ...
- // test|repeats|<amount> 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-hex[|[yes]|no] Reports could include the diameter messages in hexadecimal format. Disabled by default.
- // test|goto|<id> Updates current test pointer position.
- // test|look[|id] Show programmed test case 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 ...
- // test|reset|<soft/hard>[|id] Reset the test case for id provided, all the tests when missing ...
- // test|clear Clears all the programmed test cases.
- // test|summary Test manager general report (number of test cases, counts by state ...
+ // test|<id>|<command>[|parameters] Add a new step to the test case ...
+ // test|ttps|<amount> Starts/resume the provided number of time ticks per second (ttps). The ADML starts ...
+ // test|next[|<sync-amount>] 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|<amount> Restarts the whole programmed test list when finished the amount number of times ...
+ // test|report|<initialized/in-progress/failed/success/[all]/none>[|[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|<id> Updates current test pointer position.
+ // test|look[|id] Show programmed test case 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 ...
+ // test|reset|<[soft]/hard>[|id] Reset the test case for id provided, all the tests when missing ...
+ // test|clear Clears all the programmed test cases.
+ // test|summary Test manager general report (number of test cases, counts by state ...
if(param1 == "ttps") {
opt_response_content += "unable to configure the test rate provided";
}
}
+ else if (param1 == "next") {
+ if (numParams > 2)
+ throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION);
+
+ int sync_amount = ((param2 != "") ? atoi(param2.c_str()) : 1);
+
+ if (sync_amount < 1)
+ throw anna::RuntimeException("The parameter 'sync-amount' must be a positive integer value", ANNA_FILE_LOCATION);
+
+ 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");
+ }
else if(param1 == "ip-limit") {
if (numParams > 2)
throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION);
opt_response_content += anna::functions::asString("Pool repeats: %d%s (current cycle: %d)", repeats, nolimit.c_str(), testManager.getPoolCycle());
}
else if(param1 == "report") {
- if (numParams > 2)
+ 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 == "") param2 = "yes";
- testManager.setDumpReports((param2 == "yes"));
- opt_response_content += (testManager.getDumpReports() ? "report enabled" : "report disabled");
+ if(param2 == "") param2 = "all";
+ if(param3 == "") param3 = "yes";
+ bool enable = (param3 == "yes");
+
+ 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 if(param2 == "all") {
+ param2 = "any";
+ testManager.setDumpAllReports(enable);
+ }
+ else if(param2 == "none") {
+ enable = !enable;
+ param2 = "any";
+ testManager.setDumpAllReports(enable);
+ }
+ else
+ throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see 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";
}
else if(param1 == "report-hex") {
if (numParams > 2)
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 != "soft" && param2 != "hard")
+ if(param2 == "") param2 = "soft";
+ if (param2 != "soft" && param2 != "hard")
throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION);
int id = ((param3 != "") ? atoi(param3.c_str()) : -1);
else {
if (id == -1) {
bool anyReset = testManager.resetPool((param2 == "hard") ? true:false);
- 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_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";
}
else {
opt_response_content = "cannot found test id (";
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)
throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION);
if(param3 == "") throw anna::RuntimeException("Missing milliseconds for 'delay' command in test id operation", ANNA_FILE_LOCATION);
- anna::Millisecond delay = checkTimeMeasure("Test case delay step", param3);
+ anna::Millisecond delay = ((param3 == "0" /* special case */) ? (anna::Millisecond)0 : checkTimeMeasure("Test case delay step", param3));
testManager.getTestCase(id)->addDelay(delay); // creates / reuses
}
else if ((param2 == "waitfe")||(param2 == "waitfc")) {
}
}
else if (param2 == "sh-command") {
- if (numParams > 4)
- throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION);
+ // Allow pipes in command:
+ //if (numParams > 4)
+ // throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION);
if(param3 == "") throw anna::RuntimeException("Missing script/executable command-line for 'sh-command' in test id operation", ANNA_FILE_LOCATION);
- testManager.getTestCase(id)->addCommand(param3); // creates / reuses
+ std::string token = "|sh-command|";
+ std::string command = operation.substr(operation.find(token) + token.size());
+ testManager.getTestCase(id)->addCommand(command); // creates / reuses
}
else {
throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION);
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)
// 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() : "<null server session>"; // shouldn't happen
- getOperatedRealm()->writeLogFile(codecMsg, (success ? "sent2c" : "send2cError"), detail);
+ getOperatedHost()->writeLogFile(codecMsg, (success ? "sent2c" : "send2cError"), detail);
}
} else if(opType == "loadxml") {
codecMsg.loadXML(param1);
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())
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())
anna::comm::Application::asXML(result);
// Timming:
result->createAttribute("StartTime", a_start_time.asString());
+ result->createAttribute("InitialWorkingDirectory", a_initialWorkingDirectory);
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);
}
// OAM & statistics:
- oamAndStatsAsXML(result);
+ oamAsXML(result);
+ statsAsXML(result);
// Testing: could be heavy if test case reports are enabled
TestManager::instantiate().asXML(result);
return result;
}
-anna::xml::Node* Launcher::oamAndStatsAsXML(anna::xml::Node* parent) const
+anna::xml::Node* Launcher::oamAsXML(anna::xml::Node* parent) const
throw() {
- anna::xml::Node* result = parent->createChild("OamAndStatistics");
+ anna::xml::Node* result = parent->createChild("Oam");
// OAM:
anna::diameter::comm::OamModule::instantiate().asXML(result);
anna::diameter::comm::ApplicationMessageOamModule::instantiate().asXML(result);
anna::diameter::codec::OamModule::instantiate().asXML(result);
+
+ return result;
+}
+
+anna::xml::Node* Launcher::statsAsXML(anna::xml::Node* parent) const
+throw() {
+ anna::xml::Node* result = parent->createChild("Statistics");
+
// Statistics:
anna::statistics::Engine::instantiate().asXML(result);
return result;
}
-