Initial OpenECOMP APPC commit
[appc.git] / app-c / appc / appc-asdc-listener / appc-asdc-listener-bundle / src / main / resources / ci / scripts / startTest.sh
1 ###
2 # ============LICENSE_START=======================================================
3 # openECOMP : APP-C
4 # ================================================================================
5 # Copyright (C) 2017 AT&T Intellectual Property. All rights
6 #                                               reserved.
7 # ================================================================================
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
11
12 #      http://www.apache.org/licenses/LICENSE-2.0
13
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19 # ============LICENSE_END=========================================================
20 ###
21
22 #!/bin/bash
23
24 function usage {
25         echo "Usage: $0 <jar file>"
26 }
27
28 function exitOnError() {
29         if [ $1 -ne 0 ]
30         then
31                 echo "Failed running task $2"
32                 exit 2
33         fi
34 }
35
36 if [ $# -lt 1 ]
37 then
38         usage
39         exit 2
40 fi
41
42 CURRENT_DIR=`pwd`
43 BASEDIR=$(dirname $0)
44
45 if [ ${BASEDIR:0:1} = "/" ]
46 then
47         FULL_PATH=$BASEDIR
48 else
49         FULL_PATH=$CURRENT_DIR/$BASEDIR
50 fi
51
52 LOGS_PROP_FILE=file:${FULL_PATH}/conf/log4j.properties
53 #############################################
54 TARGET_DIR=${FULL_PATH}/target
55 CONF_FILE=${FULL_PATH}/conf/attsdc.yaml
56 DEBUG=true
57 #MainClass=org.openecomp.tlv.sdc.ci.tests.run.StartTest
58 MainClass=org.openecomp.test.ClientTest
59
60 JAR_FILE=$1
61
62 #TARGET_DIR=`echo ${TARGET_DIR} | sed 's/\//\//g'`
63 #echo $TARGET_DIR
64
65 TESTS_DIR=/opt/app/sdc/ci/resources/tests
66 COMPONENTS_DIR=/opt/app/sdc/ci/resources/components
67
68 #sed -i 's#\(outputFolder:\).*#\1 '${TARGET_DIR}'#g' $CONF_FILE
69 #sed -i 's#\(resourceConfigDir:\).*#\1 '${TESTS_DIR}'#g' $CONF_FILE
70 #sed -i 's#\(componentsConfigDir:\).*#\1 '${COMPONENTS_DIR}'#g' $CONF_FILE
71 TARGET_LOG_DIR="${TARGET_DIR}/"
72
73 mkdir -p ${TARGET_DIR}
74 if [ -d ${TARGET_DIR} ]
75 then
76     rm -rf ${TARGET_DIR}/*
77         exitOnError $? "Failed_to_delete_target_dir"
78 fi
79
80 debug_port=8800
81 #JAVA_OPTION="-javaagent:/var/tmp/jacoco/lib/jacocoagent.jar=destfile=jacoco-it.exec"
82 JAVA_OPTION=""
83 case "$2" in
84         -debug) echo "Debug mode, Listen on port $debug_port"; JAVA_OPTION="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=${debug_port}" ;;
85         "") echo "Standard mode";;
86         *) echo "USAGE: startTest.sh [-debug]";;
87 esac
88
89 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}" 
90
91 #echo $cmd
92 #console=`$cmd`
93
94 if [ $DEBUG == "true" ]
95 then
96         $cmd
97 else
98         $cmd >> /dev/null
99 fi 
100 status=`echo $?`
101
102
103
104 echo "##################################################"
105 echo "################# status is ${status} #################" 
106 echo "##################################################"
107
108 exit $status 
109