From 81b579eabbcc4edb7956260caf32c70bc8640e9d Mon Sep 17 00:00:00 2001 From: liamfallon Date: Tue, 28 Jun 2022 15:55:29 +0100 Subject: Update get version script for snapshots The current script assumes that snapshot versions are always available. However the Linux Foundation has now implemented a policy of deleting snapshots on no-master branches that are older than a certain age. THis breaks our CSITs. THis updated script copes with this by checking if a snapshot is avaialable and, if the snapshot is not available, the script falls back to the released version. This script will be needed on other branches besides master as well. Issue-ID: POLICY-4233 Change-Id: I7a9fe7ffc3abfc8044a2e0439e3fcd47c086d5f8 Signed-off-by: liamfallon --- csit/compose-grafana.yml | 2 +- csit/docker-compose-all.yml | 2 +- csit/docker-compose-gui-smoke.yml | 2 +- csit/get-versions.sh | 113 ++++++++++++++++++++++++++++---------- 4 files changed, 88 insertions(+), 31 deletions(-) (limited to 'csit') diff --git a/csit/compose-grafana.yml b/csit/compose-grafana.yml index e487a705..75b39fbb 100644 --- a/csit/compose-grafana.yml +++ b/csit/compose-grafana.yml @@ -130,7 +130,7 @@ services: 'pap', '6969' ] drools: - image: nexus3.onap.org:10001/onap/policy-drools:${POLICY_DROOLS_VERSION} + image: nexus3.onap.org:10001/onap/policy-drools:${POLICY_DROOLS_PDP_VERSION} container_name: drools depends_on: - mariadb diff --git a/csit/docker-compose-all.yml b/csit/docker-compose-all.yml index 2ac9b90d..a8a795ce 100644 --- a/csit/docker-compose-all.yml +++ b/csit/docker-compose-all.yml @@ -139,7 +139,7 @@ services: 'pap', '6969' ] drools: - image: nexus3.onap.org:10001/onap/policy-drools:${POLICY_DROOLS_VERSION} + image: nexus3.onap.org:10001/onap/policy-drools:${POLICY_DROOLS_PDP_VERSION} container_name: drools depends_on: - mariadb diff --git a/csit/docker-compose-gui-smoke.yml b/csit/docker-compose-gui-smoke.yml index 3951cb2f..8be6ec6e 100644 --- a/csit/docker-compose-gui-smoke.yml +++ b/csit/docker-compose-gui-smoke.yml @@ -137,7 +137,7 @@ services: 'pap', '6969' ] drools: - image: nexus3.onap.org:10001/onap/policy-drools:${POLICY_DROOLS_VERSION} + image: nexus3.onap.org:10001/onap/policy-drools:${POLICY_DROOLS_PDP_VERSION} container_name: drools depends_on: - mariadb diff --git a/csit/get-versions.sh b/csit/get-versions.sh index 6e50d088..623b85eb 100644 --- a/csit/get-versions.sh +++ b/csit/get-versions.sh @@ -26,45 +26,102 @@ echo POLICY_MARIADB_VER=${POLICY_MARIADB_VER} export POLICY_POSTGRES_VER=11.1 echo POLICY_POSTGRES_VER=${POLICY_POSTGRES_VER} -function getVersion +function getDockerVersion { REPO=$1 - curl -qL --silent \ - https://github.com/onap/policy-"$REPO"/raw/"${GERRIT_BRANCH}"/pom.xml | - xmllint --xpath \ - '/*[local-name()="project"]/*[local-name()="version"]/text()' - | - awk -F \. '{print $1"."$2"-SNAPSHOT-latest"}' + DEFAULT_DOCKER_IMAGE_NAME=$2 + DEFAULT_DOCKER_IMAGE_VERSION=$3 + + REPO_RELEASE_DATA=$( + curl -qL --silent \ + "https://github.com/onap/policy-parent/raw/$GERRIT_BRANCH/integration/src/main/resources/release/pf_release_data.csv" | + grep "^policy/$REPO" + ) + + # shellcheck disable=SC2034 + read -r repo \ + latest_released_tag \ + latest_snapshot_tag \ + changed_files \ + docker_images \ + <<< "$(echo "$REPO_RELEASE_DATA" | tr ',' ' ' )" + + if [[ -z "$docker_images" ]] + then + if [[ -z "$DEFAULT_DOCKER_IMAGE_NAME" ]] + then + echo "repo $REPO does not produce a docker image, execution terminated" + exit 1 + else + docker_images="$DEFAULT_DOCKER_IMAGE_NAME" + fi + fi + + docker_image_version=$(echo "$latest_snapshot_tag" | awk -F \. '{print $1"."$2"-SNAPSHOT-latest"}') + docker_image_name=$(echo "$docker_images" | sed -e "s/^.*://" -e "s/^.//" -e "s/.$//") + + if \ + curl -qL --silent \ + "https://nexus3.onap.org/service/rest/repository/browse/docker.snapshot/v2/onap/$docker_image_name/tags/" | + grep -q "$docker_image_version" + then + echo "using \"$docker_image_name:$docker_image_version\" docker image for repo \"$repo\"" + return + fi + + docker_image_version="$latest_released_tag" + if \ + curl -qL --silent \ + "https://nexus3.onap.org/service/rest/repository/browse/docker.release/v2/onap/$docker_image_name/tags/" | + grep -q "$docker_image_version" + then + echo "using \"$docker_image_name:$docker_image_version\" docker image for repo \"$repo\"" + return + fi + + docker_image_version="$DEFAULT_DOCKER_IMAGE_VERSION" + if \ + curl -qL --silent \ + "https://nexus3.onap.org/service/rest/repository/browse/docker.release/v2/onap/$docker_image_name/tags/" | + grep -q "$docker_image_version" + then + echo "using \"$docker_image_name:$docker_image_version\" docker image for repo \"$repo\"" + return + else + echo "docker image \"$docker_image_name:$docker_image_version\" not found for repo \"$repo\"" + exit 1 + fi } -export POLICY_MODELS_VERSION=$(getVersion models) -echo POLICY_MODELS_VERSION="${POLICY_MODELS_VERSION}" +getDockerVersion docker +export POLICY_DOCKER_VERSION="$docker_image_version" -export POLICY_API_VERSION=$(getVersion api) -echo POLICY_API_VERSION="${POLICY_API_VERSION}" +getDockerVersion models "'policy-models-simulator'" 2.6.4 +export POLICY_MODELS_VERSION="$docker_image_version" -export POLICY_PAP_VERSION=$(getVersion pap) -echo POLICY_PAP_VERSION="${POLICY_PAP_VERSION}" +getDockerVersion api +export POLICY_API_VERSION="$docker_image_version" -export POLICY_XACML_PDP_VERSION=$(getVersion xacml-pdp) -echo POLICY_XACML_PDP_VERSION="${POLICY_XACML_PDP_VERSION}" +getDockerVersion pap +export POLICY_PAP_VERSION="$docker_image_version" -export POLICY_DROOLS_VERSION=$(getVersion drools-pdp) -echo POLICY_DROOLS_VERSION="${POLICY_DROOLS_VERSION}" +getDockerVersion apex-pdp +export POLICY_APEX_PDP_VERSION="$docker_image_version" -export POLICY_DROOLS_APPS_VERSION=$(getVersion drools-applications) -echo POLICY_DROOLS_APPS_VERSION="${POLICY_DROOLS_APPS_VERSION}" +getDockerVersion drools-pdp +export POLICY_DROOLS_PDP_VERSION="$docker_image_version" -export POLICY_APEX_PDP_VERSION=$(getVersion apex-pdp) -echo POLICY_APEX_PDP_VERSION="${POLICY_APEX_PDP_VERSION}" +getDockerVersion xacml-pdp +export POLICY_XACML_PDP_VERSION="$docker_image_version" -export POLICY_DISTRIBUTION_VERSION=$(getVersion distribution) -echo POLICY_DISTRIBUTION_VERSION="${POLICY_DISTRIBUTION_VERSION}" +getDockerVersion distribution +export POLICY_DISTRIBUTION_VERSION="$docker_image_version" -export POLICY_CLAMP_VERSION=$(getVersion clamp) -echo POLICY_CLAMP_VERSION="${POLICY_CLAMP_VERSION}" +getDockerVersion clamp +export POLICY_CLAMP_VERSION="$docker_image_version" -export POLICY_DOCKER_VERSION=$(getVersion docker) -echo POLICY_DOCKER_VERSION="${POLICY_DOCKER_VERSION}" +getDockerVersion gui +export POLICY_GUI_VERSION="$docker_image_version" -export POLICY_GUI_VERSION=$(getVersion gui) -echo POLICY_GUI_VERSION="${POLICY_GUI_VERSION}" +getDockerVersion drools-applications +export POLICY_DROOLS_APPS_VERSION="$docker_image_version" -- cgit 1.2.3-korg