X-Git-Url: https://git.teslayout.com/public/public/public/?p=anna.git;a=blobdiff_plain;f=example%2Fdiameter%2Flauncher%2Fdeployments%2Fst-client%2Fprogram.sh;h=4d878c01db7da69fe450aafae8e1222ea181c59b;hp=84c66e98de92abc612c51850653c223d52613b2f;hb=e08f7cf02151389d0b871029ba0fba177157bb8d;hpb=1ac015cbbcd331edc3c14de26290d669d91e4e53 diff --git a/example/diameter/launcher/deployments/st-client/program.sh b/example/diameter/launcher/deployments/st-client/program.sh index 84c66e9..4d878c0 100755 --- a/example/diameter/launcher/deployments/st-client/program.sh +++ b/example/diameter/launcher/deployments/st-client/program.sh @@ -8,40 +8,91 @@ RATE_PER_INSTANCE=`cat .st_conf_rate_per_instance 2>/dev/null` DESIRED_RATE=`cat .st_conf_desired_rate 2>/dev/null` REPEATS=`cat .st_conf_cycle_repeats 2>/dev/null` PROGRAM_LAYOUT_FILE=.st_conf_n_testcases_program_layout +[ -z "$ADML_CONCURRENT_PROVISION_JOBS" ] && ADML_CONCURRENT_PROVISION_JOBS=20 ############# # FUNCTIONS # ############# _exit() { - echo - echo $1 - echo + echo -e "\n$1\n" exit 1 } 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." + cat << EOF +Usage: $0 [-s] + + Performs test case programming from scratch (current test cases will be dropped + from ADML involved instances). There are two types of programming depending on + the first argument provided: + + test stuff directory: + + The folder provided must contain msk files, specially a testcase file with + xml files referenced inside. Those xml files (without the .msk extension) + shall exists in the directory. For example: + + $0 st_examples/DynamicQualification + + Optionally, a file 'specific' could exists containing testcase-specific + information, which normally will be used to specify database sentences. + This file will be accumulated as a cloning seed over the file 'specific.all' + created on test stuff directory. + + Template type programming could be used for medium-duration testings, because + the scripting used for programming, have lots of groups divisions which even + background-executed are much more slower on programming than a c++ builtin + procedure: dynamic type is the one for large sets of test cases: + + + dynamic: + + The current dynamic procedure selected by mean 'dynlibs/select.sh' script, + will be programmed using its dirname resources: inside, you may found not + only the .so library but the needed xml files for the implemented scenary + and a file called 'dynamic.suffix' used to complete the dynamic operation + in this way: + + dynamic||| + + For example, you could have this content for 'dynamic.suffix': + + 0|7|CCR-I.xml|CCR-T.xml (0 for timeout means no timeout step) + + in order to generate the operation: + + dynamic|||0|7|CCR-I.xml|CCR-T.xml + + which would be parsed for the specific ADML instance programmed: + + dynamic|2000001|2001000|0|7|CCR-I.xml|CCR-T.xml + + The file 'dynamic.suffix' could have several lines for several scenaries. + In this case, this script will prompt for the desired one. + + This script will build every operation for the configured ADML instances + to complete all the sequence ranges along the whole test system. + + + + -s: start testing just after programming, using desired rate: $DESIRED_RATE test cases per second. +EOF [ $ADML_INSTANCES -gt 1 ] && echo " In your case, with $ADML_INSTANCES, a rate of $RATE_PER_INSTANCE ttps will be send per instance." echo _exit } -children () { - bash_pid=$$ - children=`ps -eo ppid | grep -w $bash_pid` - echo $children | wc -w +advice_to_squeeze_idle_cpu () { + local idle=$(top -b -d 0.1 -n 2 | grep 'Cpu(s):'| tail -1 | awk '{print $8}' | sed 's/,/./') + sleep 10 + echo + echo "Idle cpu now: $idle. Check the system CPU with top. If is not overcommited, consider" + echo " increase the environment variable 'ADML_CONCURRENT_PROVISION_JOBS' (now $ADML_CONCURRENT_PROVISION_JOBS)." + echo + echo "Press ENTER to continue ..." + read dummy } - ############# # EXECUTION # ############# @@ -55,62 +106,209 @@ miss_conf= echo [ -z "$1" ] && usage -./operation.sh --ping -[ $? -ne 0 ] && _exit "Programming aborted (some ADML client process is not running) !" -TESTCASE_DIR=$1 +echo "Testcases programming ..." +echo +cd `dirname $0` +./checkStatus.sh +[ $? -eq 1 ] && _exit "Fix status (instances) to continue ..." + +# We launch in background ! +#./operation.sh --ping >/dev/null +#[ $? -ne 0 ] && _exit "Programming aborted (some ADML client process is not running) !" + +# Arguments: +PROG_TYPE=$1 AUTOSTART=$2 -[ ! -d $TESTCASE_DIR ] && _exit "Cannot found the test directory '$TESTCASE_DIR' !!" -TESTCASE=( `ls $TESTCASE_DIR/testcase*msk 2>/dev/null` ) -TESTCASE_FILES=${#TESTCASE[@]} -[ $TESTCASE_FILES -ne 1 ] && _exit "One and only one 'testcase*msk' file must be present !!" - -MAX_NUMBER_GROUPS=$(grep ^MAX_NUMBER_GROUPS= clone.sh | cut -d= -f2) -CLONE_GROUPS=$((MAX_NUMBER_GROUPS/ADML_INSTANCES)) -#CLONE_GROUPS=1 - -children_before=$(children) -while read -r line -do - instance=$(echo $line | awk '{ print $1 }') - ini_seq=$(echo $line | awk '{ print $2 }') - fin_seq=$(echo $line | awk '{ print $3 }') - ADML_DIR=`readlink -f ADMLS/ADML-$instance` - ./clone.sh $ADML_DIR $TESTCASE $ini_seq $fin_seq $CLONE_GROUPS & - -done < $PROGRAM_LAYOUT_FILE - -# Wait background jobs to finish: -sleep 1 -echo "Waiting for clone completion ..." -while true -do - [ $(children) -eq $children_before ] && break - sleep 1 -done +# test case stuff programming ######################################################### +if [ "$PROG_TYPE" != "dynamic" ] +then + TESTCASE_DIR=$PROG_TYPE + + [ ! -d $TESTCASE_DIR ] && _exit "Cannot found the test directory '$TESTCASE_DIR' !!" + TESTCASE=( `ls $TESTCASE_DIR/testcase*msk 2>/dev/null` ) + TESTCASE_FILES=${#TESTCASE[@]} + [ $TESTCASE_FILES -ne 1 ] && _exit "One and only one 'testcase*msk' file must be present !!" + + MAX_NUMBER_GROUPS=$(grep ^MAX_NUMBER_GROUPS= clone.sh | cut -d= -f2) + CLONE_GROUPS=$((MAX_NUMBER_GROUPS/ADML_INSTANCES)) + #CLONE_GROUPS=1 + specific= + [ -f $TESTCASE_DIR/specific ] && specific=specific + + count=0 + while read -r line + do + instance=$(echo $line | awk '{ print $1 }') + ini_seq=$(echo $line | awk '{ print $2 }') + fin_seq=$(echo $line | awk '{ print $3 }') + ADML_DIR=`readlink -f ADMLS/ADML-$instance` + echo -e "\rCloning interval [$ini_seq,$fin_seq] for $(basename $ADML_DIR) ..." + ./clone.sh $ADML_DIR $TESTCASE $ini_seq $fin_seq $CLONE_GROUPS $specific & + sleep 0.1 + count=$((count+1)) + if [ $count -eq $ADML_CONCURRENT_PROVISION_JOBS ] + then + wait $(jobs -p) + count=0 + fi + + done < $PROGRAM_LAYOUT_FILE + + # Advice for idle cpu: + advice_to_squeeze_idle_cpu + + # Wait background jobs to finish: + sleep 5 + echo "Waiting for clone completion ..." + echo "(please be patient, this may take a while)" + echo + echo "Background Jobs: $(jobs -p | wc -l)" + wait $(jobs -p) + + echo + echo "Programming has finished !" + echo + + if [ -n "$specific" ] + then + echo "A new file '$TESTCASE_DIR/specific.all' has been created." + echo "Probably you need to apply it before starting traffic." + echo + echo "Press ENTER to continue, CTRL-C to abort ..." + read dummy + fi + +# dynamic programming ################################################################# +else + TESTCASE_DIR=$(readlink -f dynlibs/liblauncher_procedure_default_shared.so | xargs dirname) + DYNAMIC_SUFFIX_FILE=$TESTCASE_DIR/dynamic.suffix + + [ ! -f $DYNAMIC_SUFFIX_FILE ] && _exit "Missing '$DYNAMIC_SUFFIX_FILE' file.\nUse 'dynlibs/select.sh' to change the dynamic procedure and restart the ADML instances." + dynamic_suffix=( $(grep -v ^# $DYNAMIC_SUFFIX_FILE) ) + + # Multiple scenarios: + suffixes=${#dynamic_suffix[@]} + if [ $suffixes -gt 1 ] + then + echo + echo "----------------------------------------------------------------" + cat $DYNAMIC_SUFFIX_FILE + echo "----------------------------------------------------------------" + echo + echo "Detected $suffixes scenarios:" + echo + tmpfile=$(mktemp) + opt=1 + for line in $(grep -v ^# $DYNAMIC_SUFFIX_FILE) + do + echo "${opt}) $line" + opt=$((opt+1)) + done > $tmpfile + cat $tmpfile + echo + echo "Select the desired option (0 to input a user defined one):" + read option + while [ -z "$option" ]; do read option ; done + if [ "$option" != "0" ] + then + dynamic_suffix=$(grep "^${option}) " $tmpfile | cut -d" " -f2-) + [ -z "$dynamic_suffix" ] && _exit "Invalid option !" + else + echo "Input specific program arguments:" + echo " (be sure that are supported by the dynamic procedure)" + echo + read dynamic_suffix + while [ -z "$dynamic_suffix" ]; do read dynamic_suffix ; done + fi + fi + + # Modify xml files path: + xmls=( $(echo $dynamic_suffix | sed 's/'\|'/ /g') ) + dynamic_suffix=$(for xml in ${xmls[@]} + do + echo $xml | grep -q "\.xml$" + [ $? -eq 0 ] && echo -n "$TESTCASE_DIR/" + echo -n "${xml}|" + done | sed 's/'\|'$//') + + # If still idle CPU, you could increase chunks number of background jobs + echo "Dynamic programming ..." + echo + while read -r line + do + instance=$(echo $line | awk '{ print $1 }') + ini_seq=$(echo $line | awk '{ print $2 }') + fin_seq=$(echo $line | awk '{ print $3 }') + ADML_DIR=`readlink -f ADMLS/ADML-$instance` + + cd $ADML_DIR + ./operation.sh -t 60 "dynamic|$ini_seq|$fin_seq|$dynamic_suffix" & + sleep 0.1 + count=$((count+1)) + if [ $count -eq $ADML_CONCURRENT_PROVISION_JOBS ] + then + wait $(jobs -p) + count=1 + fi + cd - >/dev/null + + done < $PROGRAM_LAYOUT_FILE + + # Advice for idle cpu: + advice_to_squeeze_idle_cpu + +fi echo -echo "Programming has finished !" echo - echo "Configuring repeat cycles ..." -./operation.sh "test|repeats|$REPEATS" - +./operation.sh "test|repeats|$REPEATS" >/dev/null echo +echo "Done !" echo + start_testing= if [ "$AUTOSTART" = "-s" ] then start_testing=yes else - echo "Input desired rate (test cases per second) to start testing [0: nothing done]:" - read desired_rate - if [ "$desired_rate" != "" ] - then - rate_per_instance=$((desired_rate/$ADML_INSTANCES)) - [ $rate_per_instance -lt 1 ] && rate_per_instance=1 - ./operation.sh "test|ttps|$rate_per_instance" - fi + cat << EOF + +To start testing, you must use the './operation.sh' script. The most + common commands used for testing are: + + - Enable reports dump for failed tests: ./operation.sh "test|report|failed" + - Launch traffic: ./operation.sh "test|ttps|" + + (*) this is related to a single instance, because operation script launched + here invokes every 'ADMLS/ADML-/operation.sh' counterpart + script. Then, you should divide the desired CPS by the number of + instances. For example, if you need $DESIRED_RATE test cases per second, + as you have $ADML_INSTANCES instances, then you should execute: + + ./operation.sh "test|ttps|$RATE_PER_INSTANCE" + + - Stop traffic: ./operation.sh "test|ttps|0" + - Reset already classified (Success/Failed) test cases: ./operation.sh "test|reset[|soft]" + - Reset also 'in-progress' state test cases: ./operation.sh "test|reset|hard" + - Clear programmed test cases: ./operation.sh "test|clear" + +Remember that './operation.sh' broadcasts the operation scripts inside + the ADML instances, then some operations should better be used within + a specific 'ADMLS/ADML-' directory to avoid console spam: + + - Check a testcase in runtime: ADMLS/ADML-001/operation.sh "test|look|" + - Execute the next programmed test case: ADMLS/ADML-001/operation.sh "test|next" + - Interactive-step execution: ADMLS/ADML-001/operation.sh "test|interact||" + - Summary: ADMLS/ADML-001/operation.sh "test|summary" + +For a complete and detailed information, execute: ./operation.sh --help | less + +You could also use './launchCPS.sh' script. + +EOF + fi if [ -n "$start_testing" ]