Testing library separation: now not in launcher but isolated
[anna.git] / example / diameter / launcher / DEPLOY.sh
index 3e3cbd9..72604a8 100755 (executable)
@@ -6,8 +6,8 @@
 SETUPS_DIR=../../../source/diameter/stack/setups
 MSGDTD=../../../include/anna/diameter/codec/message.dtd
 DCTDTD=../../../include/anna/diameter/stack/dictionary.dtd
-BASE_PROT=commands_baseProtocol.xml
 SERVICES=./resources/services_examples
+STACK_EXAMPLES=./resources/stack_examples
 SRVDTD=$SERVICES/services.dtd
 
 # Executables in priority order:
@@ -18,6 +18,10 @@ EXECS=( $EXEC_installed ./release/example_diameter_launcher ./debug/example_diam
 STACKMGMT_EXEC_installed=/opt/bin/anna/example_diameter_stackManagement
 STACKMGMT_EXECS=( $STACKMGMT_EXEC_installed ../stackManagement/release/example_diameter_stackManagement ../stackManagement/debug/example_diameter_stackManagement )
 
+# Dynamic library:
+#DYNLIB_installed=/usr/local/lib/libanna_dynamicLauncherProcedure.so
+#DYNLIBS=( $DYNLIB_installed ../../../dynamic/launcher/default/release/libanna_dynamicLauncherProcedure.so ../../../dynamic/launcher/default/debug/libanna_dynamicLauncherProcedure.so )
+
 #############
 # FUNCTIONS #
 #############
@@ -29,19 +33,21 @@ _exit () {
 }
 
 usage () {
-  echo "Usage: $0 [deployment_type: a|b|f] [deployment_path]"
+  echo "Usage: $0 [deployment_type: a|b|f|s] [deployment_path]"
   echo
   echo "       deployment_type:"
   echo "          a=advanced"
   echo "          b=basic"
   echo "          f=function test client"
+  echo "          s=system test client"
   echo "       deployment_path:"
   echo "          non-existent path directory."
   echo
   echo "       For example:"
-  echo "          $0 b $HOME/ADML/basicServer"
-  echo "          $0 b $HOME/ADML/MMSbalancer"
-  echo "          $0 f $HOME/ADML/tester"
+  echo "          $0 b $HOME/ADML-basicServer"
+  echo "          $0 b $HOME/ADML-MMSbalancer"
+  echo "          $0 f $HOME/ADML-tester"
+  echo "          $0 s $HOME/ADML-stress-client"
   echo
   exit 0
 }
@@ -52,21 +58,23 @@ createRunScript () {
   [ "$1" = "b" ] && return
 
   local other=
-  [ "$1" = "a" ] && { exe=ADML-launcher ; other="--httpServer \`grep -v ^# .httpServer\`"; }
-  [ "$1" = "f" ] && { exe=ADML-ftclient ; ln -s ADML-launcher $exe ; }
+  [ "$1" = "a" ] && other="--httpServer \`grep -v ^# .httpServer\`"
+  [ "$1" = "f" ] && ln -s ADML-launcher $EXE
+  [ "$1" = "s" ] && { other="--disableLogs"; ln -s ADML-launcher $EXE ; }
 
   echo "Creating 'run.sh' script ..."
 
   cat << EOF > run.sh
 #!/bin/bash
 cd \`dirname \$0\`
-EXE=$exe
-STARTED=\`pgrep \$EXE 2>/dev/null\`
+EXE=$EXE
+STARTED=\`pgrep \$EXE$ 2>/dev/null\`
 [ \$? -eq 0 ] && { echo "Already started!"; echo "\$STARTED" ; exit 1 ; }
 ./pre-start.sh
 0> launcher.trace
 rm -f counters/* test-reports/*
 # Execution line:
+export LD_LIBRARY_PATH=\$PWD/dynlibs
 ./\$EXE --services services.xml --cntDir counters --tmDir test-reports $other &
 echo \$! > .pid
 EOF
@@ -74,42 +82,6 @@ EOF
   chmod a+x run.sh
 }
 
-createDictionaryPaths () {
-  echo "Creating dictionaries ..."
-
-  for i in stacks/*commands*xml
-  do
-    stacks/dependence.sh $i >/dev/null
-    stack=`basename $i`
-    if test "$stack" != "$BASE_PROT"
-    then
-      > .dictionary-${stack}
-      for j in `cat ${i}.dep`
-      do
-        echo -n "${j} " >> .dictionary-${stack}
-      done
-      echo "stacks/$BASE_PROT stacks/${stack}" >> .dictionary-${stack}
-    fi
-  done
-
-  # Create autonomous dictionaries:
-  mkdir stacks/autonomous
-  for i in `ls .dictionary-*`
-  do
-    name=$(echo $i | cut -d\- -f2)
-    $STACKMGMT_EXEC `cat $i` >/dev/null
-    mv result.xml stacks/autonomous/$name
-  done
-
-  # Cleanup:
-  rm -f stacks/*.dep
-  rm -f .dictionary-*
-  rm -f example_diameter_stackManagement.trace*
-
-  # Default:
-  ln -s stacks/autonomous/commands_qosControl.xml dictionary.xml
-}
-
 #############
 # EXECUTION #
 #############
@@ -122,6 +94,7 @@ echo "---------------------------------------"
 echo " (--help or -h for more info)"
 echo
 echo "Basic checkings ..."
+
 # Launcher executable:
 available=
 for EXEC in ${EXECS[@]}; do
@@ -130,6 +103,13 @@ for EXEC in ${EXECS[@]}; do
   echo "not found"
 done
 [ -z "$available" ] && _exit "Anna Diameter Launcher (ADML) is not installed neither linked. See README.md (Install section)."
+
+# Dynamic library variant:
+dynlib_variant=
+[ -f ./release/example_diameter_launcher ] && dynlib_variant=release
+[ -f ./debug/example_diameter_launcher ] && dynlib_variant=debug
+[ -z "$dynlib_variant" ] && _exit "Unknown dynamic library variant"
+
 # Dictionary creation:
 available=
 for STACKMGMT_EXEC in ${STACKMGMT_EXECS[@]}; do
@@ -140,6 +120,15 @@ done
 [ -z "$available" ] && _exit "Anna Diameter Stack Management Tool is not installed neither linked. See README.md (Install section)."
 STACKMGMT_EXEC=`readlink -f $STACKMGMT_EXEC`
 
+# Dynamic library:
+#available=
+#for DYNLIB in ${DYNLIBS[@]}; do
+#  echo -n "Looking dynamic library at '$DYNLIB' ... "
+#  [ -x $DYNLIB ] && { available=yes ; echo "available !" ; break ; }
+#  echo "not found"
+#done
+#[ -z "$available" ] && _exit "Anna Diameter Launcher Dynamic Procedure Library (ADML) is not installed neither linked. See README.md (Install section)."
+
 [ ! -d $SETUPS_DIR ] && _exit "Diameter stacks not found ($SETUPS_DIR)."
 
 echo
@@ -151,6 +140,7 @@ then
   echo " (a)dvanced version:     includes burst management script and templates for different scenarios. Automatic configuration during start."
   echo " (b)asic version:        4 types of launcher (client, server, balancer, dummy), lightly configured and managed through SIGURS2 method."
   echo " (f)unction test client: special client with regexp scheduler script based on splitted traffic logs. Requires a server to perform the tests."
+  echo " (s)ystem test client:   special client for stress testing. Requires a server/s to perform the tests."
   echo
   echo "Input option [b]:"
   read option
@@ -163,19 +153,25 @@ case $option in
   a)
     echo "Advanced deployment"
     DEPLOYMENTS_DIR=deployments/advanced
-    DPATH_dflt=$HOME/ADML/advanced
+    DPATH_dflt=$HOME/ADML-advanced
   ;;
 
   b)
     echo "Basic deployment"
     DEPLOYMENTS_DIR=deployments/basic
-    DPATH_dflt=$HOME/ADML/basic
+    DPATH_dflt=$HOME/ADML-basic
   ;;
 
   f)
     echo "FT deployment"
     DEPLOYMENTS_DIR=deployments/ft-client
-    DPATH_dflt=$HOME/ADML/ft-client
+    DPATH_dflt=$HOME/ADML-ft-client
+  ;;
+
+  s)
+    echo "ST deployment"
+    DEPLOYMENTS_DIR=deployments/st-client
+    DPATH_dflt=$HOME/ADML-st-client
   ;;
 
   *)
@@ -194,6 +190,7 @@ else
 fi
 
 [ -d $DPATH ] && _exit "The installation path '$DPATH' must not exists."
+EXE=`basename $DPATH`
 
 echo "Copying to '$DPATH' ..."
 mkdir -p $DPATH
@@ -201,17 +198,49 @@ mkdir -p $DPATH/stacks
 mkdir -p $DPATH/DTDs
 mkdir -p $DPATH/counters
 mkdir -p $DPATH/test-reports
+
+# Dynamic libs:
+mkdir -p $DPATH/dynlibs
+cd ../../../dynamic/launcher
+DYNLIBS=( $(find . -name "*.so") )
+for dl in ${DYNLIBS[@]}
+do
+  dir=$(dirname $dl | xargs dirname)
+  mkdir -p $DPATH/dynlibs/$dir
+  cp $dir/$dynlib_variant/*.so $DPATH/dynlibs/$dir
+  cp $dir/*.xml $DPATH/dynlibs/$dir 2>/dev/null
+  cp $dir/dynamic.suffix $DPATH/dynlibs/$dir 2>/dev/null
+done
+cd - >/dev/null
+cp ./resources/scripts/select_dynlib.sh $DPATH/dynlibs/select.sh
+cd $DPATH/dynlibs
+ln -s default/libanna_dynamicLauncherProcedure.so
+cd - >/dev/null
+
 [ "$option" = "b" ] && mkdir -p $DPATH/services
+
+# ADML executable:
 if [ "$EXEC" = "$EXEC_installed" ]
 then
   ln -s $EXEC_installed $DPATH/ADML-launcher
 else
   cp $EXEC $DPATH/ADML-launcher
 fi
+
+# Stack management tool:
+if [ "$STACKMGMT_EXEC" = "$STACKMGMT_EXEC_installed" ]
+then
+  ln -s $STACKMGMT_EXEC_installed $DPATH/stacks/stack-mgmt
+fi
+# Copy binary just in case: 
+[ ! -f $DPATH/stacks/stack-mgmt ] && cp $STACKMGMT_EXEC $DPATH/stacks/stack-mgmt
+
 cp -rL $DEPLOYMENTS_DIR/* $DPATH
 cp $SETUPS_DIR/*xml $DPATH/stacks
 cp $SETUPS_DIR/*sh $DPATH/stacks
 cp $SETUPS_DIR/readme.txt $DPATH/stacks
+mkdir $DPATH/stacks/other_examples
+cp $STACK_EXAMPLES/* $DPATH/stacks/other_examples 
 cp $MSGDTD $DPATH/DTDs
 cp $DCTDTD $DPATH/DTDs
 cp $SRVDTD $DPATH/DTDs
@@ -220,9 +249,22 @@ cp $SRVDTD $DPATH/DTDs
 echo "Preparing ..."
 cd $DPATH
 createRunScript $option
-createDictionaryPaths
+stacks/makeAutonomous.sh commands_qosControl.xml stacks/stack-mgmt >/dev/null
+ln -s stacks/autonomous.commands_qosControl.xml dictionary.xml
 cd - >/dev/null
 
+if [ "$option" = "s" ]
+then
+  cd $DPATH
+  ln -s services_example services
+  mv run.sh .run-one.sh
+  mv run_all.sh run.sh
+  mv operation.sh .operation-one.sh
+  mv operation_all.sh operation.sh
+  rm dictionary.xml
+  cd - >/dev/null
+fi
+
 # Help:
 echo
 echo "Go to '$DPATH' and see README file"