]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGPP/benchmark/alirelval
flat friends update
[u/mrichter/AliRoot.git] / PWGPP / benchmark / alirelval
index 7c0cd8a46820e58902c5d75281c2f98f6ac8446d..bd2c9d06b33c7a2c8bfacbd0142ff50495a40b28 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/bash
 
 #
-# launch-relval.sh -- by Dario Berzano <dario.berzano@cern.ch>
+# alirelval -- by Dario Berzano <dario.berzano@cern.ch>
 #
 # Controls the release validation submission by managing the validation virtual
 # cluster.
@@ -34,9 +34,9 @@ errStatusDoneOk=102
 errStatusDoneFail=103
 
 # thresholds
-maxVmLaunchAttempts=10
+maxVmLaunchAttempts=100
 maxSshConnectAttempts=400
-maxVmAddressWait=120
+maxVmAddressWait=200
 
 # working directory prefix
 sessionPrefix="$HOME/.alice-release-validation"
@@ -122,6 +122,9 @@ function RunVM() {
         ( euca-delete-keypair "$keyName" ; rm -f "$keyFile" ) > /dev/null 2>&1
       fi
       return $errRunVm
+    elif [ $attempt != 1 ] ; then
+      pr " * Pausing between retries"
+      sleep 5
     fi
 
     pr -n " * Launching VM (attempt #$attempt/$maxVmLaunchAttempts)..."
@@ -191,14 +194,20 @@ function RunVM() {
 
 # Prepare the validation session directory. Syntax:
 #
-#   PrepareSession <aliroot_tag>
+#   PrepareSession <aliroot_tag> <new_session_name>
 #
 # Returns 0 on success, nonzero on failure. Session tag returned on stdout.
 function PrepareSession() {
   local aliRootTag sessionTag sessionDir
   aliRootTag="$1"
-  shift
-  sessionTag="${aliRootTag}_$(ndate)"
+
+  # session tag can be "auto" or any user-specified value
+  if [ "$2" != 'auto' ] ; then
+    sessionTag="$2"
+  else
+    sessionTag="${aliRootTag}_$(ndate)"
+  fi
+  shift 2
   sessionDir="$sessionPrefix/$sessionTag"
 
   # session directory already exists? abort
@@ -217,10 +226,11 @@ function PrepareSession() {
   # aliroot version written to a file
   echo "$aliRootTag" > "$sessionDir/aliroot-version.txt"
 
-  # benchmark script, configuration and file list
-  cp benchmark.sh benchmark.config files.list "$sessionDir/"
+  # benchmark script, benchmark config, cloud config and file list
+  cp -L benchmark.sh cloud.config benchmark.config files.list "$sessionDir/"
   if [ $? != 0 ] ; then
-    pr "Cannot copy benchmark configuration and script to $sessionDir"
+    pr "Cannot copy configuration files to $sessionDir"
+    rm -rf "$sessionDir"
     return $errSessionDir
   fi
 
@@ -272,7 +282,7 @@ function RecycleSession() {
   local f
 
   for f in 'instance-id.txt' 'instance-address.txt' 'key.pem' ; do
-    cp "$fromSessionDir/$f" "$f" > /dev/null 2>&1
+    cp -L "$fromSessionDir/$f" "$f" > /dev/null 2>&1
     if [ $? != 0 ] ; then
       pr "Cannot copy $f from the source session dir $fromSessionDir"
       return $errRecycleSession
@@ -300,7 +310,7 @@ function MoveToSessionDir_Undo() {
 
 # Load the benchmark configuration
 function LoadConfig() {
-  source benchmark.config > /dev/null 2>&1
+  source cloud.config > /dev/null 2>&1
   if [ $? != 0 ] ; then
     pr "Cannot load benchmark configuration"
     return $errCfg
@@ -331,7 +341,8 @@ function InstantiateValidationVM() {
   elif [ -e "$cloudKeyFile" ] ; then
     # copy key to session dir
     pr -n "Copying private key $cloudKeyFile to session directory..."
-    cp "$cloudKeyFile" 'key.pem' 2> /dev/null
+    rm -f 'key.pem'
+    cp -L "$cloudKeyFile" 'key.pem' 2> /dev/null
     if [ $? != 0 ] ; then
       pr 'error'
       return $errCopyKey
@@ -461,10 +472,11 @@ function Validate() {
   # create helper script to launch benchmark
   cat > run-benchmark.sh <<_EoF_
 #!/bin/bash
+export LANG=C
 cd \$(dirname "\$0")
 v=validation.done
 rm -f \$v
-env ALIROOT_VERSION=$(cat aliroot-version.txt) ./benchmark.sh run $sessionTag files.list benchmark.config
+env ALIROOT_VERSION=$(cat aliroot-version.txt) ./benchmark.sh run $sessionTag files.list benchmark.config 2>&1 | tee run-benchmark.log
 #sleep 1000
 ret=\$?
 echo \$ret > \$v
@@ -581,7 +593,7 @@ function Help() {
   pr "$Prog -- by Dario Berzano <dario.berzano@cern.ch>"
   pr 'Controls the Release Validation workflow on the cloud for AliRoot.'
   pr
-  pr "Usage 1: $Prog [--prepare|--launch|--recycle] [--from-session] --aliroot <aliroot_tag> [-- arbitraryOpt1=value [arbitraryOpt2=value2...]]"
+  pr "Usage 1: $Prog [--prepare|--launch|--recycle] [--from-session] --aliroot <aliroot_tag> [--session <custom_session_tag>] [-- arbitraryOpt1=value [arbitraryOpt2=value2...]]"
   pr
   pr 'A new session is created to validate the specified AliRoot tag.'
   pr
@@ -593,6 +605,8 @@ function Help() {
   pr '  --launch   : launches the full validation process: prepares session,'
   pr '               runs the virtual machine, launches the validation program'
   pr '  --aliroot  : the AliRoot tag to validate, in the form "vAN-20140610"'
+  pr '  --session  : custom session name to provide to the validation session:'
+  pr '               if omitted, defaults to <aliroot_tag>_<utc_datetime_now>'
   pr
   pr 'Arbitrary options (in the form variable=value) can be specified after the'
   pr 'double dash and will override the corresponding options in any of the'
@@ -745,11 +759,8 @@ function Main() {
         pr 'Specify an AliRoot version with --aliroot <tag>'
         return $errInvalidOpt
       fi
-      if [ "$sessionTag" != '' ] ; then
-        pr 'Cannot use --session with --prepare. Use --help for assistance.'
-        return $errInvalidOpt
-      fi
-      sessionTag=$( RunAction "$A" "$aliRootTag" "$@" )
+      [ "$sessionTag" == '' ] && sessionTag='auto'
+      sessionTag=$( RunAction "$A" "$aliRootTag" "$sessionTag" "$@" )
       ret=$?
     elif [ "$A" == 'RecycleSession' ] ; then
       # special action requiring additional parameters