Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | function usage { |
| 4 | echo "Usage: $0 <jar file>" |
| 5 | } |
| 6 | |
| 7 | function exitOnError() { |
| 8 | if [ $1 -ne 0 ] |
| 9 | then |
| 10 | echo "Failed running task $2" |
| 11 | exit 2 |
| 12 | fi |
| 13 | } |
| 14 | |
| 15 | if [ $# -lt 1 ] |
| 16 | then |
| 17 | usage |
| 18 | exit 2 |
| 19 | fi |
| 20 | |
| 21 | CURRENT_DIR=`pwd` |
| 22 | BASEDIR=$(dirname $0) |
| 23 | |
| 24 | if [ ${BASEDIR:0:1} = "/" ] |
| 25 | then |
| 26 | FULL_PATH=$BASEDIR |
| 27 | else |
| 28 | FULL_PATH=$CURRENT_DIR/$BASEDIR |
| 29 | fi |
| 30 | |
| 31 | LOGS_PROP_FILE=file:${FULL_PATH}/conf/log4j.properties |
| 32 | ############################################# |
| 33 | TARGET_DIR=${FULL_PATH}/target |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 34 | CONF_FILE=${FULL_PATH}/conf/attsdc.yaml |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 35 | DEBUG=true |
| 36 | MainClass=org.openecomp.sdc.ci.tests.run.StartTest |
| 37 | |
| 38 | JAR_FILE=$1 |
| 39 | SUITE_FILE=$2 |
| 40 | |
| 41 | #TARGET_DIR=`echo ${TARGET_DIR} | sed 's/\//\//g'` |
| 42 | #echo $TARGET_DIR |
| 43 | |
| 44 | TESTS_DIR=/opt/app/sdc/ci/resources/tests |
| 45 | COMPONENTS_DIR=/opt/app/sdc/ci/resources/components |
| 46 | |
| 47 | #sed -i 's#\(outputFolder:\).*#\1 '${TARGET_DIR}'#g' $CONF_FILE |
| 48 | #sed -i 's#\(resourceConfigDir:\).*#\1 '${TESTS_DIR}'#g' $CONF_FILE |
| 49 | #sed -i 's#\(componentsConfigDir:\).*#\1 '${COMPONENTS_DIR}'#g' $CONF_FILE |
| 50 | TARGET_LOG_DIR="${TARGET_DIR}/" |
| 51 | |
| 52 | # mkdir -p ${TARGET_DIR} |
| 53 | #if [ -d ${TARGET_DIR} ] |
| 54 | #then |
| 55 | # rm -rf ${TARGET_DIR}/* |
| 56 | #exitOnError $? "Failed_to_delete_target_dir" |
| 57 | #fi |
| 58 | |
| 59 | debug_port=8800 |
| 60 | #JAVA_OPTION="-javaagent:/var/tmp/jacoco/lib/jacocoagent.jar=destfile=jacoco-it.exec" |
| 61 | JAVA_OPTION="" |
| 62 | case "$2" in |
| 63 | -debug) echo "Debug mode, Listen on port $debug_port"; JAVA_OPTION="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=${debug_port}" ;; |
| 64 | "") echo "Standard mode";; |
| 65 | *) echo "USAGE: startTest.sh [-debug]";; |
| 66 | esac |
| 67 | |
| 68 | cmd="java $JAVA_OPTION -DdisplayException=true -Dtargetlog=${TARGET_LOG_DIR} -Dconfig.resource=${CONF_FILE} -Ddebug=${DEBUG} -Dlog4j.configuration=${LOGS_PROP_FILE} -cp $JAR_FILE ${MainClass} $SUITE_FILE" |
| 69 | |
| 70 | #echo $cmd |
| 71 | #console=`$cmd` |
| 72 | |
| 73 | if [ $DEBUG == "true" ] |
| 74 | then |
| 75 | $cmd |
| 76 | else |
| 77 | $cmd >> /dev/null |
| 78 | fi |
| 79 | status=`echo $?` |
| 80 | |
| 81 | |
| 82 | |
| 83 | echo "##################################################" |
| 84 | echo "################# status is ${status} #################" |
| 85 | echo "##################################################" |
| 86 | |
| 87 | exit $status |
| 88 | |