3 # Copyright 2019-2021 Samsung Electronics Co., Ltd.
4 # Modifications Copyright (C) 2021 Pantheon.tech
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 # This script installs common libraries required by CSIT tests
21 echo "---> prepare-csit.sh"
25 ROBOT_INSTALLER='include-raw-integration-install-robotframework-py3.sh'
27 # Allows testing for root permissions
30 if ! (which git > /dev/null 2>&1); then
31 echo "GIT binary not found in current PATH"
32 # Add missing package to prevent script/job failures
33 if (grep Ubuntu /etc/os-release > /dev/null 2>&1) || \
34 (grep Debian /etc/os-release > /dev/null 2>&1); then
35 echo "Installing package dependency for Ubuntu/Debian"
36 if [[ "${REQ_USER}" == 'root' ]]; then
38 apt-get install -y git
41 sudo apt-get install -y git
43 elif (grep RedHat /etc/os-release > /dev/null 2>&1) || \
44 (grep CentOS /etc/os-release > /dev/null 2>&1); then
45 echo "Installing package dependency for CentOS/RedHat"
46 if [[ "${REQ_USER}" == 'root' ]]; then
49 sudo yum install -y git
52 echo "Warning: unmatched OS/distribution"
53 echo "Missing software will not be installed"
57 if [[ -z "${WORKSPACE}" ]]; then
58 if (git rev-parse --show-toplevel > /dev/null 2>&1); then
59 WORKSPACE=$(git rev-parse --show-toplevel)
67 # shellcheck disable=SC2034
68 TESTPLANDIR="${WORKSPACE}/${TESTPLAN}"
70 # Python version should match that used to setup
71 # robot-framework in other jobs/stages
72 # Use pyenv for selecting the python version
73 if [[ -d "/opt/pyenv" ]]; then
75 export PYENV_ROOT="/opt/pyenv"
76 export PATH="$PYENV_ROOT/bin:$PATH"
78 if command -v pyenv 1>/dev/null 2>&1; then
79 eval "$(pyenv init - --no-rehash)"
80 # Choose the latest numeric Python version from installed list
81 version=$(pyenv versions --bare | sed '/^[^0-9]/d' \
82 | sort -V | tail -n 1)
83 pyenv local "${version}"
87 # Assume that if ROBOT3_VENV is set, virtualenv
88 # with system site packages can be activated
89 if [[ -f "${WORKSPACE}/env.properties" ]]; then
90 source "${WORKSPACE}/env.properties"
91 elif [[ -f /tmp/env.properties ]]; then
92 source /tmp/env.properties
95 if [[ -f "${ROBOT3_VENV}/bin/activate" ]]; then
96 source "${ROBOT3_VENV}/bin/activate"
98 # Robot framework was not found
99 # Clone/update ci-management repository and invoke install script
100 if [[ ! -d /tmp/ci-management ]]; then
101 git clone "https://gerrit.onap.org/r/ci-management" \
104 git pull /tmp/ci-management
106 # shellcheck disable=SC1090
107 source "/tmp/ci-management/jjb/integration/${ROBOT_INSTALLER}"
111 mkdir -p "${ROBOT3_VENV}/src/onap"
112 rm -rf "${ROBOT3_VENV}/src/onap/testsuite"
113 # Source from the Nexus repository
114 python3 -m pip install --upgrade \
115 --extra-index-url="https://nexus3.onap.org/repository/PyPi.staging/simple" \
116 'robotframework-onap==11.0.0.dev17' \
119 echo "Versioning information:"
122 python3 -m robot.run --version || :