Testing library separation: now not in launcher but isolated
[anna.git] / example / diameter / launcher / deployments / st-client / configure.sh
index b818a78..21e3112 100755 (executable)
@@ -57,17 +57,18 @@ calculate_deployment_layout() {
   echo "Orientative table"
   echo "-----------------------------------------------------------------------------------------------------------"
   echo -n "Number of instances:  "
+  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]:"
-  instances__dflt=$(ceil $max_connections $MAXIMUM_SUGGESTED_CLIENT_CONNECTION_PER_ADML_INSTANCE)
   echo "Input the desired number of ADML instances [$instances__dflt]:"
   echo " (more than $instances instances, implies 1 single connection/instance)"
   read G_ADML_INSTANCES
@@ -77,7 +78,7 @@ calculate_deployment_layout() {
   if [ $G_ADML_CONNECTIONS -gt $MAXIMUM_SUGGESTED_CLIENT_CONNECTION_PER_ADML_INSTANCE ]
   then
     echo "Warning: the number of connections per ADML instance ($G_ADML_CONNECTIONS) is greater"
-    echo "         than the maximum suggested: $MAXIMUM_SUGGESTED_CLIENT_CONNECTION_PER_ADML_INSTANCE"
+    echo "         than the maximum recommended: $MAXIMUM_SUGGESTED_CLIENT_CONNECTION_PER_ADML_INSTANCE"
     echo
     echo "Press ENTER to continue, CTRL-C to abort ..."
     read dummy
@@ -135,12 +136,15 @@ fi
 
 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
@@ -151,7 +155,6 @@ echo "Layout:"
 echo
 echo " - $G_ADML_INSTANCES ADML instances"
 echo " - $G_ADML_CONNECTIONS client connections per ADML instance"
-#maximum_rate_1c=$((G_ADML_INSTANCES*MAXIMUM_ADML_ASYNC_RATE))
 maximum_rate=$((G_ADML_INSTANCES*G_ADML_CONNECTIONS*MAXIMUM_ADML_ASYNC_RATE))
 overcommit_rate_per_instance=$((G_ADML_CONNECTIONS*MAXIMUM_ADML_ASYNC_RATE))
 echo
@@ -171,35 +174,20 @@ 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 $desired_rate)
-time_covered=$(ceil $N_TESTCASES $((desired_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 + first_value))
-  fin=$((offset + first_value + testcase_per_adml_instance - 1))
-  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."
@@ -209,17 +197,22 @@ 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)
+repeats=0
+[ $seconds -gt $time_covered ] && { repeats=$(ceil $seconds $time_covered) ; repeats=$((repeats-1)) ; }
 if [ $repeats -gt 0 ]
 then
-  echo "You will need $repeats cycles to cover $minutes minutes."
-  echo "Input the number of cyles [$repeats]: "
-  echo " (providing 0, you will cover $time_covered seconds)"
+  cycles=$((repeats+1))
+  echo "You will need $cycles cycles to cover $minutes minutes."
+  echo "Input the desired number of cyles [$cycles]: "
+  echo " (providing 1, you will cover $time_covered seconds)"
   echo
-  read wanted_repeats
-  [ -z "$wanted_repeats" ] && wanted_repeats=$repeats
-  echo $wanted_repeats > $CYCLE_REPEATS__ST_CONF_FILE
-  [ $wanted_repeats -gt 0 ] && echo "Configured $wanted_repeats cycle repeats ($((wanted_repeats+1)) x $time_covered seconds ~ $(((wanted_repeats+1)*time_covered)) seconds of testing)."
+  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
 echo
 echo "System test configuration completed."
@@ -233,9 +226,16 @@ cp services.msk services.xml
 sed -i 's/__CLIENT_CONNECTIONS__/'$G_ADML_CONNECTIONS'/g' services.xml
 cd - >/dev/null
 
-
-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
+  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
+
   echo "Creating ADML instance $instance ..."
   mkdir -p ADMLS/ADML-$instance
   cd ADMLS/ADML-$instance
@@ -254,6 +254,7 @@ done
 
 echo
 echo "Now you can run all the instances deployed: ./run.sh"
+echo "To configure another layout you should execute this script again."
 echo
 echo "Done!"