blob: a048a0d69d52f067eb10b4e82c8aec0d3bff7999 [file] [log] [blame]
Gary Wu91387022017-06-16 13:06:20 -07001#!/bin/bash
2#
3# Copyright 2016-2017 Huawei Technologies Co., Ltd.
4#
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
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
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.
16#
17# $1 project/functionality
18# $2 robot options
19# $3 ci-management repo location
20
21
22function docker_stats(){
23 #General memory details
24 echo "> top -bn1 | head -3"
25 top -bn1 | head -3
26 echo
27
28 echo "> free -h"
29 free -h
30 echo
31
32 #Memory details per Docker
33 echo "> docker ps"
34 docker ps
35 echo
36
37 echo "> docker stats --no-stream"
38 docker stats --no-stream
39 echo
40}
41
42if [ $# -eq 0 ]
43then
44 echo
45 echo "Usage: $0 plans/<project>/<functionality> [<robot-options>] [<ci-management-dir>]"
46 echo
47 echo " <project>, <functionality>, <robot-options>: "
48 echo " The same values as for the '{project}-csit-{functionality}' JJB job template."
49 echo
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."
53 echo
54 exit 1
55fi
56
57if [ -z "$WORKSPACE" ]; then
58 export WORKSPACE=`git rev-parse --show-toplevel`
59fi
60rm -rf $WORKSPACE/archives
61mkdir -p $WORKSPACE/archives
62
63if [ -f ${WORKSPACE}/test/csit/${1}/testplan.txt ]; then
64 export TESTPLAN="${1}"
65else
66 echo "testplan not found: ${WORKSPACE}/test/csit/${TESTPLAN}/testplan.txt"
67 exit 2
68fi
69
70
71export TESTOPTIONS="${2}"
72
73if [ -z "$3" ]; then
74 CI=${WORKSPACE}/../ci-management
75else
76 CI=${3}
77fi
78
79
80
81
82TESTPLANDIR=${WORKSPACE}/test/csit/${TESTPLAN}
83
84# Assume that if ROBOT_VENV is set, we don't need to reinstall robot
85if [ -f ${WORKSPACE}/env.properties ]; then
86 source ${WORKSPACE}/env.properties
87 source ${ROBOT_VENV}/bin/activate
88fi
89if ! type pybot > /dev/null; then
90 rm -f ${WORKSPACE}/env.properties
91 source $CI/jjb/integration/include-raw-integration-install-robotframework.sh
92 source ${WORKSPACE}/env.properties
93 source ${ROBOT_VENV}/bin/activate
94fi
95
Gary Wu94f347b2017-09-18 12:45:00 -070096# install required Robot libraries
Gary Wu2b7aef32018-01-11 11:37:27 -080097pip install robotframework-selenium2library==1.8.0 robotframework-extendedselenium2library==0.9.1
Gary Wu94f347b2017-09-18 12:45:00 -070098
Gary Wu290fe982017-09-14 15:18:09 -070099# install eteutils
Gary Wu84d2f202017-09-15 13:17:56 -0700100mkdir -p ${ROBOT_VENV}/src/onap
101rm -rf ${ROBOT_VENV}/src/onap/testsuite
102git clone https://gerrit.onap.org/r/testsuite/python-testing-utils.git ${ROBOT_VENV}/src/onap/testsuite/python-testing-utils
103pip install --upgrade ${ROBOT_VENV}/src/onap/testsuite/python-testing-utils
Gary Wu290fe982017-09-14 15:18:09 -0700104
Gary Wu2b7aef32018-01-11 11:37:27 -0800105pip freeze
106
Gary Wu7a57d372017-09-18 15:44:55 -0700107# install chrome driver
Gary Wu385bbfe2018-08-06 12:11:24 -0700108google-chrome --version
Gary Wu7a57d372017-09-18 15:44:55 -0700109if [ ! -x ${ROBOT_VENV}/bin/chromedriver ]; then
110 pushd ${ROBOT_VENV}/bin
Gary Wu385bbfe2018-08-06 12:11:24 -0700111 wget -N http://chromedriver.storage.googleapis.com/2.35/chromedriver_linux64.zip
Gary Wu7a57d372017-09-18 15:44:55 -0700112 unzip chromedriver_linux64.zip
113 chmod +x chromedriver
114 popd
115fi
116
Gary Wu91387022017-06-16 13:06:20 -0700117
118WORKDIR=`mktemp -d --suffix=-robot-workdir`
119cd ${WORKDIR}
120
121
122set +u
123set -x
124
125
126# Add csit scripts to PATH
Gary Wu7a57d372017-09-18 15:44:55 -0700127export PATH=${PATH}:${WORKSPACE}/test/csit/docker/scripts:${WORKSPACE}/test/csit/scripts:${ROBOT_VENV}/bin
Gary Wu91387022017-06-16 13:06:20 -0700128export SCRIPTS=${WORKSPACE}/test/csit/scripts
129export ROBOT_VARIABLES=
130
Gary Wu1346b682017-08-08 08:04:44 -0700131# Sign in to nexus3 docker repo
132docker login -u anonymous -p anonymous nexus3.onap.org:10001
133
Gary Wu91387022017-06-16 13:06:20 -0700134# Run setup script plan if it exists
135cd ${TESTPLANDIR}
136SETUP=${TESTPLANDIR}/setup.sh
137if [ -f ${SETUP} ]; then
138 echo "Running setup script ${SETUP}"
139 source ${SETUP}
140fi
141
142# show memory consumption after all docker instances initialized
143docker_stats | tee $WORKSPACE/archives/_sysinfo-1-after-setup.txt
144
145# Run test plan
146cd $WORKDIR
147echo "Reading the testplan:"
148cat ${TESTPLANDIR}/testplan.txt | egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' | sed "s|^|${WORKSPACE}/test/csit/tests/|" > testplan.txt
149cat testplan.txt
150SUITES=$( xargs -a testplan.txt )
151
152echo ROBOT_VARIABLES=${ROBOT_VARIABLES}
153echo "Starting Robot test suites ${SUITES} ..."
154set +e
155pybot -N ${TESTPLAN} -v WORKSPACE:/tmp ${ROBOT_VARIABLES} ${TESTOPTIONS} ${SUITES}
156RESULT=$?
157set -e
158echo "RESULT: " $RESULT
159rsync -av $WORKDIR/ $WORKSPACE/archives
160
161# Record list of active docker containers
162docker ps --format "{{.Image}}" > $WORKSPACE/archives/_docker-images.log
163
164# show memory consumption after all docker instances initialized
165docker_stats | tee $WORKSPACE/archives/_sysinfo-2-after-robot.txt
166
167# Run teardown script plan if it exists
168cd ${TESTPLANDIR}
169TEARDOWN=${TESTPLANDIR}/teardown.sh
170if [ -f ${TEARDOWN} ]; then
171 echo "Running teardown script ${TEARDOWN}"
172 source ${TEARDOWN}
173fi
174
175# TODO: do something with the output
176
177exit $RESULT