From: Eduardo Ramos Testillano Date: Fri, 29 Jan 2016 13:47:21 +0000 (+0100) Subject: Fixes & improvements X-Git-Tag: REFACTORING_TESTING_LIBRARY~53 X-Git-Url: https://git.teslayout.com/public/public/public/?p=anna.git;a=commitdiff_plain;h=1ac015cbbcd331edc3c14de26290d669d91e4e53 Fixes & improvements --- diff --git a/example/diameter/launcher/DEPLOY.sh b/example/diameter/launcher/DEPLOY.sh index bf8ec84..2b6fd96 100755 --- a/example/diameter/launcher/DEPLOY.sh +++ b/example/diameter/launcher/DEPLOY.sh @@ -208,7 +208,7 @@ cp $SRVDTD $DPATH/DTDs echo "Preparing ..." cd $DPATH createRunScript $option -stacks/makeAutonomous.sh commands_qosControl.xml ./stack-mgmt >/dev/null +stacks/makeAutonomous.sh commands_qosControl.xml stacks/stack-mgmt >/dev/null ln -s stacks/autonomous.commands_qosControl.xml dictionary.xml cd - >/dev/null diff --git a/example/diameter/launcher/Launcher.cpp b/example/diameter/launcher/Launcher.cpp index 1ebf492..193e2cb 100644 --- a/example/diameter/launcher/Launcher.cpp +++ b/example/diameter/launcher/Launcher.cpp @@ -211,7 +211,7 @@ void Launcher::servicesFromXML(const anna::xml::Node* servicesNode, bool eventOp const anna::xml::Attribute *vm_attr = (*it)->getAttribute("validationMode", false /* no exception */); const anna::xml::Attribute *vd_attr = (*it)->getAttribute("validationDepth", false /* no exception */); const anna::xml::Attribute *fm_attr = (*it)->getAttribute("fixMode", false /* no exception */); - const anna::xml::Attribute *if_attr = (*it)->getAttribute("ignoreFlags", false /* no exception */); + const anna::xml::Attribute *if_attr = (*it)->getAttribute("ignoreFlagsOnValidation", false /* no exception */); std::string vm_value = vm_attr ? vm_attr->getValue() : "AfterDecoding"; std::string vd_value = vd_attr ? vd_attr->getValue() : "FirstError"; @@ -2249,6 +2249,10 @@ throw() { it->second->asXML(result); } + // Registered codec engines: + anna::diameter::codec::EngineManager &em = anna::diameter::codec::EngineManager::instantiate(); + em.asXML(result); + // OAM & statistics: oamAsXML(result); statsAsXML(result); diff --git a/example/diameter/launcher/deployments/st-client/configure.sh b/example/diameter/launcher/deployments/st-client/configure.sh index d174de6..2563d3f 100755 --- a/example/diameter/launcher/deployments/st-client/configure.sh +++ b/example/diameter/launcher/deployments/st-client/configure.sh @@ -102,7 +102,7 @@ echo "=====================================" echo "ADML SYSTEM TEST CONFIGURATION WIZARD" echo "=====================================" echo -[ -d ADMLS ] && _exit "ADMLS directory still exists. Please remove it to continue (perhaps you have to 'pkill ADML' before) !" +[ -d ADMLS ] && _exit "ADMLS directory still exists. Please remove it to continue (you may have to 'pkill ADML' before) !" [ ! -d services ] && _exit "Missing services configuration (expecting '$PWD/services' directory) !" calculate_deployment_layout @@ -190,6 +190,8 @@ do echo "Creating ADML instance $instance ..." mkdir -p ADMLS/ADML-$instance cd ADMLS/ADML-$instance + mkdir counters + mkdir test-reports # Create resources: ln -s ../../.operation-one.sh operation.sh ln -s ../../pre-start.sh diff --git a/example/diameter/launcher/deployments/st-client/operation_all.sh b/example/diameter/launcher/deployments/st-client/operation_all.sh index 8811381..e2efaa4 100755 --- a/example/diameter/launcher/deployments/st-client/operation_all.sh +++ b/example/diameter/launcher/deployments/st-client/operation_all.sh @@ -15,6 +15,10 @@ do echo -n "Instance `basename $dn_op`: " 0>launcher.trace ./operation.sh $@ + [ $? -ne 0 ] && { echo ; exit 1 ; } cd - >/dev/null done +echo +exit 0 + diff --git a/example/diameter/launcher/deployments/st-client/program.sh b/example/diameter/launcher/deployments/st-client/program.sh index b02fd2d..84c66e9 100755 --- a/example/diameter/launcher/deployments/st-client/program.sh +++ b/example/diameter/launcher/deployments/st-client/program.sh @@ -22,8 +22,11 @@ _exit() { usage() { echo "Usage: $0 [-s]" echo + echo " Performs test case programming from scratch (current test cases will be dropped from ADML involved instances)." + echo echo " test stuff directory: contains msk files, specially a testcase description with xml files referenced." echo " Those files, adding .msk extension, shall exists in the same directory. For example:" + echo echo " $0 st_examples/DynamicQualification" echo echo " -s: start testing just after programming, using desired rate: $DESIRED_RATE test cases per second." @@ -52,6 +55,8 @@ miss_conf= echo [ -z "$1" ] && usage +./operation.sh --ping +[ $? -ne 0 ] && _exit "Programming aborted (some ADML client process is not running) !" TESTCASE_DIR=$1 AUTOSTART=$2 diff --git a/example/diameter/launcher/deployments/st-client/run_all.sh b/example/diameter/launcher/deployments/st-client/run_all.sh index d9a33aa..ab95c73 100755 --- a/example/diameter/launcher/deployments/st-client/run_all.sh +++ b/example/diameter/launcher/deployments/st-client/run_all.sh @@ -17,8 +17,7 @@ do done sleep 1 -echo "Now you could program the tests by mean script 'program.sh'. For example:" -echo " ./program.sh st_examples/DynamicQualification" +echo echo echo "To enable reports dump for failed tests, execute:" echo " ./operation.sh \"test|report|failed\"" @@ -26,5 +25,10 @@ echo echo "To stop the processes, you could execute:" echo " pgrep ADML-[0-9] | xargs kill" echo +echo "When running, use script 'program.sh' to configure the test cases." +echo "To program again, you should execute './configure.sh' script to" +echo " change the current testing setup." +echo echo "Done!" +echo diff --git a/example/diameter/launcher/deployments/st-client/services_example/services.msk b/example/diameter/launcher/deployments/st-client/services_example/services.msk index 51b50f3..56ae019 100644 --- a/example/diameter/launcher/deployments/st-client/services_example/services.msk +++ b/example/diameter/launcher/deployments/st-client/services_example/services.msk @@ -1,7 +1,7 @@ - - + + diff --git a/example/diameter/launcher/resources/scripts/clone.sh b/example/diameter/launcher/resources/scripts/clone.sh index c84423d..747e8b0 100755 --- a/example/diameter/launcher/resources/scripts/clone.sh +++ b/example/diameter/launcher/resources/scripts/clone.sh @@ -1,4 +1,11 @@ #!/bin/bash +##################################################### +#### #### +## ## +# THIS SCRIPT IS NORMALLY INTENDED FOR INTERNAL USE # +## ## +#### #### +##################################################### ############# # VARIABLES # @@ -7,6 +14,7 @@ CLONE_WKDIR=$(mktemp -d) #MAX_NUMBER_GROUPS=400 MAX_NUMBER_GROUPS=200 # (depends on the machine) +CLONE_EXTRA_VARS_SCR_BN=clone-extra-vars.sh ############# # FUNCTIONS # @@ -39,19 +47,18 @@ usage() { echo " testcase variable file: path to the testcase file with parseable variables, for example '/testcase.txt.msk'." echo " xml files within this test case, must exist with aditional .msk extension in the same directory." echo - echo " Currently, 9 variables are supported to be replaced:" + echo " Currently, 4 variables are supported to be replaced:" echo echo " * __TESTID__ : sequence number. For example if you provide 1 to 20 for this script, it will be 1 .. 20" echo " * __SEQ8__ : 8-digit number corresponding to the sequence number (00000001 for 1, and so on)" echo " * __IPV4HEX__ : hexadecimal IPv4 address, for example: 00000001" echo " * __IPV4__ : IPv4 address, for example: 0.0.0.1" echo - #echo " One variant (former ones plus 1):" - #echo " __SEQ8P1__ : 8-digit number corresponding to the sequence number (00000002 for 1, and so on)" - #echo " __IPV4HEXP1__: hexadecimal IPv4 address, for example: 00000002" - #echo " __IPV4P1__ : IPv4 address, for example: 0.0.0.2" - #echo - echo " Edit the variables section to add more special values if you need them." + echo " Optionally (when exists), a user defined file '$CLONE_EXTRA_VARS_SCR_BN' is sourced to extend the parseable" + echo " variables used within the test case stuff (this script must be placed on that directory). The script" + echo " will be called with the sequence number as argument during clone procedure, and shall define the needed" + echo " variable values referenced in the parsed files. The variables must be named as '____' which ensures" + echo " that main clone script environment is not contaminated." echo echo " initial sequence: initial sequence number to parse over variables." echo " final sequence: final sequence number to parse over variables." @@ -95,32 +102,20 @@ clone() { local wkdir=$2 mkdir -p $wkdir - ############################################# SPECIAL VARIABLES SECTION ############################################# - ################################ EDIT THIS SECTION IF YOU NEED NEW SPECIAL VARIABLES ################################ + ############################################# VARIABLES SECTION ############################################# testid=$sequence seq8=$(printf "%08d" $testid) - #seq8_p1=$((seq8+1)) ipv4hex=$seq8 - #ipv4hex_p1=$seq8_p1 - #ipv4=$(for i in $(echo $seq8 | sed 's/\(..\)/0x\1 /g'); do printf "%d." $i; done | sed 's/\.$/\n/') # Numbers beginning with "0" are treated as octal (i.e. base-8): we would have 'invalid octal number with 08 and 09' # Solution: convert to base-10 in this way: $((10#$i)) ipv4=$(for i in $(echo $seq8 | sed 's/\(..\)/ \1 /g'); do printf "%d." $((10#$i)); done | sed 's/\.$/\n/') - #ipv4_p1=$(for i in $(echo $seq8_p1 | sed 's/\(..\)/ \1 /g'); do printf "%d." $((10#$i)); done | sed 's/\.$/\n/') - - local target=$wkdir/values.${1} - echo "__TESTID__=$testid" > $target - echo "__SEQ8__=$seq8" >> $target - echo "__IPV4HEX__=$ipv4hex" >> $target - echo "__IPV4__=$ipv4" >> $target - ## First variant: - #echo "__SEQ8P1__=$seq8_p1" >> $target - #echo "__IPV4HEXP1__=$ipv4hex_p1" >> $target - #echo "__IPV4P1__=$ipv4_p1" >> $target - source $target - #rm $target - ######################################### END SPECIAL VARIABLES SECTION ######################################### + __TESTID__=$testid + __SEQ8__=$seq8 + __IPV4HEX__=$ipv4hex + __IPV4__=$ipv4 + [ -n "$extra_vars" ] && source $CLONE_EXTRA_VARS_SCR_FILE $sequence + ######################################### END VARIABLES SECTION ######################################### # Parse template files: parse_file $sequence $TESTCASE_TEMPLATE $wkdir/testcase.txt.$sequence @@ -166,6 +161,9 @@ N_GROUPS=$5 POPULATION=$6 POPULATION_FILE=$TESTCASE_TEMPLATE_DIR/$POPULATION POPULATION_ALL=$TESTCASE_TEMPLATE_DIR/${POPULATION}.all +CLONE_EXTRA_VARS_SCR_FILE=$TESTCASE_TEMPLATE_DIR/$CLONE_EXTRA_VARS_SCR_BN +extra_vars= +[ -f $CLONE_EXTRA_VARS_SCR_FILE ] && extra_vars=yes [ "$4" = "" ] && usage @@ -202,6 +200,7 @@ timestamp_begin=$(echo "scale=3 ; $(date '+%s') + $(date '+%N') / 1000000000" | children_before=$(children) offset=0 $OPERATION "test|clear" +[ $? -ne 0 ] && _exit "Clone aborted: failed to clean tests !" echo "Please be patient, this may take a while ..." #echo "Temporary directory: $CLONE_WKDIR" for group in `seq 1 $((N_GROUPS+1))` diff --git a/example/diameter/launcher/resources/scripts/operation_signal.sh b/example/diameter/launcher/resources/scripts/operation_signal.sh index da0449b..04684bd 100755 --- a/example/diameter/launcher/resources/scripts/operation_signal.sh +++ b/example/diameter/launcher/resources/scripts/operation_signal.sh @@ -16,7 +16,7 @@ _exit() { usage() { echo - echo "Usage: $0 [-h|--help] [-t|--timeout ] [-f|--file] " + echo "Usage: $0 [-h|--help] [-t|--timeout ] [-f|--file] [-p|--ping] " echo echo " -h|--help: this usage help." echo " -t|--timeout: timeout for operation in seconds." @@ -26,6 +26,9 @@ usage() { echo " with one operation per line. If missing, it will be" echo " a single operation string." echo + echo " -p|--ping: Check the target process id." + echo " Returns 1 (dead) or 0 (alive)." + echo echo " data: operation string or file with several operations." echo echo " For example:" @@ -40,6 +43,7 @@ parse_arguments() { is_file= timeout=$TIMEOUT__dflt data= + ping= while [ $# -gt 0 ]; do case $1 in @@ -61,6 +65,10 @@ parse_arguments() { shift ;; + -p|--ping) + ping=yes + ;; + *) first=$(echo $1 | cut -c1) [ "$first" = "-" ] && _exit "Unsupported script option: $1. Type '$SCR_BN -h' (or --help) to print the available options." @@ -70,13 +78,13 @@ parse_arguments() { shift done - [ -z "$data" ] && _exit "Missing data value" + [ -z "$ping" -a -z "$data" ] && _exit "Missing data value" } # $1: pid to check check_pid() { kill -0 $1 2>/dev/null - [ $? -ne 0 ] && _exit "Operation error: missing process with pid $1" + return $? } ############# @@ -91,6 +99,12 @@ PID=`cat .pid` [ "$1" = "" -o "$1" = "--help" -o "$1" = "-h" ] && usage parse_arguments $@ +# Check pid: +check_pid $PID +res=$? +[ -n "$ping" ] && exit $res +[ $res -ne 0 ] && _exit "Operation error: missing process with pid $PID" + # Send operation: if [ -n "$is_file" ] then diff --git a/example/diameter/launcher/testing/TestStep.cpp b/example/diameter/launcher/testing/TestStep.cpp index e58bb0b..810565b 100644 --- a/example/diameter/launcher/testing/TestStep.cpp +++ b/example/diameter/launcher/testing/TestStep.cpp @@ -334,6 +334,9 @@ throw() { xmlmsg += a_messageCodec->asXMLString(); xmlmsg += "\n"; } + else { + xmlmsg = ""; + } if (msg != "") result->createAttribute("Message", msg); if (xmlmsg != "") result->createAttribute("XMLMessage", xmlmsg); @@ -570,6 +573,9 @@ throw() { xmlmsg += a_messageCodec->asXMLString(); xmlmsg += "\n"; } + else { + xmlmsg = ""; + } if (msg != "") result->createAttribute("MatchedMessage", msg); if (xmlmsg != "") result->createAttribute("MatchedXMLMessage", xmlmsg); diff --git a/include/anna/diameter/codec/EngineManager.hpp b/include/anna/diameter/codec/EngineManager.hpp index 268e318..69e063e 100644 --- a/include/anna/diameter/codec/EngineManager.hpp +++ b/include/anna/diameter/codec/EngineManager.hpp @@ -20,6 +20,10 @@ namespace anna { +namespace xml { + class Node; + +} namespace diameter { namespace codec { @@ -119,6 +123,13 @@ public: */ bool selectFromApplicationId (void) throw() { return a_autoSelectFromApplicationId; } + /** + Class XML representation. + \param parent XML node over which we will put instance information. + \return XML documentcon with class content. + */ + virtual anna::xml::Node* asXML(anna::xml::Node* parent) const throw(); + friend class anna::Singleton ; }; diff --git a/source/diameter/codec/EngineManager.cpp b/source/diameter/codec/EngineManager.cpp index 68add2b..2eb6f78 100644 --- a/source/diameter/codec/EngineManager.cpp +++ b/source/diameter/codec/EngineManager.cpp @@ -8,9 +8,12 @@ // Project #include +#include #include #include #include +#include + using namespace anna::diameter::codec; @@ -26,3 +29,14 @@ void EngineManager::registerCodecEngine(const ApplicationId &appid, Engine* engi if (!engine) return; // nothing done a_appid_codec_engines[appid] = engine; } + +anna::xml::Node* EngineManager::asXML(anna::xml::Node* parent) const +throw() { + anna::xml::Node* result = parent->createChild("EngineManager"); + appid_codec_engines_it it_min(a_appid_codec_engines.begin()); + appid_codec_engines_it it_max(a_appid_codec_engines.end()); + for (appid_codec_engines_it it = it_min; it != it_max; it++) + it->second->asXML(result); + + return result; +}