Improvements and new scenaries
[anna.git] / example / diameter / launcher / deployments / st-client / program.sh
index b02fd2d..07e7616 100755 (executable)
@@ -22,23 +22,24 @@ _exit() {
 usage() {
   echo "Usage: $0 <test stuff directory> [-s]"
   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 "       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 file with xml files referenced inside. Those"
+  echo "                             xml files (without the .msk extension) shall exists in the directory. For example:"
+  echo
   echo "                                $0 st_examples/DynamicQualification"
   echo
+  echo "                             Optionally, a file called 'specific' could exists containing testcase-specific information,"
+  echo "                             which normally will be used to specify database sentences. This file will be accumulated"
+  echo "                             as a cloning seed over the file 'specific.all' created on test stuff directory."
+  echo
+  echo
   echo "       -s: start testing just after programming, using desired rate: $DESIRED_RATE test cases per second."
   [ $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
-}
-
-
 #############
 # EXECUTION #
 #############
@@ -52,6 +53,11 @@ miss_conf=
 
 echo
 [ -z "$1" ] && usage
+echo "Starting testcases programming ..."
+echo
+
+./operation.sh --ping >/dev/null
+[ $? -ne 0 ] && _exit "Programming aborted (some ADML client process is not running) !"
 TESTCASE_DIR=$1
 AUTOSTART=$2
 
@@ -63,26 +69,42 @@ TESTCASE_FILES=${#TESTCASE[@]}
 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
 
-children_before=$(children)
+[ -z "$ADML_CONCURRENT_PROVISION_JOBS" ] && ADML_CONCURRENT_PROVISION_JOBS=5
+
+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`
-  ./clone.sh $ADML_DIR $TESTCASE $ini_seq $fin_seq $CLONE_GROUPS &
+  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
+    idle_cpu=$(top -b -d 0.1 -n 2 | grep 'Cpu(s):'| tail -1 |awk '{print $8}')
+    echo
+    echo "Idle cpu = $idle_cpu%"
+    echo "if cpu is not overcommited, consider increase ADML_CONCURRENT_PROVISION_JOBS environment variable (now $ADML_CONCURRENT_PROVISION_JOBS)"
+    echo
+    wait $(jobs -p)
+    count=0
+  fi
 
 done < $PROGRAM_LAYOUT_FILE
 
 # Wait background jobs to finish:
-sleep 1
+sleep 5
 echo "Waiting for clone completion ..."
-while true
-do
-  [ $(children) -eq $children_before ] && break
-  sleep 1
-done
+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 !"
@@ -91,6 +113,15 @@ echo
 echo "Configuring repeat cycles ..."
 ./operation.sh "test|repeats|$REPEATS"
 
+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
+
 echo
 echo
 start_testing=
@@ -105,6 +136,12 @@ else
     rate_per_instance=$((desired_rate/$ADML_INSTANCES))
     [ $rate_per_instance -lt 1 ] && rate_per_instance=1
     ./operation.sh "test|ttps|$rate_per_instance"
+  else
+    echo "Remember that you could start traffic using:"
+    echo "   ./operation.sh \"test|ttps|<test cases per second rate>\""
+    echo
+    echo "For example, to reach $DESIRED_RATE test cases per second:"
+    echo "   ./operation.sh \"test|ttps|$RATE_PER_INSTANCE\""
   fi
 fi