blob: f8285ef506e51cf71ce34de6422d4fb52ac345a0 [file] [log] [blame]
Michael Landob3d48982017-06-11 14:22:02 +03001#!/bin/bash
2REMOTE_DEBUG=false
3RERUN=false
4JAVA_OPTION=""
5debug_port=8000
6TEST_SUITES=testSuites
7fileName=testng-failed.xml
8
9function help_usage ()
10{
11 echo
12 echo "$0 (<jar_file_name> <suite file name>) [-r/rerun <true/false> -d/debug <true/false>]"
13 echo "nohup ./startTest.sh ui-ci-1707.0.5-SNAPSHOT-jar-with-dependencies.jar extendedSanity.xml -r false -d true &"
14 echo "by default rerun is true and remote debug is false."
15 echo
16 exit 2
17}
18
19function isBoolean ()
20{
21 PARAM_NAME=$1
22 VALUE=$2
23 if [[ ${VALUE} != "true" ]] && [[ ${VALUE} != "false" ]]; then
24 echo "Valid parameter" ${PARAM_NAME} "values are: true/false"
25 help_usage
26 fi
27}
28
29function prepareFailedXmlFile ()
30{
31 echo "1="$1 "2="$2 "fileName="${fileName}
32 PATTERN=`grep -w "test name=" ${FULL_PATH}/${TEST_SUITES}/$2 | awk -F'"' '{print $2}'`
33 sed '/<test name="'${PATTERN}'"/,/<!-- '${PATTERN}' --/d' $1 > ${FULL_PATH}/${TEST_SUITES}/${fileName}
34 sed -i 's/thread-count="[0-9]\+"/thread-count="1"/g' ${FULL_PATH}/${TEST_SUITES}/${fileName}
35}
36
37#main
38[ $# -lt 2 ] && help_usage
39
40JAR_FILE=$1
41SUITE_FILE=$2
42
43while [ $# -ne 0 ]; do
44 case $1 in
45 -r|rerun)
46 RERUN=$2
47 isBoolean $1 ${RERUN}
48 shift 1
49 shift 1
50 ;;
51 -d|debug)
52 REMOTE_DEBUG=$2
53 isBoolean $1 ${REMOTE_DEBUG}
54 shift 1
55 shift 1
56 ;;
57 *)
58 shift 1
59 ;;
60 esac
61done
62
63CURRENT_DIR=`pwd`
64BASEDIR=$(dirname $0)
65
66if [ ${BASEDIR:0:1} = "/" ]
67then
68 FULL_PATH=$BASEDIR
69else
70 FULL_PATH=$CURRENT_DIR/$BASEDIR
71fi
amohamad9ee60942020-06-26 12:40:11 -040072LOGS_PROP_FILE=file:${FULL_PATH}/conf/log4j2.properties
Michael Landob3d48982017-06-11 14:22:02 +030073#############################################
74TARGET_DIR=${FULL_PATH}/target
75CONF_FILE=${FULL_PATH}/conf/attsdc.yaml
76
77DEBUG=true
78MainClass=org.openecomp.sdc.ci.tests.run.StartTest
79
80TESTS_DIR=/opt/app/sdc/ci/resources/tests
81COMPONENTS_DIR=/opt/app/sdc/ci/resources/components
82
83
84TARGET_LOG_DIR="${TARGET_DIR}/"
85
86######ADD USERS################
87
88BE_IP=`cat conf/attsdc.yaml | grep catalogBeHost| awk '{print $2}'`
89
90ADD_USERS_SCRIPT="addUsersFromList_new.sh"
Tal Gitelman153a3582017-07-03 20:16:55 +030091USER_LIST="conf/userList.txt"
Michael Landob3d48982017-06-11 14:22:02 +030092chmod +x ${ADD_USERS_SCRIPT}
93echo "add users..."
Michael Landoa5445102018-03-04 14:53:33 +020094./${ADD_USERS_SCRIPT} -ip ${BE_IP} -f ${USER_LIST}
Michael Landob3d48982017-06-11 14:22:02 +030095
96
97
98if [ ${REMOTE_DEBUG} == "true" ]; then
99 echo "Debug mode, Listen on port $debug_port";
100 JAVA_OPTION="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=${debug_port}" ;
101fi
102
Michael Lando5b593492018-07-29 16:13:45 +0300103cmd="java -Xmx2048m -Xms1024m $JAVA_OPTION -DdisplayException=true -Dtargetlog=${TARGET_LOG_DIR} -Dfilepath=${FILES_TEST} -Dconfig.resource=${CONF_FILE} -Ddebug=${DEBUG} -Dlog4j.configuration=${LOGS_PROP_FILE} -Dorg.freemarker.loggerLibrary=none -cp $JAR_FILE ${MainClass} $SUITE_FILE &"
Michael Landob3d48982017-06-11 14:22:02 +0300104
105
106if [ $DEBUG == "true" ]
107then
108 $cmd
109else
110 $cmd >> /dev/null
111fi
112
113if [ ${RERUN} == "true" ]; then
114 if [ -f ${TARGET_DIR}/${fileName} ]; then
115 echo "Prepare" ${TARGET_DIR}/${fileName} "file to rerun all failed tests ...";
116 prepareFailedXmlFile ${TARGET_DIR}/${fileName} $SUITE_FILE;
117 SUITE_FILE=${fileName};
Michael Lando5b593492018-07-29 16:13:45 +0300118 cmd="java -Xmx2048m -Xms1024m $JAVA_OPTION -DdisplayException=true -Dtargetlog=${TARGET_LOG_DIR} -Dfilepath=${FILES_TEST} -Dconfig.resource=${CONF_FILE} -Ddebug=${DEBUG} -Dlog4j.configuration=${LOGS_PROP_FILE} -Dorg.freemarker.loggerLibrary=none -cp $JAR_FILE ${MainClass} $SUITE_FILE &"
Michael Landob3d48982017-06-11 14:22:02 +0300119 $cmd;
120 fi
121fi
122
123status=`echo $?`
124
125source ExtentReport/versions.info
126now=$(date +'%Y-%m-%d_%H_%M')
127REPORT_NAME=${now}
128VERSION=${osVersion}
129
130if [[ $env == *"DEV20"* ]]
131then
132 MYENV="Nightly"
133else
134 MYENV=""
135fi
136
137COPY_REPORT_SCRIPT="copyToStorage.sh"
138chmod +x ${COPY_REPORT_SCRIPT}
139echo "copy report to storage..."
Michael Landoa5445102018-03-04 14:53:33 +0200140( ./${COPY_REPORT_SCRIPT} ${REPORT_NAME} ${VERSION} ${MYENV} )
Michael Landob3d48982017-06-11 14:22:02 +0300141
142
143MAILING_SCRIPT_NAME="sendMail.sh"
144chmod +x ${MAILING_SCRIPT_NAME}
145echo "Sending report via mail..."
146`./${MAILING_SCRIPT_NAME} ${REPORT_NAME} ${VERSION} ${MYENV}`
147
148
149echo "##################################################"
150echo "################# status is ${status} #################"
151echo "##################################################"
152
153exit $status