#############
# VARIABLES #
#############
+CWD=$(dirname $0)
MAXIMUM_ADML_ASYNC_RATE=50
MAXIMUM_SUGGESTED_CLIENT_CONNECTION_PER_ADML_INSTANCE=10
ADML_INSTANCES__ST_CONF_FILE=.st_conf_adml_instances
# FUNCTIONS #
#############
_exit () {
- echo
- echo $1
- echo
- exit 1
+ echo -e "\n$1\n"
+
+ # Cleanup:
+ cd $CWD
+ rm -rf ADMLS.tmp
+ cd services
+ rm -f cer*.xml services.xml *.msk2
+
+ rc=1
+ [ -n "$2" ] && rc=$2
+ exit $rc
+}
+
+sig_handler () {
+ _exit "Script interrupted. Cleanup & exit ..."
}
# ceil of division $1/$2
read max_server_accepted_connections
[ "$max_server_accepted_connections" = "" ] && max_server_accepted_connections=5000
- echo "Input the maximum test case rate per second:"
+ echo "Input the maximum desired test case rate per second:"
read desired_rate
while [ -z "$desired_rate" ]; do read desired_rate; done
G_ADML_CONNECTIONS=1
G_ADML_INSTANCES=1
return
- fi
- max_adml_instances=$((max_server_accepted_connections/MAXIMUM_SUGGESTED_CLIENT_CONNECTION_PER_ADML_INSTANCE))
- if [ $max_connections -gt $max_server_accepted_connections ]
+ elif [ $max_connections -gt $max_server_accepted_connections ]
then
- echo
- echo "Maximum rate reached for $max_server_accepted_connections server connections:"
- G_ADML_CONNECTIONS=$MAXIMUM_SUGGESTED_CLIENT_CONNECTION_PER_ADML_INSTANCE
- G_ADML_INSTANCES=$max_adml_instances
- return
+ _exit "Not enough server connections to fit the desired rate (requires $max_connections connections)."
fi
echo
echo "==========================================================================================================="
echo "Orientative table"
echo "-----------------------------------------------------------------------------------------------------------"
- echo -e "Connects per instance:\t1\t2\t3\t4\t5\t6\t7\t8\t9\t10"
echo -n "Number of instances: "
- for conn in `seq 1 $MAXIMUM_SUGGESTED_CLIENT_CONNECTION_PER_ADML_INSTANCE`
+ instances__dflt=$(ceil $max_connections $MAXIMUM_SUGGESTED_CLIENT_CONNECTION_PER_ADML_INSTANCE)
+ for conn in `seq 1 $MAXIMUM_SUGGESTED_CLIENT_CONNECTION_PER_ADML_INSTANCE | tac`
do
instances=$(ceil $max_connections $conn)
echo -n -e "\t$instances"
+ [ $conn -eq 1 ] && instances__dflt=$instances
done
echo
+ echo -e "Connects per instance:\t10\t9\t8\t7\t6\t5\t4\t3\t2\t1"
echo "==========================================================================================================="
echo
- echo "Input selection (connections per instance 1..$MAXIMUM_SUGGESTED_CLIENT_CONNECTION_PER_ADML_INSTANCE) [1]:"
- read G_ADML_CONNECTIONS
- [ -z "$G_ADML_CONNECTIONS" ] && G_ADML_CONNECTIONS=1
- [ $G_ADML_CONNECTIONS -lt 1 ] && G_ADML_CONNECTIONS=1
-# if [ $G_ADML_CONNECTIONS -gt 1 ]
-# then
-# echo "Remember to add 'diameterServerSessions="$G_ADML_CONNECTIONS"' on servers services.xml file (node tag)"
-# echo " in case that you are testing against ADML servers."
-# echo
-# echo "Press ENTER to continue, CTRL-C to abort ..."
-# read dummy
-# fi
+ #echo "Input selection (connections per instance 1..$MAXIMUM_SUGGESTED_CLIENT_CONNECTION_PER_ADML_INSTANCE) [1]:"
+ echo "Input the desired number of ADML instances [$instances__dflt]:"
+ echo " (more than $instances instances, implies 1 single connection/instance)"
+ read G_ADML_INSTANCES
+ [ -z "$G_ADML_INSTANCES" ] && G_ADML_INSTANCES=$instances__dflt
+ [ $G_ADML_INSTANCES -lt 1 ] && G_ADML_INSTANCES=1
+ G_ADML_CONNECTIONS=$(ceil $max_connections $G_ADML_INSTANCES)
if [ $G_ADML_CONNECTIONS -gt $MAXIMUM_SUGGESTED_CLIENT_CONNECTION_PER_ADML_INSTANCE ]
then
- G_ADML_CONNECTIONS=$MAXIMUM_SUGGESTED_CLIENT_CONNECTION_PER_ADML_INSTANCE
+ echo "Warning: the number of connections per ADML instance ($G_ADML_CONNECTIONS) is greater"
+ echo " than the maximum recommended: $MAXIMUM_SUGGESTED_CLIENT_CONNECTION_PER_ADML_INSTANCE"
+ echo
+ echo "Press ENTER to continue, CTRL-C to abort ..."
+ read dummy
+ fi
+ client_connections=$((G_ADML_INSTANCES*G_ADML_CONNECTIONS))
+ if [ $client_connections -gt $max_server_accepted_connections ]
+ then
+ echo
+ echo "Insufficient server connections available ($max_server_accepted_connections) to accept"
+ echo " launcher client connections: $G_ADML_INSTANCES x $G_ADML_CONNECTIONS = $client_connections."
+ _exit "Configuration error"
fi
-
- G_ADML_INSTANCES=$(ceil $max_connections $G_ADML_CONNECTIONS)
}
#############
# EXECUTION #
#############
-cd `dirname $0`
+trap sig_handler INT QUIT TERM
+
+cd $CWD
echo
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 realms ] && _exit "Missing realms configuration (expecting '$PWD/realms' directory). Try with 'realms-example' and see README inside it !"
+
+[ ! -d services ] && _exit "Missing services configuration (expecting '$PWD/services' directory).\nTake a look to 'services_example' and './dynlibs' scenaries stuff to complete your services.\n\nFor example:\n ln -s services_example services\n cp dynlibs/gx/00001/services/* services\n Edit CER files and 'services.msk' there, to fit your needs."
calculate_deployment_layout
+# Format for instance number (for example: 1 -> 001, .., 45 -> 045, 300 -> 300)
+INSTANCE_FORMAT=$(echo $G_ADML_INSTANCES | wc -c)
+INSTANCE_FORMAT=$((INSTANCE_FORMAT-1))
+
# Dump persintently:
echo $G_ADML_INSTANCES > $ADML_INSTANCES__ST_CONF_FILE
echo $G_ADML_CONNECTIONS > $ADML_CONNECTIONS__ST_CONF_FILE
# Rate per instance:
-#rate_per_instance=$(ceil $desired_rate $G_ADML_INSTANCES)
rate_per_instance=$((desired_rate/$G_ADML_INSTANCES))
[ $rate_per_instance -lt 1 ] && rate_per_instance=1
echo $rate_per_instance > $ADML_RATE_PER_INSTANCE__ST_CONF_FILE
echo $desired_rate > $ADML_DESIRED_RATE__ST_CONF_FILE
echo
-echo "Suggested layout:"
+echo "Layout:"
+echo
echo " - $G_ADML_INSTANCES ADML instances"
echo " - $G_ADML_CONNECTIONS client connections per ADML instance"
maximum_rate=$((G_ADML_INSTANCES*G_ADML_CONNECTIONS*MAXIMUM_ADML_ASYNC_RATE))
-echo " - Maximum rate: $maximum_rate test cases per second"
+overcommit_rate_per_instance=$((G_ADML_CONNECTIONS*MAXIMUM_ADML_ASYNC_RATE))
echo
-echo "Usually, you will program a test case per subscriber. Input the number of test cases to program:"
+echo " - Desired rate: $desired_rate test cases per second:"
+echo " Remember the command to send the needed rate per instance ($rate_per_instance TCs/sec):"
+echo " ./operation.sh \"test|ttps|$rate_per_instance\""
+echo
+if [ $maximum_rate -ne $desired_rate ]
+then
+ echo " - Maximum bunch rate ($G_ADML_CONNECTIONS connections per instance): $maximum_rate testcases/second"
+ echo " For this, configure instances rate to $overcommit_rate_per_instance test cases per second:"
+ echo " ./operation.sh \"test|ttps|$overcommit_rate_per_instance\""
+ echo
+fi
+echo "Usually, you will program a test case per subscriber."
+echo "Input the number of test cases to program:"
read N_TESTCASES
while [ -z "$N_TESTCASES" ]; do read N_TESTCASES; done
echo $N_TESTCASES > $N_TESTCASES__ST_CONF_FILE
-testcase_per_adml_instance=$N_TESTCASES
+echo "Input the first test id to program [1]:"
+read first_value
+[ "$first_value" = "" ] && first_value=1
+[ $first_value -lt 1 ] && first_value=1
echo
-time_covered_1=$(ceil $N_TESTCASES $maximum_rate)
-time_covered=$(ceil $N_TESTCASES $((maximum_rate*G_ADML_INSTANCES)))
-echo "That amount covers $time_covered_1 seconds for one running ADML instance."
-if [ $G_ADML_INSTANCES -gt 1 ]
-then
- echo "But you will have $G_ADML_INSTANCES instances running in parallel, then the total covered time is: $time_covered seconds"
- testcase_per_adml_instance=$((N_TESTCASES/G_ADML_INSTANCES))
- echo "(aproximately, $testcase_per_adml_instance test cases will be programmed on each ADML instance)"
-fi
-
-0>$N_TESTCASES_PROGRAM_LAYOUT__ST_CONF_FILE
-for instance in `seq 1 $G_ADML_INSTANCES`
-do
- offset=$((testcase_per_adml_instance * (instance-1)))
- ini=$((offset + 1))
- fin=$((offset + testcase_per_adml_instance))
- echo "$instance $ini $fin" >> $N_TESTCASES_PROGRAM_LAYOUT__ST_CONF_FILE
-done
+time_covered=$(echo "$N_TESTCASES/$desired_rate" | bc)
+testcase_per_adml_instance=$((N_TESTCASES/G_ADML_INSTANCES))
+echo "Aproximately, $testcase_per_adml_instance test cases will be programmed on each ADML instance (we have $G_ADML_INSTANCES instances)."
+echo "As we shall program $N_TESTCASES test cases, the total time covered for the desired system rate of $desired_rate cps, is $time_covered seconds."
echo
-if [ $time_covered -lt 300 ]
+if [ $time_covered -lt 10 ]
then
- echo "$time_covered seconds is under 5 minutes, you should add more test cases to the pool except if you are sure"
+ echo "$time_covered seconds is under 10 seconds, you should add more test cases to the pool except if you are sure"
echo " they will take less time that cycle completion. You could ensure that with a first timeout step."
echo "Configuring such timeout slightly under $((1000*time_covered)) milliseconds, you could repeat the cycle safely to"
echo " obtain a greater total time of testing."
fi
echo
-echo "How many total time do you want to cover (in minutes):"
+echo "How many total time you need to cover (in minutes):"
read minutes
while [ -z "$minutes" ]; do read minutes; done
seconds=$((minutes*60))
-repeats=$(ceil $seconds $time_covered)
-echo $repeats > $CYCLE_REPEATS__ST_CONF_FILE
-[ $repeats -gt 0 ] && echo "Configured $repeats cycle repeats ($repeats x $time_covered seconds ~ $seconds seconds (desired $minutes minutes)"
+repeats=0
+[ $seconds -gt $time_covered -a $time_covered -gt 0 ] && { repeats=$(ceil $seconds $time_covered) ; repeats=$((repeats-1)) ; }
+if [ $repeats -gt 0 ]
+then
+ cycles=$((repeats+1))
+ echo "You will need $cycles cycles to cover $minutes minutes."
+ echo "Input the desired number of cycles [$cycles]: "
+ echo " (providing 1, you will cover $time_covered seconds)"
+ echo
+ read wanted_cycles
+ [ -z "$wanted_cycles" ] && wanted_cycles=$cycles
+ wanted_repeats=$((wanted_cycles-1))
+ echo $wanted_cycles > $CYCLE_REPEATS__ST_CONF_FILE
+ [ $wanted_repeats -gt 0 ] && echo "Configured $wanted_repeats cycle repeats ($wanted_cycles cycles x $time_covered seconds ~ $((wanted_cycles*time_covered)) seconds of testing)."
+else
+ echo 0 > $CYCLE_REPEATS__ST_CONF_FILE
+fi
+
+# Single vs multiple peer:
+echo
+echo "Select [s]ingle peer or (m)ultiple peer [s]:"
+read opt
+peer_seq=
+[ -z "$opt" ] && opt=s
+[ "$opt" = "m" ] && { peer_seq=1 ; echo "Origin-Host will be sequenced for each ADML instance." ; }
+
echo
echo "System test configuration completed."
echo
read dummy
# Update services.xml regarding the number of client connections:
-cd realms
-cp services.msk services.xml
-sed -i 's/__CLIENT_CONNECTIONS__/'$G_ADML_CONNECTIONS'/g' services.xml
-cd - >/dev/null
+cd services
+cp services.msk services.msk2
+for cer in $(ls cer*.msk 2>/dev/null); do cp $cer ${cer}2; done
+cd ..
+sed -i 's/__CLIENT_CONNECTIONS__/'$G_ADML_CONNECTIONS'/g' services/services.msk2
-for instance in `seq 1 $G_ADML_INSTANCES`
+# Create instances and layout:
+0>$N_TESTCASES_PROGRAM_LAYOUT__ST_CONF_FILE
+for i in `seq 1 $G_ADML_INSTANCES`
do
- echo "Creating ADMLS/$instance ..."
- mkdir -p ADMLS/$instance
- cd ADMLS/$instance
+ instance=$(printf "%0${INSTANCE_FORMAT}d" $i)
+ offset=$((testcase_per_adml_instance * (i-1)))
+ ini=$((offset + first_value))
+ fin=$((offset + first_value + testcase_per_adml_instance - 1))
+ echo "$instance $ini $fin" >> $N_TESTCASES_PROGRAM_LAYOUT__ST_CONF_FILE
+
+ # Case of multiple peer:
+ sed 's/__PEER_SEQ__/'$peer_seq'/g' services/services.msk2 > services/services.xml
+ for cer in $(ls services/cer*.msk2 2>/dev/null)
+ do
+ cer_xml="${cer%.*}.xml"
+ sed 's/__PEER_SEQ__/'$peer_seq'/g' $cer > $cer_xml
+ done
+ [ -n "$peer_seq" ] && peer_seq=$((peer_seq+1))
+
+ echo "Creating ADML instance $instance ..."
+ mkdir -p ADMLS.tmp/ADML-$instance
+ cd ADMLS.tmp/ADML-$instance
+ mkdir counters
+ mkdir test-reports
+ ln -s ../../dynlibs
# Create resources:
ln -s ../../.operation-one.sh operation.sh
ln -s ../../pre-start.sh
cp ../../.run-one.sh run.sh
sed -i 's/^EXE=.*/EXE=ADML-'$instance'/' run.sh
- ln -s ../../ADML-launcher ADML-$instance
- for xml in `ls ../../realms/*xml`; do ln -s $xml; done
+ ln -s ../../ADML ADML-$instance
+ for xml in `ls ../../services/*xml`; do cp $xml .; done
cd - >/dev/null
done
+cd $CWD
+
+# Default ADMLS name:
+echo
+echo "Configured layout:"
+echo
+ADML_INSTANCES=`cat $ADML_INSTANCES__ST_CONF_FILE 2>/dev/null`
+ADML_CONNECTIONS=`cat $ADML_CONNECTIONS__ST_CONF_FILE 2>/dev/null`
+RATE_PER_INSTANCE=`cat $ADML_RATE_PER_INSTANCE__ST_CONF_FILE 2>/dev/null`
+DESIRED_RATE=`cat $ADML_DESIRED_RATE__ST_CONF_FILE 2>/dev/null`
+REPEATS=`cat $CYCLE_REPEATS__ST_CONF_FILE 2>/dev/null`
+N_TESTCASES=`cat $N_TESTCASES__ST_CONF_FILE 2>/dev/null`
+
+[ -n "$ADML_INSTANCES" ] && echo " $ADML_INSTANCES ADML instances."
+[ -n "$ADML_CONNECTIONS" ] && echo " $ADML_CONNECTIONS connections per ADML instance."
+[ -n "$RATE_PER_INSTANCE" ] && echo " Rate of $RATE_PER_INSTANCE TCs/second and instance."
+[ -n "$DESIRED_RATE" ] && echo " Desired rate was: $DESIRED_RATE TCs/second and instance."
+[ -n "$REPEATS" ] && echo " Number of cycles: $((REPEATS + 1))."
+[ -n "$N_TESTCASES" ] && echo " $N_TESTCASES test cases programmed."
+echo
+operation_result=$(echo "scale=3 ; (1 + $REPEATS) * $N_TESTCASES / $ADML_INSTANCES / $RATE_PER_INSTANCE" | bc)
+echo " Time covered: $((REPEATS + 1)) cycles x ($N_TESTCASES/(${ADML_INSTANCES}x${RATE_PER_INSTANCE})) = $operation_result seconds"
+echo
+ADMLS__dflt="ADMLS#${ADML_INSTANCES}instances.${ADML_CONNECTIONS}connectionsPerInstance"
+if [ -n "$peer_seq" ]
+then
+ ADMLS__dflt="${ADMLS__dflt}.MultiplePeer"
+else
+ ADMLS__dflt="${ADMLS__dflt}.SinglePeer"
+fi
+
+echo
+echo "Input a name for the ADMLS instances directory [$ADMLS__dflt]:"
+read ADMLS_NAME
+[ "$ADMLS_NAME" = "" ] && ADMLS_NAME=$ADMLS__dflt
+while [ -e "$ADMLS_NAME" ]
+do
+ ADMLS_NAME=
+ echo "Some file/directory already exists with that name ! Please, input another one:"
+ while [ -z "$ADMLS_NAME" ]; do read ADMLS_NAME; done
+done
+
+mv ADMLS.tmp $ADMLS_NAME
+rm -rf ADMLS
+ln -s $ADMLS_NAME ADMLS
+
echo
echo "Now you can run all the instances deployed: ./run.sh"
+echo "You could provide optional target: 'run.sh <another ADMLS directory>'."
+echo
+echo "To configure another layout you should execute this script again."
echo
-echo "Done!"
+_exit "Done!" 0