Skip to content
Snippets Groups Projects
Commit cf440f4c authored by felmer's avatar felmer
Browse files

LMS-1552 fix integration tests

SVN: 16677
parent 226d0a33
No related branches found
No related tags found
No related merge requests found
...@@ -37,28 +37,28 @@ function report_error { ...@@ -37,28 +37,28 @@ function report_error {
function exit_if_assertion_failed { function exit_if_assertion_failed {
if [ "$TEST_FAILED" = "true" ]; then if [ "$TEST_FAILED" = "true" ]; then
report_error Test failed. report_error Test failed.
exit 1; exit 1;
else else
echo [OK] Test was successful! echo [OK] Test was successful!
fi fi
} }
function assert_file_exists { function assert_file_exists {
local file=$1 local file=$1
if [ ! -f "$file" ]; then if [ ! -f "$file" ]; then
report_error File $file does not exist! report_error File $file does not exist!
else else
echo [OK] File $file exists echo [OK] File $file exists
fi fi
} }
function assert_file_not_exists { function assert_file_not_exists {
local file=$1 local file=$1
if [ -f "$file" ]; then if [ -f "$file" ]; then
report_error File $file does exist although it should not! report_error File $file does exist although it should not!
else else
echo [OK] File $file does not exists echo [OK] File $file does not exists
fi fi
} }
...@@ -76,9 +76,9 @@ function assert_same_inode { ...@@ -76,9 +76,9 @@ function assert_same_inode {
function assert_dir_exists { function assert_dir_exists {
local DIR=$1 local DIR=$1
if [ ! -d "$DIR" ]; then if [ ! -d "$DIR" ]; then
report_error Directory \"$DIR\" does not exist! report_error Directory \"$DIR\" does not exist!
else else
echo [OK] Directory \"$DIR\" exists echo [OK] Directory \"$DIR\" exists
fi fi
} }
...@@ -93,18 +93,18 @@ function assert_file_exists_or_die { ...@@ -93,18 +93,18 @@ function assert_file_exists_or_die {
local F="$1" local F="$1"
local files_num=`ls -1 $F 2> /dev/null | wc -l` local files_num=`ls -1 $F 2> /dev/null | wc -l`
if [ $files_num -gt 1 ]; then if [ $files_num -gt 1 ]; then
fatal_error "One file expected for pattern $F, but more found: " $F fatal_error "One file expected for pattern $F, but more found: " $F
else else
if [ ! -f $F ]; then if [ ! -f $F ]; then
fatal_error "No file matching pattern $F exists" fatal_error "No file matching pattern $F exists"
fi fi
fi fi
} }
function assert_dir_exists_or_die { function assert_dir_exists_or_die {
local DIR=$1 local DIR=$1
if [ ! -d $DIR ]; then if [ ! -d $DIR ]; then
fatal_error "Directory $DIR does not exist!" fatal_error "Directory $DIR does not exist!"
fi fi
} }
...@@ -113,7 +113,7 @@ function assert_dir_empty { ...@@ -113,7 +113,7 @@ function assert_dir_empty {
is_empty_dir $dir is_empty_dir $dir
empty=$? empty=$?
if [ $empty == 0 ]; then if [ $empty == 0 ]; then
report_error Directory \'$dir\' should be empty! report_error Directory \'$dir\' should be empty!
fi fi
} }
...@@ -158,18 +158,18 @@ function assert_pattern_present { ...@@ -158,18 +158,18 @@ function assert_pattern_present {
cat $file | grep "$pattern" cat $file | grep "$pattern"
local lines=`cat $file | grep "$pattern" | wc -l` local lines=`cat $file | grep "$pattern" | wc -l`
if [ $lines != $occurences ]; then if [ $lines != $occurences ]; then
report_error $lines instead of $occurences occurences of pattern $pattern found! report_error $lines instead of $occurences occurences of pattern $pattern found!
else else
echo [OK] $occurences occurences of pattern $pattern found echo [OK] $occurences occurences of pattern $pattern found
fi fi
} }
function assert_files_number { function assert_files_number {
local dir=$1 local dir=$1
local expected_files_count=$2 local expected_files_count=$2
local files_count=`ls -1 $dir | wc -l` local files_count=`ls -1 $dir | wc -l`
assert_equals "Wrong number of files in $dir directory" $expected_files_count $files_count assert_equals "Wrong number of files in $dir directory" $expected_files_count $files_count
} }
...@@ -200,11 +200,11 @@ function locate_file { ...@@ -200,11 +200,11 @@ function locate_file {
shift shift
local additional_paths=$@ local additional_paths=$@
for dir in `get_env_path` $additional_paths; do for dir in `get_env_path` $additional_paths; do
local full_path=$dir/$file local full_path=$dir/$file
if [ -x $full_path ]; then if [ -x $full_path ]; then
echo $full_path; echo $full_path;
return return
fi fi
done done
} }
...@@ -219,16 +219,16 @@ function run_lsof { ...@@ -219,16 +219,16 @@ function run_lsof {
# Tries to find PostgreSQL executable and returns its absolute path. # Tries to find PostgreSQL executable and returns its absolute path.
# If not found, then exits the script with an appropriate error message. # If not found, then exits the script with an appropriate error message.
function run_psql { function run_psql {
for prg in psql psql84 psql83; do for prg in psql psql84 psql83; do
exe=`locate_file $prg $BIN_PATHS` exe=`locate_file $prg $BIN_PATHS`
if [ $exe ]; then if [ $exe ]; then
echo $exe echo $exe
return return
fi fi
done done
echo "Cannot find PostgreSQL" echo "Cannot find PostgreSQL"
echo "This executable is needed to run the integration tests" echo "This executable is needed to run the integration tests"
exit 1 exit 1
} }
function build_zips { function build_zips {
...@@ -239,14 +239,14 @@ function build_zips { ...@@ -239,14 +239,14 @@ function build_zips {
if [ $build_dss == "true" -o $build_dmv == "true" -o $build_openbis == "true" ]; then if [ $build_dss == "true" -o $build_dmv == "true" -o $build_openbis == "true" ]; then
mkdir -p $INSTALL mkdir -p $INSTALL
if [ "$use_local_source" = "true" ]; then if [ "$use_local_source" = "true" ]; then
build_zips_from_local $build_dss $build_dmv $build_openbis build_zips_from_local $build_dss $build_dmv $build_openbis
else else
build_zips_from_svn $build_dss $build_dmv $build_openbis build_zips_from_svn $build_dss $build_dmv $build_openbis
fi fi
else else
echo "No components to build were specified (--help explains how to do this)." echo "No components to build were specified (--help explains how to do this)."
echo "Build process skipped." echo "Build process skipped."
fi fi
assert_file_exists_or_die "$INSTALL/openBIS*.zip" assert_file_exists_or_die "$INSTALL/openBIS*.zip"
assert_file_exists_or_die "$INSTALL/datastore_server-*.zip" assert_file_exists_or_die "$INSTALL/datastore_server-*.zip"
...@@ -277,17 +277,17 @@ function build_components { ...@@ -277,17 +277,17 @@ function build_components {
build_openbis=$4 build_openbis=$4
if [ $build_dss == "true" ]; then if [ $build_dss == "true" ]; then
rm -f $INSTALL/datastore_server*.zip rm -f $INSTALL/datastore_server*.zip
rm -f $INSTALL/dss_client*.zip rm -f $INSTALL/dss_client*.zip
$build_cmd datastore_server $build_cmd datastore_server
$build_cmd rtd_yeastx $build_cmd rtd_yeastx
fi fi
if [ $build_dmv == "true" ]; then if [ $build_dmv == "true" ]; then
rm -f $INSTALL/datamover*.zip rm -f $INSTALL/datamover*.zip
$build_cmd datamover $build_cmd datamover
fi fi
if [ $build_openbis == "true" ]; then if [ $build_openbis == "true" ]; then
rm -f $INSTALL/openBIS*.zip rm -f $INSTALL/openBIS*.zip
$build_cmd openbis $build_cmd openbis
fi fi
} }
...@@ -320,7 +320,7 @@ function build_zips_from_svn { ...@@ -320,7 +320,7 @@ function build_zips_from_svn {
function clean_svn { function clean_svn {
local DIR=$1 local DIR=$1
for file in `find $DIR -name ".svn"`; do for file in `find $DIR -name ".svn"`; do
rm -fr $file; rm -fr $file;
done done
} }
...@@ -355,15 +355,15 @@ function wait_for_server { ...@@ -355,15 +355,15 @@ function wait_for_server {
echo -n "Server starting" echo -n "Server starting"
i=0; i=0;
while [ "`check_server_port`" == "" -a $i -lt 20 ]; do while [ "`check_server_port`" == "" -a $i -lt 20 ]; do
sleep 2; sleep 2;
echo -n "."; echo -n ".";
let i=$i+1; let i=$i+1;
done done
if [ "`check_server_port`" == "" ]; then if [ "`check_server_port`" == "" ]; then
report_error "Server could not be started!" report_error "Server could not be started!"
exit 1 exit 1
else else
echo "...[Done]" echo "...[Done]"
fi fi
} }
...@@ -376,11 +376,12 @@ function install_openbis_server { ...@@ -376,11 +376,12 @@ function install_openbis_server {
if [ $install_openbis == "true" ]; then if [ $install_openbis == "true" ]; then
rm -fr $OPENBIS_SERVER rm -fr $OPENBIS_SERVER
copy_templates $OPENBIS_SERVER_NAME copy_templates $OPENBIS_SERVER_NAME
unzip -d $OPENBIS_SERVER $INSTALL/openBIS*.zip unzip -d $OPENBIS_SERVER $INSTALL/openBIS*.zip
$OPENBIS_SERVER/openBIS-server/install.sh $PWD/$OPENBIS_SERVER $OPENBIS_SERVER/service.properties $OPENBIS_SERVER/openbis.conf $OPENBIS_SERVER/openBIS-server/install.sh $PWD/$OPENBIS_SERVER $OPENBIS_SERVER/service.properties $OPENBIS_SERVER/openbis.conf
wait_for_server startup_openbis_server
wait_for_server
else else
copy_templates $OPENBIS_SERVER_NAME copy_templates $OPENBIS_SERVER_NAME
restart_openbis restart_openbis
...@@ -399,20 +400,20 @@ function shutdown_openbis_server { ...@@ -399,20 +400,20 @@ function shutdown_openbis_server {
fi fi
} }
# unpack everything, override default configuration with test configuation # unpack everything, override default configuration with test configuation
function install_dsss { function install_dsss {
local install_dss=$1 local install_dss=$1
local dss_dirs="datastore_server1 datastore_server2 datastore_server_yeastx" local dss_dirs="datastore_server1 datastore_server2 datastore_server_yeastx"
if [ $install_dss == "true" ]; then if [ $install_dss == "true" ]; then
unpack datastore_server- unpack datastore_server-
for dss_dir in $dss_dirs; do for dss_dir in $dss_dirs; do
prepare datastore_server $dss_dir prepare datastore_server $dss_dir
done done
remove_unpacked datastore_server remove_unpacked datastore_server
else else
for dss_dir in $dss_dirs; do for dss_dir in $dss_dirs; do
copy_templates $dss_dir copy_templates $dss_dir
done done
fi fi
} }
...@@ -420,29 +421,29 @@ function install_datamovers { ...@@ -420,29 +421,29 @@ function install_datamovers {
local install_dmv=$1 local install_dmv=$1
if [ $install_dmv == "true" ]; then if [ $install_dmv == "true" ]; then
unpack datamover unpack datamover
prepare datamover datamover-raw prepare datamover datamover-raw
prepare datamover datamover-analysis prepare datamover datamover-analysis
remove_unpacked datamover remove_unpacked datamover
cp -fR $TEMPLATE/dummy-img-analyser $WORK cp -fR $TEMPLATE/dummy-img-analyser $WORK
copy_templates datamover-raw copy_templates datamover-raw
copy_templates datamover-analysis copy_templates datamover-analysis
else else
copy_templates datamover-raw copy_templates datamover-raw
copy_templates datamover-analysis copy_templates datamover-analysis
fi fi
} }
function restart_openbis { function restart_openbis {
assert_dir_exists_or_die $OPENBIS_SERVER assert_dir_exists_or_die $OPENBIS_SERVER
if [ "`check_server_port`" != "" ]; then if [ "`check_server_port`" != "" ]; then
# maybe server is just closing, wait a moment # maybe server is just closing, wait a moment
sleep 5 sleep 5
fi fi
if [ "`check_server_port`" != "" ]; then if [ "`check_server_port`" != "" ]; then
echo Shutting down openbis server. echo Shutting down openbis server.
shutdown_openbis_server shutdown_openbis_server
sleep 1 sleep 1
fi fi
startup_openbis_server startup_openbis_server
sleep 4 sleep 4
} }
...@@ -455,13 +456,13 @@ function install { ...@@ -455,13 +456,13 @@ function install {
mkdir -p $WORK mkdir -p $WORK
if [ $reinstall_all == "true" ];then if [ $reinstall_all == "true" ];then
install_dsss "true" install_dsss "true"
install_datamovers "true" install_datamovers "true"
install_openbis_server "true" install_openbis_server "true"
else else
install_dsss $install_dss install_dsss $install_dss
install_datamovers $install_dmv install_datamovers $install_dmv
install_openbis_server $install_openbis install_openbis_server $install_openbis
fi fi
} }
...@@ -482,9 +483,9 @@ function call_in_dir { ...@@ -482,9 +483,9 @@ function call_in_dir {
function is_empty_dir { function is_empty_dir {
dir=$1 dir=$1
if [ "`ls $dir`" = "" ]; then if [ "`ls $dir`" = "" ]; then
return 1; return 1;
else else
return 0; return 0;
fi fi
} }
...@@ -493,8 +494,8 @@ function is_empty_dir { ...@@ -493,8 +494,8 @@ function is_empty_dir {
function chmod_exec { function chmod_exec {
for file in $@; do for file in $@; do
if [ -f $file ]; then if [ -f $file ]; then
chmod u+x $file chmod u+x $file
fi fi
done done
} }
...@@ -511,18 +512,18 @@ function switch_sth { ...@@ -511,18 +512,18 @@ function switch_sth {
chmod_exec $dir/$cmd_stop chmod_exec $dir/$cmd_stop
if [ "$switch_on" == "on" ]; then if [ "$switch_on" == "on" ]; then
echo "Launching $dir..." echo "Launching $dir..."
rm -fr $dir/log/* rm -fr $dir/log/*
call_in_dir "$cmd_start" $dir call_in_dir "$cmd_start" $dir
else else
echo "Stopping $dir, displaying errors from the log" echo "Stopping $dir, displaying errors from the log"
if [ "`cat $dir/log/* | grep ERROR | tee -a $ERR_LOG`" != "" ]; then if [ "`cat $dir/log/* | grep ERROR | tee -a $ERR_LOG`" != "" ]; then
if [ $report_error -eq $TRUE ]; then if [ $report_error -eq $TRUE ]; then
report_error $dir reported errors. report_error $dir reported errors.
cat $dir/log/* | grep ERROR >&2 cat $dir/log/* | grep ERROR >&2
fi fi
fi fi
call_in_dir "$cmd_stop" $dir call_in_dir "$cmd_stop" $dir
fi fi
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment