rameshiyer27 | b15eda6 | 2024-02-14 10:13:16 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright 2024 Nordix Foundation. |
| 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 | |
| 18 | # Script to run the ACM regression test suite in cucumber. |
rameshiyer27 | 9c4e66a | 2024-07-17 23:19:44 +0000 | [diff] [blame^] | 19 | # Deploys ACM-R and participants in two different release branch/versions for testing backward compatibility. |
rameshiyer27 | b15eda6 | 2024-02-14 10:13:16 +0000 | [diff] [blame] | 20 | |
rameshiyer27 | 9c4e66a | 2024-07-17 23:19:44 +0000 | [diff] [blame^] | 21 | function usage() { |
| 22 | echo "Usage: $0 --release <acmr-release_branch> <ppnt-release_branch> | --version <acmr-version> <ppnt-version>" |
| 23 | exit 1 |
| 24 | } |
rameshiyer27 | b15eda6 | 2024-02-14 10:13:16 +0000 | [diff] [blame] | 25 | |
rameshiyer27 | 9c4e66a | 2024-07-17 23:19:44 +0000 | [diff] [blame^] | 26 | # Legacy config files for releases up to 'newdelhi' |
| 27 | function release_config_path() { |
| 28 | if [ $1 == 'master' ] || [[ "$(echo "$1" | cut -c1 )" > 'n' ]]; then |
| 29 | echo "config/clamp" |
| 30 | else |
| 31 | echo "config/clamp/legacy" |
| 32 | fi |
| 33 | } |
rameshiyer27 | b15eda6 | 2024-02-14 10:13:16 +0000 | [diff] [blame] | 34 | |
rameshiyer27 | 9c4e66a | 2024-07-17 23:19:44 +0000 | [diff] [blame^] | 35 | # Legacy config files for versions before 8.0.0 |
| 36 | function version_config_path() { |
| 37 | if [[ "$(printf '%s\n' "$1" "8.0.0" | sort -V | head -n 1)" == "8.0.0" ]]; then |
| 38 | echo "config/clamp" |
| 39 | else |
| 40 | echo "config/clamp/legacy" |
| 41 | fi |
| 42 | } |
| 43 | |
| 44 | function validate_version() { |
| 45 | local version=$1 |
| 46 | if [[ ! $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 47 | echo "Invalid version format: $version. Expected format: x.y.z where x, y, and z are numbers." |
| 48 | usage |
| 49 | fi |
| 50 | } |
| 51 | |
| 52 | function validate_release() { |
| 53 | local release=$1 |
| 54 | if [[ ! $release =~ ^[a-zA-Z._-]+$ ]]; then |
| 55 | echo "Invalid release format: $release. Expected a string release name" |
| 56 | usage |
| 57 | fi |
| 58 | } |
| 59 | |
| 60 | # Invalid input |
| 61 | if [ "$#" -ne 0 ] && [ "$#" -ne 3 ]; then |
| 62 | usage |
rameshiyer27 | b15eda6 | 2024-02-14 10:13:16 +0000 | [diff] [blame] | 63 | fi |
| 64 | |
| 65 | if [ -z "${WORKSPACE}" ]; then |
| 66 | WORKSPACE=$(git rev-parse --show-toplevel) |
| 67 | export WORKSPACE |
| 68 | fi |
| 69 | |
rameshiyer27 | 9c4e66a | 2024-07-17 23:19:44 +0000 | [diff] [blame^] | 70 | if [ -z "$ROBOT_LOG_DIR" ]; then |
| 71 | export ROBOT_LOG_DIR=/tmp/ |
| 72 | fi |
rameshiyer27 | b15eda6 | 2024-02-14 10:13:16 +0000 | [diff] [blame] | 73 | |
| 74 | export SCRIPTS="${WORKSPACE}/csit/resources/scripts" |
rameshiyer27 | b15eda6 | 2024-02-14 10:13:16 +0000 | [diff] [blame] | 75 | COMPOSE_FOLDER="${WORKSPACE}"/compose |
| 76 | REGRESSION_FOLDER="${WORKSPACE}"/policy-regression-tests/policy-clamp-regression/ |
| 77 | export PROJECT='clamp' |
rameshiyer27 | 9c4e66a | 2024-07-17 23:19:44 +0000 | [diff] [blame^] | 78 | DEFAULT_BRANCH=$(awk -F= '$1 == "defaultbranch" { print $2 }' \ |
| 79 | "${WORKSPACE}"/.gitreview) |
rameshiyer27 | b15eda6 | 2024-02-14 10:13:16 +0000 | [diff] [blame] | 80 | |
rameshiyer27 | 9c4e66a | 2024-07-17 23:19:44 +0000 | [diff] [blame^] | 81 | # Run from default branch |
| 82 | if [ $# -eq 0 ] |
| 83 | then |
| 84 | echo "Usage: $0 --release <acmr-release_branch> <ppnt-release_branch> | --version <acmr-version> <ppnt-version>" |
| 85 | echo "*** No release_branch/versions provided. Default branch will be used." |
| 86 | echo "Fetching image versions for all components..." |
| 87 | source ${COMPOSE_FOLDER}/get-versions-regression.sh $DEFAULT_BRANCH $DEFAULT_BRANCH > /dev/null 2>&1 |
| 88 | echo "Starting Regression with ACM-R and PPNT from the default release branch $DEFAULT_BRANCH ***" |
| 89 | export CLAMP_CONFIG_PATH=$(release_config_path "$DEFAULT_BRANCH") |
| 90 | export PPNT_CONFIG_PATH="$CLAMP_CONFIG_PATH" |
| 91 | echo "Using configuration file located at $CLAMP_CONFIG_PATH for ACM-R and $PPNT_CONFIG_PATH for PPNTS." |
rameshiyer27 | b15eda6 | 2024-02-14 10:13:16 +0000 | [diff] [blame] | 92 | |
rameshiyer27 | 9c4e66a | 2024-07-17 23:19:44 +0000 | [diff] [blame^] | 93 | # Run with specific release/version |
| 94 | elif [ "$#" -gt 0 ] |
| 95 | then |
| 96 | case $1 in |
| 97 | --release) |
| 98 | validate_release $2 |
| 99 | validate_release $3 |
| 100 | echo "Fetching image versions for all components..." |
| 101 | source ${COMPOSE_FOLDER}/get-versions-regression.sh $2 $3 > /dev/null 2>&1 |
| 102 | echo "*** Starting Regression with ACM-R from branch $2 and PPNT from branch $3 ***" |
| 103 | export CLAMP_CONFIG_PATH=$(release_config_path $2) |
| 104 | export PPNT_CONFIG_PATH=$(release_config_path $3) |
| 105 | echo "Using configuration file located at $CLAMP_CONFIG_PATH for ACM-R and $PPNT_CONFIG_PATH for PPNTS." |
| 106 | ;; |
| 107 | --version) |
| 108 | validate_version $2 |
| 109 | validate_version $3 |
| 110 | echo "Fetching image versions for all components..." |
| 111 | source ${COMPOSE_FOLDER}/get-versions-regression.sh $DEFAULT_BRANCH $DEFAULT_BRANCH > /dev/null 2>&1 |
| 112 | export POLICY_CLAMP_VERSION=$2 |
| 113 | export POLICY_CLAMP_PPNT_VERSION=$3 |
| 114 | echo "*** Starting Regression with ACM-R version $2 and PPNT version $3 ***" |
| 115 | export CLAMP_CONFIG_PATH=$(version_config_path "$2") |
| 116 | export PPNT_CONFIG_PATH=$(version_config_path "$3") |
| 117 | echo "Using configuration file located at $CLAMP_CONFIG_PATH for ACM-R and $PPNT_CONFIG_PATH for PPNTS." |
| 118 | ;; |
| 119 | *) |
| 120 | echo "Unknown parameter: $1" |
| 121 | usage |
| 122 | ;; |
| 123 | esac |
| 124 | fi |
| 125 | |
| 126 | echo "*** Configure docker compose and trigger deployment***" |
rameshiyer27 | b15eda6 | 2024-02-14 10:13:16 +0000 | [diff] [blame] | 127 | cd ${COMPOSE_FOLDER} |
rameshiyer27 | 9c4e66a | 2024-07-17 23:19:44 +0000 | [diff] [blame^] | 128 | docker login -u docker -p docker nexus3.onap.org:10001 > /dev/null 2>&1 |
rameshiyer27 | b15eda6 | 2024-02-14 10:13:16 +0000 | [diff] [blame] | 129 | source export-ports.sh > /dev/null 2>&1 |
rameshiyer27 | b15eda6 | 2024-02-14 10:13:16 +0000 | [diff] [blame] | 130 | |
rameshiyer27 | 9c4e66a | 2024-07-17 23:19:44 +0000 | [diff] [blame^] | 131 | docker compose -f docker-compose.yml up -d "policy-clamp-runtime-acm" |
rameshiyer27 | b15eda6 | 2024-02-14 10:13:16 +0000 | [diff] [blame] | 132 | |
| 133 | # wait for the app to start up |
| 134 | "${SCRIPTS}"/wait_for_rest.sh localhost "${ACM_PORT}" |
| 135 | |
| 136 | cd ${REGRESSION_FOLDER} |
| 137 | |
| 138 | # Invoke the regression test cases |
rameshiyer27 | 9c4e66a | 2024-07-17 23:19:44 +0000 | [diff] [blame^] | 139 | mvn clean test -Dtests.skip=false |
| 140 | |