3 # Copyright 2016-2017 Huawei Technologies Co., Ltd.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # $1 project/functionality
19 # $3 ci-management repo location
22 function docker_stats(){
23 #General memory details
24 echo "> top -bn1 | head -3"
32 #Memory details per Docker
37 echo "> docker stats --no-stream"
38 docker stats --no-stream
45 echo "Usage: $0 plans/<project>/<functionality> [<robot-options>] [<ci-management-dir>]"
47 echo " <project>, <functionality>, <robot-options>: "
48 echo " The same values as for the '{project}-csit-{functionality}' JJB job template."
50 echo " <ci-management-dir>: "
51 echo " Path to the ci-management repo checked out locally. It not specified, "
52 echo " assumed to be adjacent to the integration repo directory."
57 if [ -z "$WORKSPACE" ]; then
58 export WORKSPACE=`git rev-parse --show-toplevel`
60 rm -rf $WORKSPACE/archives
61 mkdir -p $WORKSPACE/archives
63 if [ -f ${WORKSPACE}/${1}/testplan.txt ]; then
64 export TESTPLAN="${1}"
66 echo "testplan not found: ${WORKSPACE}/${TESTPLAN}/testplan.txt"
71 export TESTOPTIONS="${2}"
74 CI=${WORKSPACE}/../../ci-management
82 TESTPLANDIR=${WORKSPACE}/${TESTPLAN}
84 # Assume that if ROBOT_VENV is set, we don't need to reinstall robot
85 if [ -f ${WORKSPACE}/env.properties ]; then
86 source ${WORKSPACE}/env.properties
88 if [ -f ${ROBOT_VENV}/bin/activate ]; then
89 source ${ROBOT_VENV}/bin/activate
91 source $CI/jjb/integration/include-raw-integration-install-robotframework.sh
94 # install required Robot libraries
95 pip install robotframework-selenium2library==1.8.0 robotframework-extendedselenium2library==0.9.1
98 mkdir -p ${ROBOT_VENV}/src/onap
99 rm -rf ${ROBOT_VENV}/src/onap/testsuite
100 git clone https://gerrit.onap.org/r/testsuite/python-testing-utils.git ${ROBOT_VENV}/src/onap/testsuite/python-testing-utils
101 pip install --upgrade ${ROBOT_VENV}/src/onap/testsuite/python-testing-utils
105 # install chrome driver
106 google-chrome --version
107 if [ ! -x ${ROBOT_VENV}/bin/chromedriver ]; then
108 pushd ${ROBOT_VENV}/bin
109 wget -N http://chromedriver.storage.googleapis.com/2.35/chromedriver_linux64.zip
110 unzip chromedriver_linux64.zip
111 chmod +x chromedriver
116 WORKDIR=`mktemp -d --suffix=-robot-workdir`
124 # Add csit scripts to PATH
125 export PATH=${PATH}:${WORKSPACE}/docker/scripts:${WORKSPACE}/scripts:${ROBOT_VENV}/bin
126 export SCRIPTS=${WORKSPACE}/scripts
127 export ROBOT_VARIABLES=
129 # Sign in to nexus3 docker repo
130 docker login -u anonymous -p anonymous nexus3.onap.org:10001
132 # Run setup script plan if it exists
134 SETUP=${TESTPLANDIR}/setup.sh
135 if [ -f ${SETUP} ]; then
136 echo "Running setup script ${SETUP}"
140 # show memory consumption after all docker instances initialized
141 docker_stats | tee $WORKSPACE/archives/_sysinfo-1-after-setup.txt
145 echo "Reading the testplan:"
146 cat ${TESTPLANDIR}/testplan.txt | egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' | sed "s|^|${WORKSPACE}/tests/|" > testplan.txt
148 SUITES=$( xargs -a testplan.txt )
150 echo ROBOT_VARIABLES=${ROBOT_VARIABLES}
151 echo "Starting Robot test suites ${SUITES} ..."
153 python -m robot.run -N ${TESTPLAN} -v WORKSPACE:/tmp ${ROBOT_VARIABLES} ${TESTOPTIONS} ${SUITES}
156 echo "RESULT: " $RESULT
157 rsync -av $WORKDIR/ $WORKSPACE/archives
159 # Record list of active docker containers
160 docker ps --format "{{.Image}}" > $WORKSPACE/archives/_docker-images.log
162 # show memory consumption after all docker instances initialized
163 docker_stats | tee $WORKSPACE/archives/_sysinfo-2-after-robot.txt
165 # Run teardown script plan if it exists
167 TEARDOWN=${TESTPLANDIR}/teardown.sh
168 if [ -f ${TEARDOWN} ]; then
169 echo "Running teardown script ${TEARDOWN}"
173 # TODO: do something with the output