Add automation for s3p tests 99/136199/1
authorsaul.gill <saul.gill@est.tech>
Mon, 16 Oct 2023 16:21:15 +0000 (17:21 +0100)
committersaul.gill <saul.gill@est.tech>
Mon, 16 Oct 2023 16:21:19 +0000 (17:21 +0100)
Issue-ID: POLICY-4844
Change-Id: Ia6003d5b492d2731fdd0d17342b4fd1c213c4b91
Signed-off-by: saul.gill <saul.gill@est.tech>
testsuites/performance/src/main/resources/testplans/performance.jmx
testsuites/performance/src/main/resources/testplans/run_test.sh
testsuites/run-s3p-test.sh [new file with mode: 0644]
testsuites/stability/src/main/resources/setup/config/apiParameters.yaml
testsuites/stability/src/main/resources/setup/config/papParameters.yaml
testsuites/stability/src/main/resources/setup/distribution/bin/policy-dist.sh
testsuites/stability/src/main/resources/setup/docker-compose.yml
testsuites/stability/src/main/resources/setup/start.sh
testsuites/stability/src/main/resources/setup/versions.sh
testsuites/stability/src/main/resources/testplans/run_test.sh
testsuites/stability/src/main/resources/testplans/stability.jmx

index 7abd7e4..02ea601 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.4.1">
+<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.5">
   <hashTree>
     <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="performance test plan" enabled="true">
       <stringProp name="TestPlan.comments"></stringProp>
               <stringProp name="HTTPSampler.port">${PAP_PORT}</stringProp>
               <stringProp name="HTTPSampler.protocol">http</stringProp>
               <stringProp name="HTTPSampler.contentEncoding"></stringProp>
-              <stringProp name="HTTPSampler.path">/policy/pap/v1/policies/status/</stringProp>
+              <stringProp name="HTTPSampler.path">/policy/pap/v1/policies/status</stringProp>
               <stringProp name="HTTPSampler.method">GET</stringProp>
               <boolProp name="HTTPSampler.follow_redirects">true</boolProp>
               <boolProp name="HTTPSampler.auto_redirects">false</boolProp>
           <boolProp name="AuthManager.controlledByThreadGroup">false</boolProp>
         </AuthManager>
         <hashTree/>
-        <GenericController guiclass="LogicControllerGui" testclass="GenericController" testname="HealthCheck/Statistics" enabled="true"/>
+        <GenericController guiclass="LogicControllerGui" testclass="GenericController" testname="HealthCheck" enabled="true"/>
         <hashTree>
           <ConstantTimer guiclass="ConstantTimerGui" testclass="ConstantTimer" testname="Constant Timer" enabled="true">
             <stringProp name="ConstantTimer.delay">1000</stringProp>
             </ResponseAssertion>
             <hashTree/>
           </hashTree>
-          <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Statistics" enabled="true">
-            <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
-              <collectionProp name="Arguments.arguments"/>
-            </elementProp>
-            <stringProp name="HTTPSampler.domain">${DISTRIBUTION_HOST}</stringProp>
-            <stringProp name="HTTPSampler.port">${DISTRIBUTION_PORT}</stringProp>
-            <stringProp name="HTTPSampler.protocol">http</stringProp>
-            <stringProp name="HTTPSampler.contentEncoding"></stringProp>
-            <stringProp name="HTTPSampler.path">statistics</stringProp>
-            <stringProp name="HTTPSampler.method">GET</stringProp>
-            <boolProp name="HTTPSampler.follow_redirects">true</boolProp>
-            <boolProp name="HTTPSampler.auto_redirects">false</boolProp>
-            <boolProp name="HTTPSampler.use_keepalive">true</boolProp>
-            <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
-            <stringProp name="HTTPSampler.embedded_url_re"></stringProp>
-            <stringProp name="HTTPSampler.connect_timeout"></stringProp>
-            <stringProp name="HTTPSampler.response_timeout"></stringProp>
-          </HTTPSamplerProxy>
-          <hashTree>
-            <ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="Response Assertion" enabled="true">
-              <collectionProp name="Asserion.test_strings">
-                <stringProp name="49586">200</stringProp>
-              </collectionProp>
-              <stringProp name="Assertion.custom_message"></stringProp>
-              <stringProp name="Assertion.test_field">Assertion.response_code</stringProp>
-              <boolProp name="Assertion.assume_success">false</boolProp>
-              <intProp name="Assertion.test_type">8</intProp>
-            </ResponseAssertion>
-            <hashTree/>
-          </hashTree>
         </hashTree>
         <GenericController guiclass="LogicControllerGui" testclass="GenericController" testname="Assert Metrics" enabled="true"/>
         <hashTree>
       </hashTree>
     </hashTree>
   </hashTree>
-</jmeterTestPlan>
+</jmeterTestPlan>
\ No newline at end of file
index 1022a8e..5ce3e7c 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/bash
 # ============LICENSE_START=======================================================
-#  Copyright (c) 2021-2022 Nordix Foundation.
+#  Copyright (c) 2021-2023 Nordix Foundation.
 # ================================================================================
 # 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=========================================================
 
+if [ $# -ne 1 ]; then
+    echo "Usage: $0 <duration>"
+    exit 1
+fi
+
+duration="$1"
+
 DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
-JMETER_HOME=~/jmeter/apache-jmeter-5.4.1
+JMETER_HOME=~/jmeter/apache-jmeter-5.5
 
 POLICY_API_IP=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' policy-api)
 POLICY_PAP_IP=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' policy-pap)
 POLICY_DISTRIBUTION_IP=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' policy-distribution)
 
-${JMETER_HOME}/bin/jmeter -n -t "${DIR}"/performance.jmx -Jduration=14400 \
+${JMETER_HOME}/bin/jmeter -n -t "${DIR}"/performance.jmx -Jduration="${duration}" \
     -Japihost="${POLICY_API_IP}" \
     -Jpaphost="${POLICY_PAP_IP}" \
     -Jdisthost="${POLICY_DISTRIBUTION_IP}" -l distribution_performance.jtl &
diff --git a/testsuites/run-s3p-test.sh b/testsuites/run-s3p-test.sh
new file mode 100644 (file)
index 0000000..00f8643
--- /dev/null
@@ -0,0 +1,157 @@
+#!/bin/bash
+# ============LICENSE_START=======================================================
+#  Copyright (c) 2023 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=========================================================
+
+# Check if the correct number of arguments is provided
+if [ $# -ne 2 ]; then
+    echo "Usage: $0 <type> <duration>"
+    exit 1
+fi
+
+type="$1"
+duration="$2"
+
+# Check if the type is valid
+if [ "$type" != "stability" ] && [ "$type" != "performance" ]; then
+    echo "Invalid type. Use 'stability' or 'performance'."
+    exit 1
+fi
+
+sudo apt update
+
+# Check if OpenJDK 17 is installed
+if java --version | grep -q "openjdk 17"; then
+    echo "OpenJDK 17 is already installed."
+else
+    echo "OpenJDK 17 is not installed. Installing..."
+    sudo apt install -y openjdk-17-jdk
+fi
+
+# Check if docker is installed
+if docker --version | grep -q "Docker version"; then
+    echo "docker is already installed."
+else
+    echo "docker is not installed. Installing..."
+    # Add docker repository
+    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
+
+    echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
+    $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
+
+    sudo apt update
+
+    # Install docker
+    sudo apt-get install docker-ce docker-ce-cli containerd.io
+
+    sudo chmod 666 /var/run/docker.sock
+fi
+
+systemctl status --no-pager docker
+
+docker ps
+
+# Check if docker compose is installed
+if docker-compose --version | grep -q "docker-compose version"; then
+    echo "docker compose is already installed."
+else
+    echo "docker compose is not installed. Installing..."
+    # Install compose (check if version is still available or update as necessary)
+    sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
+    sudo chmod +x /usr/local/bin/docker-compose
+fi
+
+# Check if install was successful
+docker-compose --version
+
+bash ./stability/src/main/resources/setup/versions.sh
+
+bash ./stability/src/main/resources/setup/start.sh
+
+# Install required packages
+sudo apt install -y wget unzip
+
+# Install JMeter
+mkdir -p ~/jmeter
+wget https://dlcdn.apache.org//jmeter/binaries/apache-jmeter-5.5.zip # check if valid version
+unzip -q -d ~/jmeter apache-jmeter-5.5.zip
+rm apache-jmeter-5.5.zip
+
+# Check if visualvm is installed
+if visualvm --help | grep -q "Usage:"; then
+    echo "visualvm is already installed."
+else
+    echo "visualvm is not installed. Installing..."
+    # Install compose (check if version is still available or update as necessary)
+    sudo apt install visualvm
+fi
+
+# Set globally accessable permissions on policy file
+sudo chmod 777 /usr/lib/jvm/java-17-openjdk-amd64/bin/visualvm.policy
+
+# Create Java security policy file for VisualVM
+file_path="/usr/lib/jvm/java-17-openjdk-amd64/bin/visualvm.policy"
+
+if [ -e "$file_path" ]; then
+    echo "File exists already."
+else
+    echo "File does not exist. Creating now..."
+    sudo tee "$file_path" > /dev/null <<EOF
+    grant codebase "jrt:/jdk.jstatd" {
+       permission java.security.AllPermission;
+    };
+    grant codebase "jrt:/jdk.internal.jvmstat" {
+       permission java.security.AllPermission;
+    };
+EOF
+    sudo chmod 644 "$file_path"  # Adjust file permissions as needed
+fi
+
+# check if jstatd is running
+process_name="jstatd"
+
+if pgrep "$process_name" > /dev/null; then
+    echo "The process '$process_name' is running."
+else
+    echo "The process '$process_name' is not running. Will run now"
+    /usr/lib/jvm/java-17-openjdk-amd64/bin/jstatd -p 1111 -J-Djava.security.policy=/usr/lib/jvm/java-17-openjdk-amd64/bin/visualvm.policy &
+fi
+
+visualvm &
+
+tmp_path="/tmp/policydistribution/distributionmount"
+
+if [ -e "$tmp_path" ]; then
+    echo "tmp File exists already."
+else
+    echo "tmp does not exist. Creating now..."
+    sudo mkdir -p /tmp/policydistribution/distributionmount
+    sudo chmod -R a+trwx /tmp
+fi
+
+sleep 240
+
+# Run different tests based on the type
+if [ "$type" == "stability" ]; then
+    echo "Running stability test for $duration seconds in directory ${PWD}..."
+    bash ./stability/src/main/resources/testplans/run_test.sh "$duration"
+    echo "Stability test completed."
+elif [ "$type" == "performance" ]; then
+    echo "Running performance test for $duration seconds in directory ${PWD}..."
+    bash ./performance/src/main/resources/testplans/run_test.sh "$duration"
+    echo "Performance test completed."
+fi
\ No newline at end of file
index e61653a..7d486ae 100644 (file)
@@ -2,6 +2,8 @@ server:
   port: 6969
   ssl:
     enabled: false
+  servlet:
+    context-path: /policy/api/v1
 
 spring:
   security.user:
@@ -79,4 +81,6 @@ management:
       base-path: /
       exposure:
         include: health,metrics,prometheus
-      path-mapping.prometheus: metrics
+      path-mapping:
+        -metrics: plain-metrics
+        -prometheus: metrics
\ No newline at end of file
index 8249edd..4020365 100644 (file)
@@ -23,12 +23,18 @@ spring:
 
 server:
   port: 6969
+  servlet:
+    context-path: /policy/pap/v1
   ssl:
     enabled: false
 
 pap:
   name: PapGroup
   aaf: false
+  topic:
+    pdp-pap.name: POLICY-PDP-PAP
+    notification.name: POLICY-NOTIFICATION
+    heartbeat.name: POLICY-HEARTBEAT
   pdpParameters:
     heartBeatMs: 120000
     updateParameters:
@@ -37,41 +43,42 @@ pap:
     stateChangeParameters:
       maxRetryCount: 1
       maxWaitMs: 30000
+  savePdpStatisticsInDb: true
   topicParameterGroup:
     topicSources:
-    - topic: POLICY-PDP-PAP
-      servers:
-      - message-router
-      topicCommInfrastructure: dmaap
-      useHttps: false
-      fetchTimeout: 15000
-    - topic: POLICY-HEARTBEAT
-      effectiveTopic: POLICY-PDP-PAP
-      consumerGroup: policy-pap
-      servers:
-      - message-router
-      topicCommInfrastructure: dmaap
-      useHttps: false
-      fetchTimeout: 15000
+      - topic: POLICY-PDP-PAP
+        servers:
+          - message-router
+        topicCommInfrastructure: dmaap
+        useHttps: false
+        fetchTimeout: 15000
+      - topic: POLICY-HEARTBEAT
+        effectiveTopic: POLICY-PDP-PAP
+        consumerGroup: policy-pap
+        servers:
+          - message-router
+        topicCommInfrastructure: dmaap
+        useHttps: false
+        fetchTimeout: 15000
     topicSinks:
-    - topic: POLICY-PDP-PAP
-      servers:
-      - message-router
-      topicCommInfrastructure: dmaap
-      useHttps: false
-    - topic: POLICY-NOTIFICATION
-      servers:
-      - message-router
-      topicCommInfrastructure: dmaap
-      useHttps: false
+      - topic: POLICY-PDP-PAP
+        servers:
+          - message-router
+        topicCommInfrastructure: dmaap
+        useHttps: false
+      - topic: POLICY-NOTIFICATION
+        servers:
+          - message-router
+        topicCommInfrastructure: dmaap
+        useHttps: false
   healthCheckRestClientParameters:
-  - clientName: api
-    hostname: policy-api
-    port: 6969
-    userName: policyadmin
-    password: zb!XztG34
-    useHttps: false
-    basePath: policy/api/v1/healthcheck
+    - clientName: api
+      hostname: policy-api
+      port: 6969
+      userName: policyadmin
+      password: zb!XztG34
+      useHttps: false
+      basePath: policy/api/v1/healthcheck
 
 management:
   endpoints:
@@ -79,4 +86,6 @@ management:
       base-path: /
       exposure:
         include: health, metrics, prometheus
-      path-mapping.prometheus: metrics
+      path-mapping:
+        -metrics: plain-metrics
+        -prometheus: metrics
\ No newline at end of file
index 2d781ea..13924ce 100755 (executable)
@@ -20,7 +20,7 @@
 # ============LICENSE_END=========================================================
 #
 
-JAVA_HOME=/usr/lib/jvm/java-11-openjdk/
+JAVA_HOME=/usr/lib/jvm/java-17-openjdk/
 KEYSTORE="${POLICY_HOME}/etc/ssl/policy-keystore"
 KEYSTORE_PASSWD="Pol1cy_0nap"
 TRUSTSTORE="${POLICY_HOME}/etc/ssl/policy-truststore"
index 48d1851..2fd77d7 100644 (file)
@@ -1,5 +1,5 @@
 # ============LICENSE_START=======================================================
-# Copyright (C) 2021-2022 Nordix Foundation.
+# Copyright (C) 2021-2023 Nordix Foundation.
 # ================================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -45,9 +45,9 @@ services:
       - ./config/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/bin/db_migrator_policy_init.sh',
-        'mariadb', '3306'
+      '-c',
+      '/opt/app/policy/bin/db_migrator_policy_init.sh',
+      'mariadb', '3306'
     ]
   simulator:
     image: nexus3.onap.org:10001/onap/policy-models-simulator:${POLICY_MODELS_SIMULATOR}
@@ -83,9 +83,9 @@ services:
       - ./config/wait_for_port.sh:/opt/app/policy/api/bin/wait_for_port.sh:ro
     entrypoint: /opt/app/policy/api/bin/wait_for_port.sh
     command: [
-        '-c', './policy-api.sh',
-        'mariadb', '3306',
-        'policy-db-migrator', '6824'
+      '-c', './policy-api.sh',
+      'mariadb', '3306',
+      'policy-db-migrator', '6824'
     ]
   policy-pap:
     image: nexus3.onap.org:10001/onap/policy-pap:${POLICY_PAP_VERSION}
@@ -103,10 +103,10 @@ services:
       - ./config/jsonConfigs/papGroups.json:/opt/app/policy/pap/etc/mounted/groups.json:ro
     entrypoint: /opt/app/policy/pap/bin/wait_for_port.sh
     command: [
-        '-c', './policy-pap.sh',
-        'mariadb', '3306',
-        'message-router', '3904',
-        'policy-api', '6969'
+      '-c', './policy-pap.sh',
+      'mariadb', '3306',
+      'message-router', '3904',
+      'policy-api', '6969'
     ]
   policy-dist:
     image: nexus3.onap.org:10001/onap/policy-distribution:${POLICY_DIST_VERSION}
@@ -119,12 +119,14 @@ services:
     expose:
       - 6969
       - 9090
+    ports:
+      - 9090:9090
     container_name: policy-distribution
     entrypoint: /opt/app/policy/bin/wait_for_port.sh
     command: [
-        '-c', './policy-dist.sh',
-        'mariadb', '3306',
-        'message-router', '3904',
-        'policy-api', '6969',
-        'policy-pap', '6969'
+      '-c', './policy-dist.sh',
+      'mariadb', '3306',
+      'message-router', '3904',
+      'policy-api', '6969',
+      'policy-pap', '6969'
     ]
index 765c5b6..e227eaf 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/bash
 # ============LICENSE_START=======================================================
-#  Copyright (c) 2021-2022 Nordix Foundation.
+#  Copyright (c) 2021-2023 Nordix Foundation.
 # ================================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
 # ============LICENSE_END=========================================================
 
 # load up all the image version
-source "$(pwd)"/versions.sh
+source "$(pwd)"/stability/src/main/resources/setup/versions.sh
 
 DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
 WORK_DIR=$(mktemp -d -p "$DIR")
@@ -33,7 +33,7 @@ if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then
 fi
 
 # bring down maven
-curl -s -S https://dlcdn.apache.org/maven/maven-3/3.8.5/binaries/apache-maven-3.8.5-bin.tar.gz > apache-maven.tar.gz
+curl -s -S https://dlcdn.apache.org/maven/maven-3/3.9.5/binaries/apache-maven-3.9.5-bin.tar.gz > apache-maven.tar.gz
 mkdir -p apache-maven && tar -xzvf apache-maven.tar.gz -C apache-maven --strip-components 1
 
 MAVEN="${WORK_DIR}"/apache-maven/bin/mvn
@@ -42,10 +42,14 @@ echo ""
 
 # clone oparent for maven settings and models for building pdp/simulator
 git clone http://gerrit.onap.org/r/oparent
-git clone --depth 1 https://gerrit.onap.org/r/policy/models -b master
 
+docker pull nexus3.onap.org:10001/onap/policy-jre-alpine:${POLICY_DB_MIGRATOR}
+docker tag nexus3.onap.org:10001/onap/policy-jre-alpine:${POLICY_DB_MIGRATOR} onap/policy-jre-alpine:${POLICY_DB_MIGRATOR}
+
+git clone --depth 1 https://gerrit.onap.org/r/policy/models -b master
 cd models/models-sim/policy-models-sim-pdp || exit
 $MAVEN clean install -DskipTests --settings "${WORK_DIR}"/oparent/settings.xml
+
 bash ./src/main/package/docker/docker_build.sh
 
 cd "$DIR" || exit
index 1ac71df..f19f839 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/bash
 # ============LICENSE_START=======================================================
-#  Copyright (c) 2021 Nordix Foundation.
+#  Copyright (c) 2021-2023 Nordix Foundation.
 # ================================================================================
 # 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=========================================================
 
-# update versions here
-export POLICY_MARIADB_VER=10.5.8
-export POLICY_DB_MIGRATOR=2.4-SNAPSHOT-latest
-export POLICY_API_VERSION=2.6-SNAPSHOT-latest
-export POLICY_PAP_VERSION=2.6-SNAPSHOT-latest
-export POLICY_MODELS_SIMULATOR=2.6-SNAPSHOT-latest
-export POLICY_DIST_VERSION=2.7-SNAPSHOT-latest
+if [ -z "${WORKSPACE}" ]; then
+    WORKSPACE=$(git rev-parse --show-toplevel)
+    export WORKSPACE
+fi
+
+GERRIT_BRANCH=$(awk -F= '$1 == "defaultbranch" { print $2 }' \
+                    "${WORKSPACE}"/.gitreview)
+
+echo GERRIT_BRANCH="${GERRIT_BRANCH}"
+
+export POLICY_MARIADB_VER=10.10.2
+echo POLICY_MARIADB_VER=${POLICY_MARIADB_VER}
+
+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_version=$latest_snapshot_tag
+    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_DB_MIGRATOR="$docker_image_version"
+
+getDockerVersion models "'policy-models-simulator'" 3.0.1
+export POLICY_MODELS_SIMULATOR="$docker_image_version"
+
+getDockerVersion api
+export POLICY_API_VERSION="$docker_image_version"
+
+getDockerVersion pap
+export POLICY_PAP_VERSION="$docker_image_version"
+
+getDockerVersion distribution
+export POLICY_DIST_VERSION="$docker_image_version"
 
 echo "                MariaDB Version: ${POLICY_MARIADB_VER}"
 echo "     Policy DB Migrator Version: ${POLICY_DB_MIGRATOR}"
@@ -31,4 +122,4 @@ echo "             Policy API Version: ${POLICY_API_VERSION}"
 echo "             Policy PAP Version: ${POLICY_PAP_VERSION}"
 echo "Policy Models Simulator Version: ${POLICY_MODELS_SIMULATOR}"
 echo "    Policy Distribution Version: ${POLICY_DIST_VERSION}"
-echo ""
+echo ""
\ No newline at end of file
index edef48b..195f78a 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/bash
 # ============LICENSE_START=======================================================
-#  Copyright (c) 2021-2022 Nordix Foundation.
+#  Copyright (c) 2021-2023 Nordix Foundation.
 # ================================================================================
 # 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=========================================================
 
+if [ $# -ne 1 ]; then
+    echo "Usage: $0 <duration>"
+    exit 1
+fi
+
+duration="$1"
+
 echo "Starting stability test against distribution component..."
 
 DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
-JMETER_HOME=~/jmeter/apache-jmeter-5.4.1
+JMETER_HOME=~/jmeter/apache-jmeter-5.5
 
 POLICY_API_IP=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' policy-api)
 POLICY_PAP_IP=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' policy-pap)
 POLICY_DISTRIBUTION_IP=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' policy-distribution)
 
-${JMETER_HOME}/bin/jmeter -n -t "${DIR}"/stability.jmx -Jduration=259200 \
+${JMETER_HOME}/bin/jmeter -n -t "${DIR}"/stability.jmx -Jduration="${duration}" \
     -Japihost="${POLICY_API_IP}" \
     -Jpaphost="${POLICY_PAP_IP}" \
     -Jdisthost="${POLICY_DISTRIBUTION_IP}" -l distribution_stability.jtl &
index 75810c0..9ac5170 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.4.1">
+<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.5" xmlns="http://jakarta.apache.org/jmeter" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jakarta.apache.org/jmeter jmeter.xsd">
   <hashTree>
     <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="stability test plan" enabled="true">
       <stringProp name="TestPlan.comments"></stringProp>
             <hashTree/>
           </hashTree>
         </hashTree>
-        <GenericController guiclass="LogicControllerGui" testclass="GenericController" testname="HealthCheck/Statistics" enabled="true"/>
+        <GenericController guiclass="LogicControllerGui" testclass="GenericController" testname="HealthCheck" enabled="true"/>
         <hashTree>
           <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Healthcheck" enabled="true">
             <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
             </ResponseAssertion>
             <hashTree/>
           </hashTree>
-          <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Statistics" enabled="true">
-            <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
-              <collectionProp name="Arguments.arguments"/>
-            </elementProp>
-            <stringProp name="HTTPSampler.domain">${DISTRIBUTION_HOST}</stringProp>
-            <stringProp name="HTTPSampler.port">${DISTRIBUTION_PORT}</stringProp>
-            <stringProp name="HTTPSampler.protocol">http</stringProp>
-            <stringProp name="HTTPSampler.contentEncoding"></stringProp>
-            <stringProp name="HTTPSampler.path">statistics</stringProp>
-            <stringProp name="HTTPSampler.method">GET</stringProp>
-            <boolProp name="HTTPSampler.follow_redirects">true</boolProp>
-            <boolProp name="HTTPSampler.auto_redirects">false</boolProp>
-            <boolProp name="HTTPSampler.use_keepalive">true</boolProp>
-            <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
-            <stringProp name="HTTPSampler.embedded_url_re"></stringProp>
-            <stringProp name="HTTPSampler.connect_timeout"></stringProp>
-            <stringProp name="HTTPSampler.response_timeout"></stringProp>
-          </HTTPSamplerProxy>
-          <hashTree>
-            <ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="Response Assertion" enabled="true">
-              <collectionProp name="Asserion.test_strings">
-                <stringProp name="49586">200</stringProp>
-              </collectionProp>
-              <stringProp name="Assertion.custom_message"></stringProp>
-              <stringProp name="Assertion.test_field">Assertion.response_code</stringProp>
-              <boolProp name="Assertion.assume_success">false</boolProp>
-              <intProp name="Assertion.test_type">8</intProp>
-            </ResponseAssertion>
-            <hashTree/>
-          </hashTree>
         </hashTree>
         <GenericController guiclass="LogicControllerGui" testclass="GenericController" testname="Metrics" enabled="true"/>
         <hashTree>
             <stringProp name="HTTPSampler.port">${PAP_PORT}</stringProp>
             <stringProp name="HTTPSampler.protocol">http</stringProp>
             <stringProp name="HTTPSampler.contentEncoding"></stringProp>
-            <stringProp name="HTTPSampler.path">/policy/pap/v1/policies/status/</stringProp>
+            <stringProp name="HTTPSampler.path">/policy/pap/v1/policies/status</stringProp>
             <stringProp name="HTTPSampler.method">GET</stringProp>
             <boolProp name="HTTPSampler.follow_redirects">true</boolProp>
             <boolProp name="HTTPSampler.auto_redirects">false</boolProp>
           </HTTPSamplerProxy>
           <hashTree>
             <ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="Response Assertion" enabled="true">
-              <collectionProp name="Asserion.test_strings">
-                <stringProp name="2914">[]</stringProp>
-              </collectionProp>
-              <stringProp name="Assertion.custom_message"></stringProp>
               <stringProp name="Assertion.test_field">Assertion.response_data</stringProp>
               <boolProp name="Assertion.assume_success">false</boolProp>
-              <intProp name="Assertion.test_type">2</intProp>
+              <intProp name="Assertion.test_type">2</intProp> <!-- "Equals" test type -->
+              <stringProp name="Assertion.test_string">[]</stringProp> <!-- Expected response content -->
             </ResponseAssertion>
             <hashTree/>
           </hashTree>
       </hashTree>
     </hashTree>
   </hashTree>
-</jmeterTestPlan>
+</jmeterTestPlan>
\ No newline at end of file