Improvements and new scenaries
[anna.git] / example / diameter / launcher / deployments / st-client / program.sh
index 0308771..07e7616 100755 (executable)
@@ -40,13 +40,6 @@ usage() {
   _exit
 }
 
-children () {
-  bash_pid=$$
-  children=`ps -eo ppid | grep -w $bash_pid`
-  echo $children | wc -w
-}
-
-
 #############
 # EXECUTION #
 #############
@@ -60,7 +53,10 @@ miss_conf=
 
 echo
 [ -z "$1" ] && usage
-./operation.sh --ping
+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
@@ -76,25 +72,39 @@ CLONE_GROUPS=$((MAX_NUMBER_GROUPS/ADML_INSTANCES))
 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`
+  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 !"
@@ -129,6 +139,9 @@ else
   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