3 # Copyright 2016-2017 Huawei Technologies Co., Ltd.
4 # Modification Copyright 2019 © Samsung Electronics Co., Ltd.
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
18 # $1 project/functionality
21 function docker_stats(){
22 #General memory details
23 echo "> top -bn1 | head -3"
31 #Memory details per Docker
36 echo "> docker stats --no-stream"
37 docker stats --no-stream
44 echo "Usage: $0 plans/<project>/<functionality> [<robot-options>]"
46 echo " <project>, <functionality>, <robot-options>: "
47 echo " The same values as for the '{project}-csit-{functionality}' JJB job template."
52 if [ -z "$WORKSPACE" ]; then
53 export WORKSPACE=`git rev-parse --show-toplevel`
56 rm -rf $WORKSPACE/archives
57 mkdir -p $WORKSPACE/archives
59 if [ -f ${WORKSPACE}/${1}/testplan.txt ]; then
60 export TESTPLAN="${1}"
62 echo "testplan not found: ${WORKSPACE}/${TESTPLAN}/testplan.txt"
66 export TESTOPTIONS="${2}"
68 TESTPLANDIR=${WORKSPACE}/${TESTPLAN}
70 # Run installation of prerequired libraries
71 source ${WORKSPACE}/prepare-csit.sh
73 # Activate the virtualenv containing all the required libraries installed by prepare-csit.sh
74 source "${ROBOT_VENV}/bin/activate"
76 WORKDIR=`mktemp -d --suffix=-robot-workdir`
82 # Add csit scripts to PATH
83 export PATH=${PATH}:${WORKSPACE}/docker/scripts:${WORKSPACE}/scripts:${ROBOT_VENV}/bin
84 export SCRIPTS=${WORKSPACE}/scripts
85 export ROBOT_VARIABLES=
87 # Sign in to nexus3 docker repo
88 docker login -u anonymous -p anonymous nexus3.onap.org:10001
90 # Run setup script plan if it exists
92 SETUP=${TESTPLANDIR}/setup.sh
93 if [ -f ${SETUP} ]; then
94 echo "Running setup script ${SETUP}"
98 # show memory consumption after all docker instances initialized
99 docker_stats | tee $WORKSPACE/archives/_sysinfo-1-after-setup.txt
103 echo "Reading the testplan:"
104 cat ${TESTPLANDIR}/testplan.txt | egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' | sed "s|^|${WORKSPACE}/tests/|" > testplan.txt
106 SUITES=$( xargs -a testplan.txt )
108 echo ROBOT_VARIABLES=${ROBOT_VARIABLES}
109 echo "Starting Robot test suites ${SUITES} ..."
111 python -m robot.run -N ${TESTPLAN} -v WORKSPACE:/tmp ${ROBOT_VARIABLES} ${TESTOPTIONS} ${SUITES}
114 echo "RESULT: " $RESULT
115 rsync -av $WORKDIR/ $WORKSPACE/archives
117 # Record list of active docker containers
118 docker ps --format "{{.Image}}" > $WORKSPACE/archives/_docker-images.log
120 # show memory consumption after all docker instances initialized
121 docker_stats | tee $WORKSPACE/archives/_sysinfo-2-after-robot.txt
123 # Run teardown script plan if it exists
125 TEARDOWN=${TESTPLANDIR}/teardown.sh
126 if [ -f ${TEARDOWN} ]; then
127 echo "Running teardown script ${TEARDOWN}"
131 # TODO: do something with the output