Matthew Watkins | 8850db1 | 2022-12-16 18:01:56 +0000 | [diff] [blame] | 1 | #!/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 | |
| 21 | echo "---> prepare-csit.sh" |
| 22 | |
| 23 | set -exo pipefail |
| 24 | |
| 25 | ROBOT_INSTALLER='include-raw-integration-install-robotframework-py3.sh' |
| 26 | |
Matthew Watkins | 795671a | 2023-01-04 11:29:33 +0000 | [diff] [blame] | 27 | # Allows testing for root permissions |
| 28 | REQ_USER=$(id -un) |
| 29 | |
| 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 |
| 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 Watkins | 8850db1 | 2022-12-16 18:01:56 +0000 | [diff] [blame] | 55 | fi |
| 56 | |
Matthew Watkins | 795671a | 2023-01-04 11:29:33 +0000 | [diff] [blame] | 57 | if [[ -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 Watkins | 8850db1 | 2022-12-16 18:01:56 +0000 | [diff] [blame] | 65 | fi |
| 66 | |
| 67 | # shellcheck disable=SC2034 |
Matthew Watkins | 795671a | 2023-01-04 11:29:33 +0000 | [diff] [blame] | 68 | TESTPLANDIR="${WORKSPACE}/${TESTPLAN}" |
Matthew Watkins | 8850db1 | 2022-12-16 18:01:56 +0000 | [diff] [blame] | 69 | |
| 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 |
| 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 |
| 85 | fi |
| 86 | |
| 87 | # Assume that if ROBOT3_VENV is set, virtualenv |
| 88 | # with system site packages can be activated |
Matthew Watkins | 795671a | 2023-01-04 11:29:33 +0000 | [diff] [blame] | 89 | if [[ -f "${WORKSPACE}/env.properties" ]]; then |
| 90 | source "${WORKSPACE}/env.properties" |
| 91 | elif [[ -f /tmp/env.properties ]]; then |
| 92 | source /tmp/env.properties |
Matthew Watkins | 8850db1 | 2022-12-16 18:01:56 +0000 | [diff] [blame] | 93 | fi |
Matthew Watkins | 795671a | 2023-01-04 11:29:33 +0000 | [diff] [blame] | 94 | |
| 95 | if [[ -f "${ROBOT3_VENV}/bin/activate" ]]; then |
| 96 | source "${ROBOT3_VENV}/bin/activate" |
Matthew Watkins | 8850db1 | 2022-12-16 18:01:56 +0000 | [diff] [blame] | 97 | else |
| 98 | # Robot framework was not found |
Matthew Watkins | 4fec7bc | 2023-03-22 12:16:34 +0000 | [diff] [blame^] | 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" \ |
Matthew Watkins | 8850db1 | 2022-12-16 18:01:56 +0000 | [diff] [blame] | 102 | /tmp/ci-management |
Matthew Watkins | 4fec7bc | 2023-03-22 12:16:34 +0000 | [diff] [blame^] | 103 | else |
| 104 | git pull /tmp/ci-management |
| 105 | fi |
Matthew Watkins | 795671a | 2023-01-04 11:29:33 +0000 | [diff] [blame] | 106 | # shellcheck disable=SC1090 |
| 107 | source "/tmp/ci-management/jjb/integration/${ROBOT_INSTALLER}" |
Matthew Watkins | 8850db1 | 2022-12-16 18:01:56 +0000 | [diff] [blame] | 108 | fi |
| 109 | |
| 110 | # install eteutils |
Matthew Watkins | 795671a | 2023-01-04 11:29:33 +0000 | [diff] [blame] | 111 | mkdir -p "${ROBOT3_VENV}/src/onap" |
| 112 | rm -rf "${ROBOT3_VENV}/src/onap/testsuite" |
Matthew Watkins | 8850db1 | 2022-12-16 18:01:56 +0000 | [diff] [blame] | 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' \ |
| 117 | --pre |
| 118 | |
| 119 | echo "Versioning information:" |
| 120 | python3 --version |
| 121 | pip freeze |
| 122 | python3 -m robot.run --version || : |
| 123 | |