#!/bin/sh
#
software=$HOME/srv/runner/software/c9604729ffc0a4748bc2f1ac4cd34bda
performance_tester_erp5=$software/bin/performance_tester_erp5

date=`date '+pt%Y%m%d%H%M%S'`
report_directory_home=$HOME/tmp/cloudia-performance-test
report_directory=$report_directory_home/$date
report_pdf_directory=$report_directory_home/pdf
mkdir -p $report_directory
mkdir -p $report_pdf_directory
# to understand these options, see performance_tester_erp5 -h
option=" --users-range-increment 1 --repeat 3 --repeat-range 1 -r $report_directory "

# to do this, you must configure your dns and apache
url="https://[2001:380:e0c:155:5cc0:ac3b:e647:154d]:16001/erp5"

# 1/ testing quetionnareFillOut
concurrent_users="2"

echo "command options:"
echo $performance_tester_erp5 $option $url $concurrent_users
# run performance tester command
echo "\n...running questionnaireFillout performance test\n"
$performance_tester_erp5 $option $url $concurrent_users questionnaireFillout.py

echo "\n...running questionnaireCorrection performance test\n"
$performance_tester_erp5 $option $url $concurrent_users questionnaireCorrection.py


# If you get this error: _tkinter.TclError: couldn't connect to display ":0"
# probablly you need to configure xhost something like this.
# % sudo xhost +SI:localuser:slapuserXX
report_file="$report_pdf_directory"`date +/%Y-%m-%d_%H%M.%S.pdf`
generate_erp5_tester_report --output-filename $report_file $report_directory
echo "Performance test result: $report_file"
