X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=example%2Fdiameter%2Flauncher%2Fresources%2Fscripts%2Fclone.sh;h=099aa7fcc49aeffdc057c20a1b7baaf780556b8d;hb=0df06e9ac54caeec9d29bb11e0b61befec83110b;hp=c6560f3f2a37529fa643b5bcc8cba7e4ae7e6614;hpb=983eaadca6cfae987be3453853d75bb9bce04487;p=anna.git diff --git a/example/diameter/launcher/resources/scripts/clone.sh b/example/diameter/launcher/resources/scripts/clone.sh index c6560f3..099aa7f 100755 --- a/example/diameter/launcher/resources/scripts/clone.sh +++ b/example/diameter/launcher/resources/scripts/clone.sh @@ -28,7 +28,7 @@ sig_handler() { } usage() { - echo "Usage: $0 [number of groups]" + echo "Usage: $0 [number of groups] [population]" echo echo " ADML directory: path to the ADML directory where 'operation.sh' script is used to load the test cases." echo " testcase variable file: path to the testcase file with parseable variables, for example '/testcase.txt.msk'." @@ -43,13 +43,22 @@ usage() { echo " __SRX1_SUFFIX__: \"" echo " __SGX2_SUFFIX__: 2<8-digit sequence>" echo " __SRX2_SUFFIX__: \"" + echo " Edit the variables section to add more special values if you need them." echo echo " initial sequence: initial sequence number to parse over variables." echo " final sequence: final sequence number to parse over variables." echo " number of groups: number of background group jobs to clone the provided sequence range." - echo " By default, it will be the number of items divided by 25, with a maximum of $MAX_NUMBER_GROUPS." - echo - echo + echo " By default (or if you provide \"\"), it will be the number of items divided by 25, with a maximum" + echo " of $MAX_NUMBER_GROUPS." + echo " population: Optionally, a population file (basename) can be provided. It must exist on the same directory" + echo " than other stuff (testcase, xml files). The behaviour will be the accumulation of every parsing" + echo " operation during clone procedure regarding the templated content of the population file. The" + echo " accumulated content will be dump over a new file created together with cloned and" + echo " named with the extension '.all' (.all). This population file could be useful to" + echo " specify database commands related to each sequence (each single testcase), in order to have" + echo " the whole population file. This won't include common database elements for the tested scenary," + echo " which shall be provisioned in a separated procedure." + echo _exit } @@ -78,7 +87,8 @@ clone() { local wkdir=$2 mkdir -p $wkdir - # Values: + ############################################# SPECIAL VARIABLES SECTION ############################################# + ################################ EDIT THIS SECTION IF YOU NEED NEW SPECIAL VARIABLES ################################ testid=$sequence seq8=$(printf "%08d" $testid) msisdn9=6${seq8} @@ -105,6 +115,8 @@ clone() { echo "__SRX2_SUFFIX__=$srx2_suffix" >> $target source $target #rm $target + ######################################### END SPECIAL VARIABLES SECTION ######################################### + # Parse template files: parse_file $sequence $TESTCASE_TEMPLATE $wkdir/testcase.txt.$sequence @@ -117,6 +129,13 @@ clone() { done cat $wkdir/testcase.txt.$sequence >> $wkdir/testcase.txt rm $wkdir/testcase.txt.$sequence + + # Population: + if [ -n "$POPULATION_FILE" ] + then + parse_file $sequence $POPULATION_FILE $CLONE_WKDIR/${POPULATION}.$sequence + cat $CLONE_WKDIR/${POPULATION}.$sequence >> $POPULATION_ALL + fi } # $1: group number; $2: initial subrange value; $3: final subrange value @@ -124,7 +143,7 @@ clone_group() { for i in `seq $2 $3` do clone $i $CLONE_WKDIR/$1 - #sleep 0.01 + sleep 0.01 done } @@ -136,9 +155,13 @@ trap sig_handler SIGTERM ADML_DIR=$1 TESTCASE_TEMPLATE=`readlink -f $2` +TESTCASE_TEMPLATE_DIR=`dirname $TESTCASE_TEMPLATE` CLONE_SEQ_BEGIN=$3 CLONE_SEQ_END=$4 N_GROUPS=$5 +POPULATION=$6 +POPULATION_FILE=$TESTCASE_TEMPLATE_DIR/$POPULATION +POPULATION_ALL=$TESTCASE_TEMPLATE_DIR/${POPULATION}.all [ "$4" = "" ] && usage @@ -147,7 +170,14 @@ OPERATION=$ADML_DIR/operation.sh [ ! -f $OPERATION ] && _exit "Missing '$OPERATION' file !!" [ ! -f $TESTCASE_TEMPLATE ] && _exit "Missing '$TESTCASE_TEMPLATE' testcase template file !!" -TESTCASE_TEMPLATE_DIR=`dirname $TESTCASE_TEMPLATE` +if [ -n "$POPULATION" ] +then + bn_population=`basename $POPULATION` + [ "$bn_population" != "$POPULATION" ] && _exit "Only basename is allowed for population provided !!" + [ ! -f $POPULATION_FILE ] && _exit "Missing provided population file '$POPULATION_FILE' !!" + 0> $POPULATION_ALL +fi + N_ITEMS=$((CLONE_SEQ_END - CLONE_SEQ_BEGIN + 1)) if [ -z "$N_GROUPS" ] then @@ -167,8 +197,9 @@ fi timestamp_begin=$(echo "scale=3 ; $(date '+%s') + $(date '+%N') / 1000000000" | bc) children_before=$(children) offset=0 -echo "Please be patient, this may take a while ..." $OPERATION "test|clear" +echo "Please be patient, this may take a while ..." +#echo "Temporary directory: $CLONE_WKDIR" for group in `seq 1 $((N_GROUPS+1))` do n_begin=$((CLONE_SEQ_BEGIN + offset)) @@ -178,7 +209,6 @@ do clone_group $group $n_begin $n_end & offset=$((group * GROUPS_SIZE)) done -children_now=$(children) # Wait background jobs to finish: while true