blob: a0de1fa56d27b9898f6eba3478446c9c25bdd558 [file] [log] [blame]
Michael Landob3d48982017-06-11 14:22:02 +03001#!/bin/bash
2REMOTE_DEBUG=false
3RERUN=true
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
72LOGS_PROP_FILE=file:${FULL_PATH}/conf/log4j.properties
73#############################################
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
87######ADD USERS################
88
89BE_IP=`cat conf/attsdc.yaml | grep catalogBeHost| awk '{print $2}'`
90
91ADD_USERS_SCRIPT="addUsersFromList_new.sh"
Tal Gitelman153a3582017-07-03 20:16:55 +030092USER_LIST="conf/userList.txt"
Michael Landob3d48982017-06-11 14:22:02 +030093chmod +x ${ADD_USERS_SCRIPT}
94echo "add users..."
95`./${ADD_USERS_SCRIPT} -ip ${BE_IP} -f ${USER_LIST}`
96
97
98
99
100if [ ${REMOTE_DEBUG} == "true" ]; then
101 echo "Debug mode, Listen on port $debug_port";
102 JAVA_OPTION="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=${debug_port}" ;
103fi
104
105cmd="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} -cp $JAR_FILE ${MainClass} $SUITE_FILE &"
106
107
108if [ $DEBUG == "true" ]
109then
110 $cmd
111else
112 $cmd >> /dev/null
113fi
114
115if [ ${RERUN} == "true" ]; then
116 if [ -f ${TARGET_DIR}/${fileName} ]; then
117 echo "Prepare" ${TARGET_DIR}/${fileName} "file to rerun all failed tests ...";
118 prepareFailedXmlFile ${TARGET_DIR}/${fileName} $SUITE_FILE;
119 SUITE_FILE=${fileName};
120 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} -cp $JAR_FILE ${MainClass} $SUITE_FILE &"
121 $cmd;
122 fi
123fi
124
125status=`echo $?`
126
127source ExtentReport/versions.info
128now=$(date +'%Y-%m-%d_%H_%M')
129REPORT_NAME=${now}
130VERSION=${osVersion}
131
132if [[ $env == *"DEV20"* ]]
133then
134 MYENV="Nightly"
135else
136 MYENV=""
137fi
138
139COPY_REPORT_SCRIPT="copyToStorage.sh"
140chmod +x ${COPY_REPORT_SCRIPT}
141echo "copy report to storage..."
142sh ./${COPY_REPORT_SCRIPT} ${REPORT_NAME} ${VERSION} ${MYENV}
143
144
145MAILING_SCRIPT_NAME="sendMail.sh"
146chmod +x ${MAILING_SCRIPT_NAME}
147echo "Sending report via mail..."
148`./${MAILING_SCRIPT_NAME} ${REPORT_NAME} ${VERSION} ${MYENV}`
149
150
151echo "##################################################"
152echo "################# status is ${status} #################"
153echo "##################################################"
154
155exit $status