#!/bin/sh

# $Header: https://svn.mpia.de/gulli/TwiceAsNice/branch/unstable/ln/laos-drot/test/LaosDrotIntegrationTest_derotateUploadToLate_noRT.sh 14191 2017-03-01 19:21:03Z mathar $

export INSROOT_ETC_PATH=../etc/

if [ "x$srcdir" = "x" ]; 
then
    srcdir="."
fi

if [ "x$NICE_TYPE_PATH" = "x" ]; 
then
    NICE_TYPE_PATH="."
fi

LOGLEVEL=ERROR
#LOGLEVEL=DEBUG

LD_LIBRARY_PATH=`cd $SHARKNIR_DROT_LIB_PATH && pwd`:`cd $INTERFACE_DROT_LIB_PATH && pwd`:$LD_LIBRARY_PATH

echo "start IIF simulator"
LbtoIIFSimulator --CONFIG=lbto.iifSimulator-svr.cfg \
                 --LOGGER.LEVEL=$LOGLEVEL &
                                          
LbcsIIFSimulator_pid=$!
sleep 5
echo "IIF simulator is running"
#netstat -lntp

echo "start IIF server"
basdard --CONFIG=lbcs.iifDummyLocalhost-svr.cfg \
        --LOGGER.LEVEL:LogLevel=$LOGLEVEL &
LbcsIIFService_pid=$!
sleep 5
echo "IIF server is running"
#netstat -lntp                                         

#echo "start Drot server"
#basdard --CONFIG=laos.dx.gws.drot.dummy-svr.cfg \
#        --LOGGER.LEVEL:LogLevel=DEBUG &
##        --LOGGER.LEVEL:LogLevel=$LOGLEVEL &
#SharknirDrotService_pid=$!
#sleep 5
#echo "Drot server is running"
##netstat -lntp                                         
##niceFinder

echo "run test"
./SharknirDrotIntegrationTest_derotateUploadToLate_noRT --CONFIG:Endpoint=[ALIAS=drotxh] \
                            --LOGGER.LEVEL=$LOGLEVEL \
                            --log_level=test_suite

CLIENT_EXIT_CODE=$?

#kill -TERM $SharknirDrotService_pid
kill -TERM $LbcsIIFService_pid
kill -TERM $LbcsIIFSimulator_pid
                            
exit $CLIENT_EXIT_CODE
