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.
CLAMP TOSCA Control Loop was not in Honolulu and the CLAMP CSITs ran
separately in the CLAMP repo. We ported the CSITs over to the
policy/docker repo in Istanbul. Therefore, we need to disable the CLAMP
CSITs in policy/docker in honolulu
Issue-ID: POLICY-4233
Change-Id: I83f0a6816942d5bfaef7c22fc69625f40ae74d23
Signed-off-by: liamfallon <liam.fallon@est.tech>
 POLICY_PAP_IP=`get-instance-ip.sh policy-pap`
 MARIADB_IP=`get-instance-ip.sh mariadb`
 APEX_IP=`get-instance-ip.sh policy-apex-pdp`
-DMAAP_IP=`get-instance-ip.sh policy.api.simpledemo.onap.org`
+DMAAP_IP=`get-instance-ip.sh simulator`
 
 echo PAP IP IS ${POLICY_PAP_IP}
 echo MARIADB IP IS ${MARIADB_IP}
 
--- /dev/null
+#!/bin/bash
+# ============LICENSE_START=======================================================
+#  Copyright (C) 2022 Nordix Foundation.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
 
--- /dev/null
+#!/bin/bash
+# ============LICENSE_START=======================================================
+#  Copyright (C) 2022 Nordix Foundation.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
 
--- /dev/null
+# Test suites are relative paths under [policy/docker.git]/csit/[project]/tests.
+# Place the suites in run order.
+policy-clamp-test.robot
 
--- /dev/null
+*** Test Cases ***
+iDummy CLAMP Honolulu Robot Test
+    Log To Console            CLAMP Robot tests are in the policy/clamp repo in Honolulu
 
     "topicParameterGroup": {
         "topicSources" : [{
             "topic" : "POLICY-PDP-PAP",
-            "servers" : [ "policy.api.simpledemo.onap.org" ],
+            "servers" : [ "simulator" ],
             "topicCommInfrastructure" : "dmaap",
             "useHttps" : true,
             "allowSelfSignedCerts" : true
         }],
         "topicSinks" : [{
             "topic" : "POLICY-PDP-PAP",
-            "servers" : [ "policy.api.simpledemo.onap.org" ],
+            "servers" : [ "simulator" ],
             "topicCommInfrastructure" : "dmaap",
             "useHttps" : true,
             "allowSelfSignedCerts" : true
 
 # DCAE DMaaP
 
 DCAE_TOPIC=unauthenticated.DCAE_CL_OUTPUT
-DCAE_SERVERS=policy.api.simpledemo.onap.org
+DCAE_SERVERS=simulator
 DCAE_CONSUMER_GROUP=dcae.policy.shared
 
 # Open DMaaP
 
-DMAAP_SERVERS=policy.api.simpledemo.onap.org
+DMAAP_SERVERS=simulator
 
 # AAI
 
-AAI_HOST=policy.api.simpledemo.onap.org
+AAI_HOST=simulator
 AAI_PORT=6666
 AAI_CONTEXT_URI=
 AAI_USERNAME=policy@policy.onap.org
 
 # MSO
 
-SO_HOST=policy.api.simpledemo.onap.org
+SO_HOST=simulator
 SO_PORT=6669
 SO_CONTEXT_URI=
-SO_URL=https://policy.api.simpledemo.onap.org:6669/
+SO_URL=https://simulator:6669/
 SO_USERNAME=InfraPortalClient
 SO_PASSWORD=password1$
 
 # VFC
 
-VFC_HOST=policy.api.simpledemo.onap.org
+VFC_HOST=simulator
 VFC_PORT=6670
 VFC_CONTEXT_URI=
 VFC_USERNAME=
 
 # SDNC
 
-SDNC_HOST=policy.api.simpledemo.onap.org
+SDNC_HOST=simulator
 SDNC_PORT=6668
 SDNC_CONTEXT_URI=
 SDNC_USERNAME=
 
     "topicParameterGroup": {
         "topicSources" : [{
             "topic" : "POLICY-PDP-PAP",
-            "servers" : [ "policy.api.simpledemo.onap.org" ],
+            "servers" : [ "simulator" ],
             "topicCommInfrastructure" : "dmaap",
             "useHttps": true,
             "allowSelfSignedCerts" : true
         }],
         "topicSinks" : [{
             "topic" : "POLICY-PDP-PAP",
-            "servers" : [ "policy.api.simpledemo.onap.org" ],
+            "servers" : [ "simulator" ],
             "topicCommInfrastructure" : "dmaap",
             "useHttps": true,
             "allowSelfSignedCerts" : true
         },
         {
             "topic" : "POLICY-NOTIFICATION",
-            "servers" : [ "policy.api.simpledemo.onap.org" ],
+            "servers" : [ "simulator" ],
             "topicCommInfrastructure" : "dmaap",
             "useHttps": true,
             "allowSelfSignedCerts" : true
 
     "topicParameterGroup": {
         "topicSources" : [{
             "topic" : "POLICY-PDP-PAP",
-            "servers" : [ "policy.api.simpledemo.onap.org" ],
+            "servers" : [ "simulator" ],
             "topicCommInfrastructure" : "dmaap",
             "useHttps" : true,
             "allowSelfSignedCerts" : true
         }],
         "topicSinks" : [{
             "topic" : "POLICY-PDP-PAP",
-            "servers" : [ "policy.api.simpledemo.onap.org" ],
+            "servers" : [ "simulator" ],
             "topicCommInfrastructure" : "dmaap",
             "useHttps" : true,
             "allowSelfSignedCerts" : true
 
+#! /bin/bash
+
 # ============LICENSE_START====================================================
 #  Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+#  Modification Copyright 2021-2022 Nordix Foundation.
+#  Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
 # =============================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # SPDX-License-Identifier: Apache-2.0
 # ============LICENSE_END======================================================
 
-source ${SCRIPTS}/get-branch-mariadb.sh
 
+if [[ -z "$GERRIT_BRANCH" ]]
+then
+    source "${SCRIPTS}"/get-branch.sh
+else
+    echo GERRIT_BRANCH="${GERRIT_BRANCH}"
+fi
+
+export POLICY_MARIADB_VER=10.5.8
 echo POLICY_MARIADB_VER=${POLICY_MARIADB_VER}
 
-POLICY_MODELS_VERSION=$(
-    curl -q --silent \
-      https://git.onap.org/policy/models/plain/pom.xml?h=${GERRIT_BRANCH} |
-    xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' -)
-export POLICY_MODELS_VERSION=${POLICY_MODELS_VERSION:0:3}-SNAPSHOT-latest
-echo POLICY_MODELS_VERSION=${POLICY_MODELS_VERSION}
-
-POLICY_API_VERSION=$(
-    curl -q --silent \
-      https://git.onap.org/policy/api/plain/pom.xml?h=${GERRIT_BRANCH} |
-    xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' -)
-export POLICY_API_VERSION=${POLICY_API_VERSION:0:3}-SNAPSHOT-latest
-echo POLICY_API_VERSION=${POLICY_API_VERSION}
-
-POLICY_PAP_VERSION=$(
-    curl -q --silent \
-      https://git.onap.org/policy/pap/plain/pom.xml?h=${GERRIT_BRANCH} |
-    xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' -)
-export POLICY_PAP_VERSION=${POLICY_PAP_VERSION:0:3}-SNAPSHOT-latest
-echo POLICY_PAP_VERSION=${POLICY_PAP_VERSION}
-
-POLICY_XACML_PDP_VERSION=$(
-    curl -q --silent \
-      https://git.onap.org/policy/xacml-pdp/plain/pom.xml?h=${GERRIT_BRANCH} |
-    xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' -)
-export POLICY_XACML_PDP_VERSION=${POLICY_XACML_PDP_VERSION:0:3}-SNAPSHOT-latest
-echo POLICY_XACML_PDP_VERSION=${POLICY_XACML_PDP_VERSION}
-
-POLICY_DROOLS_VERSION=$(
-    curl -q --silent \
-      https://git.onap.org/policy/drools-pdp/plain/pom.xml?h=${GERRIT_BRANCH} |
-    xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' -)
-export POLICY_DROOLS_VERSION=${POLICY_DROOLS_VERSION:0:3}-SNAPSHOT-latest
-echo POLICY_DROOLS_VERSION=${POLICY_DROOLS_VERSION}
-
-POLICY_DROOLS_APPS_VERSION=$(
-    curl -q --silent \
-      https://git.onap.org/policy/drools-applications/plain/pom.xml?h=${GERRIT_BRANCH} |
-    xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' -)
-export POLICY_DROOLS_APPS_VERSION=${POLICY_DROOLS_APPS_VERSION:0:3}-SNAPSHOT-latest
-echo POLICY_DROOLS_APPS_VERSION=${POLICY_DROOLS_APPS_VERSION}
-
-POLICY_APEX_PDP_VERSION=$(
-    curl -q --silent \
-      https://git.onap.org/policy/apex-pdp/plain/pom.xml?h=${GERRIT_BRANCH} |
-    xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' -)
-export POLICY_APEX_PDP_VERSION=${POLICY_APEX_PDP_VERSION:0:3}-SNAPSHOT-latest
-echo POLICY_APEX_PDP_VERSION=${POLICY_APEX_PDP_VERSION}
-
-POLICY_DISTRIBUTION_VERSION=$(
-    curl -q --silent \
-      https://git.onap.org/policy/distribution/plain/pom.xml?h=${GERRIT_BRANCH} |
-    xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' -)
-export POLICY_DISTRIBUTION_VERSION=${POLICY_DISTRIBUTION_VERSION:0:3}-SNAPSHOT-latest
-echo POLICY_DISTRIBUTION_VERSION=${POLICY_DISTRIBUTION_VERSION}
+export POLICY_POSTGRES_VER=11.1
+echo POLICY_POSTGRES_VER=${POLICY_POSTGRES_VER}
+
+function getDockerVersion
+{
+    REPO=$1
+    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
+}
+
+getDockerVersion docker
+export POLICY_DOCKER_VERSION="$docker_image_version"
+
+getDockerVersion models "'policy-models-simulator'" 2.6.4
+export POLICY_MODELS_VERSION="$docker_image_version"
+
+getDockerVersion api
+export POLICY_API_VERSION="$docker_image_version"
+
+getDockerVersion pap
+export POLICY_PAP_VERSION="$docker_image_version"
+
+getDockerVersion apex-pdp
+export POLICY_APEX_PDP_VERSION="$docker_image_version"
+
+getDockerVersion drools-pdp
+export POLICY_DROOLS_PDP_VERSION="$docker_image_version"
+
+getDockerVersion xacml-pdp
+export POLICY_XACML_PDP_VERSION="$docker_image_version"
+
+getDockerVersion distribution
+export POLICY_DISTRIBUTION_VERSION="$docker_image_version"
+
+getDockerVersion clamp
+export POLICY_CLAMP_VERSION="$docker_image_version"
+
+getDockerVersion drools-applications
+export POLICY_DROOLS_APPS_VERSION="$docker_image_version"
 
 POLICY_PAP_IP=`get-instance-ip.sh policy-pap`
 MARIADB_IP=`get-instance-ip.sh mariadb`
 APEX_IP=`get-instance-ip.sh policy-apex-pdp`
-DMAAP_IP=`get-instance-ip.sh policy.api.simpledemo.onap.org`
+DMAAP_IP=`get-instance-ip.sh simulator`
 POLICY_DISTRIBUTION_IP=`get-instance-ip.sh policy-distribution`
 
 echo PAP IP IS ${POLICY_PAP_IP}
 
          - ./config/db:/docker-entrypoint-initdb.d:ro
       expose:
        - 3306
-   policy.api.simpledemo.onap.org:
+   simulator:
       image: nexus3.onap.org:10001/onap/policy-models-simulator:${POLICY_MODELS_VERSION}
-      container_name: policy.api.simpledemo.onap.org
-      hostname: policy.api.simpledemo.onap.org
+      container_name: simulator
+      hostname: simulator
       volumes:
        - ./config/sim-all:/opt/app/policy/simulators/etc/mounted:ro
+       - ./config/ks.jks:/opt/app/policy/simulators/etc/ssl/policy-keystore:ro
+       - ./config/policy-truststore:/opt/app/policy/simulators/etc/ssl/policy-truststore:ro
       expose:
        - 6666
        - 6668
        - 6969
       volumes:
        - ./wait_for_port.sh:/opt/app/policy/api/bin/wait_for_port.sh:ro
+       - ./config/ks.jks:/opt/app/policy/api/etc/ssl/policy-keystore:ro
+       - ./config/policy-truststore:/opt/app/policy/api/etc/ssl/policy-truststore:ro
       entrypoint: ./wait_for_port.sh
       command: [
         '-c', './policy-api.sh',
       container_name: policy-pap
       depends_on:
        - mariadb
-       - policy.api.simpledemo.onap.org
+       - simulator
        - api
       hostname: policy-pap
       expose:
       volumes:
        - ./config/pap/defaultConfig.json:/opt/app/policy/pap/etc/defaultConfig.json:ro
        - ./wait_for_port.sh:/opt/app/policy/pap/bin/wait_for_port.sh:ro
+       - ./config/ks.jks:/opt/app/policy/pap/etc/ssl/policy-keystore:ro
+       - ./config/policy-truststore:/opt/app/policy/pap/etc/ssl/policy-truststore:ro
       entrypoint: ./wait_for_port.sh
       command: [
         '-c', './policy-pap.sh',
         'mariadb', '3306',
-        'policy.api.simpledemo.onap.org', '3905',
+        'simulator', '3905',
         'api', '6969'
         ]
    xacml-pdp:
       container_name: policy-xacml-pdp
       depends_on:
        - mariadb
-       - policy.api.simpledemo.onap.org
+       - simulator
        - pap
       hostname: policy-xacml-pdp
       expose:
       volumes:
        - ./config/xacml-pdp/defaultConfig.json:/opt/app/policy/pdpx/etc/defaultConfig.json:ro
        - ./wait_for_port.sh:/opt/app/policy/pdpx/bin/wait_for_port.sh:ro
+       - ./config/ks.jks:/opt/app/policy/pdpx/etc/ssl/policy-keystore:ro
+       - ./config/policy-truststore:/opt/app/policy/pdpx/etc/ssl/policy-truststore:ro
       entrypoint: ./wait_for_port.sh
       command: [
         '-c', './policy-pdpx.sh',
         'mariadb', '3306',
-        'policy.api.simpledemo.onap.org', '3905',
+        'simulator', '3905',
         '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
-       - policy.api.simpledemo.onap.org
+       - simulator
        - pap
       hostname: drools
       expose:
       command: [
         '-c', '/opt/app/policy/bin/pdpd-entrypoint.sh boot',
         'mariadb', '3306',
-        'policy.api.simpledemo.onap.org', '3905'
+        'simulator', '3905'
         ]
    drools-apps:
       image: nexus3.onap.org:10001/onap/policy-pdpd-cl:${POLICY_DROOLS_APPS_VERSION}
       container_name: drools-apps
       depends_on:
        - mariadb
-       - policy.api.simpledemo.onap.org
+       - simulator
        - pap
        - xacml-pdp
       hostname: drools-apps
       command: [
         '-c', '/opt/app/policy/bin/pdpd-cl-entrypoint.sh boot',
         'mariadb', '3306',
-        'policy.api.simpledemo.onap.org', '3905',
+        'simulator', '3905',
         'pap', '6969',
-        'policy.api.simpledemo.onap.org', '6666',
-        'policy.api.simpledemo.onap.org', '6668',
-        'policy.api.simpledemo.onap.org', '6669',
-        'policy.api.simpledemo.onap.org', '6670'
+        'simulator', '6666',
+        'simulator', '6668',
+        'simulator', '6669',
+        'simulator', '6670'
         ]
    apex-pdp:
       image: nexus3.onap.org:10001/onap/policy-apex-pdp:${POLICY_APEX_PDP_VERSION}
       container_name: policy-apex-pdp
       depends_on:
        - mariadb
-       - policy.api.simpledemo.onap.org
+       - simulator
        - pap
       hostname: policy-apex-pdp
       expose:
        - 23324
       volumes:
        - ./config/apex-pdp/OnapPfConfig.json:/opt/app/policy/apex-pdp/etc/onappf/config/OnapPfConfig.json:ro
+       - ./config/ks.jks:/opt/app/policy/apex-pdp/etc/ssl/policy-keystore:ro
+       - ./config/policy-truststore:/opt/app/policy/apex-pdp/etc/ssl/policy-truststore:ro
        - ./wait_for_port.sh:/opt/app/policy/bin/wait_for_port.sh:ro
       entrypoint: /opt/app/policy/bin/wait_for_port.sh
       command: [
         '-c', '/opt/app/policy/apex-pdp/bin/apexOnapPf.sh -c /opt/app/policy/apex-pdp/etc/onappf/config/OnapPfConfig.json',
         'mariadb', '3306',
-        'policy.api.simpledemo.onap.org', '3905',
+        'simulator', '3905',
         'pap', '6969'
         ]
    distribution:
       hostname: policy-distribution
       volumes:
        - ./config/distribution/defaultConfig.json:/opt/app/policy/distribution/etc/defaultConfig.json:ro
+       - ./config/ks.jks:/opt/app/policy/distribution/etc/ssl/policy-keystore:ro
+       - ./config/policy-truststore:/opt/app/policy/distribution/etc/ssl/policy-truststore:ro
        - ./distribution/config/temp/:/opt/app/policy/distribution/etc/temp/:ro
        - ./wait_for_port.sh:/opt/app/policy/bin/wait_for_port.sh:ro
       entrypoint: /opt/app/policy/bin/wait_for_port.sh
       command: [
         '-c', './policy-dist.sh',
         'mariadb', '3306',
-        'policy.api.simpledemo.onap.org', '3905',
+        'simulator', '3905',
         'pap', '6969',
         'apex-pdp', '6969'
         ]
 
 API_IP=`get-instance-ip.sh policy-api`
 PAP_IP=`get-instance-ip.sh policy-pap`
 XACML_IP=`get-instance-ip.sh policy-xacml-pdp`
-SIM_IP=`get-instance-ip.sh policy.api.simpledemo.onap.org`
+SIM_IP=`get-instance-ip.sh simulator`
 export SIM_IP
 
 echo DROOLS IP IS ${DROOLS_IP}
 
 # SPDX-License-Identifier: Apache-2.0
 # ============LICENSE_END======================================================
 
-tmout=120
+tmout=300
 cmd=
 while getopts c:t: opt; do
     case "$opt" in
 
 POLICY_API_IP=`get-instance-ip.sh policy-api`
 MARIADB_IP=`get-instance-ip.sh mariadb`
 POLICY_PDPX_IP=`get-instance-ip.sh policy-xacml-pdp`
-SIM_IP=`get-instance-ip.sh policy.api.simpledemo.onap.org`
+SIM_IP=`get-instance-ip.sh simulator`
 POLICY_PAP_IP=`get-instance-ip.sh policy-pap`
 
 echo PDP IP IS ${POLICY_PDPX_IP}