blob: dc732c6bb9e769b3e149665dec3b86a8d674a3bd [file] [log] [blame]
Matthew Watkins8850db12022-12-16 18:01:56 +00001#!/bin/bash -x
2#
3# Copyright 2019-2021 Samsung Electronics Co., Ltd.
4# Modifications Copyright (C) 2021 Pantheon.tech
5#
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
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
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.
17#
18# This script installs common libraries required by CSIT tests
19#
20
21echo "---> prepare-csit.sh"
22
23set -exo pipefail
24
25ROBOT_INSTALLER='include-raw-integration-install-robotframework-py3.sh'
26
Matthew Watkins795671a2023-01-04 11:29:33 +000027# Allows testing for root permissions
28REQ_USER=$(id -un)
29
30if ! (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
37 apt-get update
38 apt-get install -y git
39 else
40 sudo apt-get update
41 sudo apt-get install -y git
42 fi
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
47 yum install -y git
48 else
49 sudo yum install -y git
50 fi
51 else
52 echo "Warning: unmatched OS/distribution"
53 echo "Missing software will not be installed"
54 fi
Matthew Watkins8850db12022-12-16 18:01:56 +000055fi
56
Matthew Watkins795671a2023-01-04 11:29:33 +000057if [[ -z "${WORKSPACE}" ]]; then
58 if (git rev-parse --show-toplevel > /dev/null 2>&1); then
59 WORKSPACE=$(git rev-parse --show-toplevel)
60 export WORKSPACE
61 else
62 WORKSPACE=$(pwd)
63 export WORKSPACE
64 fi
Matthew Watkins8850db12022-12-16 18:01:56 +000065fi
66
67# shellcheck disable=SC2034
Matthew Watkins795671a2023-01-04 11:29:33 +000068TESTPLANDIR="${WORKSPACE}/${TESTPLAN}"
Matthew Watkins8850db12022-12-16 18:01:56 +000069
70# Python version should match that used to setup
71# robot-framework in other jobs/stages
72# Use pyenv for selecting the python version
73if [[ -d "/opt/pyenv" ]]; then
74 echo "Setup pyenv:"
75 export PYENV_ROOT="/opt/pyenv"
76 export PATH="$PYENV_ROOT/bin:$PATH"
77 pyenv versions
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}"
84 fi
85fi
86
87# Assume that if ROBOT3_VENV is set, virtualenv
88# with system site packages can be activated
Matthew Watkins795671a2023-01-04 11:29:33 +000089if [[ -f "${WORKSPACE}/env.properties" ]]; then
90 source "${WORKSPACE}/env.properties"
91elif [[ -f /tmp/env.properties ]]; then
92 source /tmp/env.properties
Matthew Watkins8850db12022-12-16 18:01:56 +000093fi
Matthew Watkins795671a2023-01-04 11:29:33 +000094
95if [[ -f "${ROBOT3_VENV}/bin/activate" ]]; then
96 source "${ROBOT3_VENV}/bin/activate"
Matthew Watkins8850db12022-12-16 18:01:56 +000097else
98 # Robot framework was not found
Matthew Watkins4fec7bc2023-03-22 12:16:34 +000099 # 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" \
Matthew Watkins8850db12022-12-16 18:01:56 +0000102 /tmp/ci-management
Matthew Watkins4fec7bc2023-03-22 12:16:34 +0000103 else
104 git pull /tmp/ci-management
105 fi
Matthew Watkins795671a2023-01-04 11:29:33 +0000106 # shellcheck disable=SC1090
107 source "/tmp/ci-management/jjb/integration/${ROBOT_INSTALLER}"
Matthew Watkins8850db12022-12-16 18:01:56 +0000108fi
109
110# install eteutils
Matthew Watkins795671a2023-01-04 11:29:33 +0000111mkdir -p "${ROBOT3_VENV}/src/onap"
112rm -rf "${ROBOT3_VENV}/src/onap/testsuite"
Matthew Watkins8850db12022-12-16 18:01:56 +0000113# Source from the Nexus repository
114python3 -m pip install --upgrade \
115 --extra-index-url="https://nexus3.onap.org/repository/PyPi.staging/simple" \
116 'robotframework-onap==11.0.0.dev17' \
117 --pre
118
119echo "Versioning information:"
120python3 --version
121pip freeze
122python3 -m robot.run --version || :
123