summaryrefslogtreecommitdiffstats
path: root/test-tools
diff options
context:
space:
mode:
authordanielhanrahan <daniel.hanrahan@est.tech>2023-11-29 18:51:16 +0000
committerDaniel Hanrahan <daniel.hanrahan@est.tech>2024-02-26 10:38:57 +0000
commit5543875f9f3a6a772a09c17f7f0b1a3939c78292 (patch)
tree6e0eb14a73a867cc0251dca671fa5b94f7e796d3 /test-tools
parenta167ab14ed2fdaeded5e1a7a9a22614353f47269 (diff)
Add passthrough read operation (synchronous) to DMI stub
- Implement DMI stub endpoint needed for for NCMP passthrough data operation, returning a fixed JSON response and adding delay. POST /dmi/v1/ch/{cmHandleId}/data/ds/{datastoreName} - Add script to measure average overhead for many requests Test results indicate the NCMP adds up to 150ms per request. Issue-ID: CPS-2099 Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech> Change-Id: I2aba8285f8a52f3570fc1699a8687caffa9d9c77
Diffstat (limited to 'test-tools')
-rwxr-xr-xtest-tools/perf-test-ncmp-passthrough-read.sh90
1 files changed, 90 insertions, 0 deletions
diff --git a/test-tools/perf-test-ncmp-passthrough-read.sh b/test-tools/perf-test-ncmp-passthrough-read.sh
new file mode 100755
index 0000000000..21b031ce95
--- /dev/null
+++ b/test-tools/perf-test-ncmp-passthrough-read.sh
@@ -0,0 +1,90 @@
+#!/bin/bash
+#
+# Copyright 2024 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.
+#
+
+# This script measures the performance of NCMP data passthrough operations:
+# NCMP endpoint tested: /ncmp/v1/ch/{cmHandleId}/data/ds/{datastoreName}
+
+set -o errexit # Exit on most errors
+set -o nounset # Disallow expansion of unset variables
+set -o pipefail # Use last non-zero exit code in a pipeline
+#set -o xtrace # Uncomment for debugging
+
+############################
+# Configuration parameters #
+############################
+CPS_HOST=localhost
+CPS_PORT=8883
+CPS_USERNAME=cpsuser
+CPS_PASSWORD=cpsr0cks!
+PARALLEL_REQUESTS=12
+WARMUP_REQUESTS=600
+MEASUREMENT_REQUESTS=240
+
+SCRIPT_DIR=$(dirname -- "${BASH_SOURCE[0]}")
+# Read DMI delay from docker-compose.yml
+DMI_DATA_DELAY=$(grep 'DATA_FOR_CM_HANDLE_DELAY_MS:' "$SCRIPT_DIR"/../docker-compose/docker-compose.yml | grep -oE '[0-9]+')
+
+function cmHandleExists() {
+ local cmHandleId=$1
+ curl --silent --fail --output /dev/null --user "$CPS_USERNAME:$CPS_PASSWORD" --basic "http://$CPS_HOST:$CPS_PORT/ncmp/v1/ch/$cmHandleId"
+}
+
+function failIfCmHandlesNotFound() {
+ # Just check to see if last needed CM-handle exists
+ local MAX_NEEDED_CM_HANDLES=$((WARMUP_REQUESTS > MEASUREMENT_REQUESTS ? WARMUP_REQUESTS : MEASUREMENT_REQUESTS))
+ local cmHandleId="ch-$MAX_NEEDED_CM_HANDLES"
+ if ! cmHandleExists "$cmHandleId"; then
+ echo "ERROR: CM-handles not registered ($cmHandleId not found)" >&2
+ echo "Note: this test assumes CM-handles have IDs ch-1, ch-2... ch-$MAX_NEEDED_CM_HANDLES" >&2
+ exit 1
+ fi
+}
+
+function warnIfLessThan20kCmHandlesFound() {
+ local cmHandleId='ch-20000'
+ if ! cmHandleExists "$cmHandleId"; then
+ echo "WARNING: testing with less than 20,000 CM-handles is not recommended ($cmHandleId not found)" >&2
+ fi
+}
+
+function measureAverageResponseTimeInMillis() {
+ local totalRequests=$1
+ curl --show-error --fail --fail-early \
+ --output /dev/null --write-out '%{time_total}\n' \
+ --parallel --parallel-max $PARALLEL_REQUESTS --parallel-immediate \
+ --user "$CPS_USERNAME:$CPS_PASSWORD" --basic \
+ --request POST "http://$CPS_HOST:$CPS_PORT/ncmp/v1/ch/ch-[1-$totalRequests]/data/ds/ncmp-datastore%3Apassthrough-operational?resourceIdentifier=x&include-descendants=true" |
+ awk '{ sum += $1; n++ } END { if (n > 0) print (sum / n) * 1000; }'
+}
+
+# Sanity checks
+failIfCmHandlesNotFound
+warnIfLessThan20kCmHandlesFound
+
+# Do JVM warmup
+echo "Warming up ($WARMUP_REQUESTS requests, ignoring results)"
+measureAverageResponseTimeInMillis "$WARMUP_REQUESTS" > /dev/null
+
+# Measure performance
+echo "Measuring average time of $MEASUREMENT_REQUESTS total requests, sending $PARALLEL_REQUESTS requests in parallel"
+ncmpResponseTime=$(measureAverageResponseTimeInMillis "$MEASUREMENT_REQUESTS")
+ncmpOverhead=$(echo "$ncmpResponseTime - $DMI_DATA_DELAY" | bc)
+
+# Report performance
+echo "Average response time from NCMP: $ncmpResponseTime ms"
+echo "Average response time from DMI: $DMI_DATA_DELAY ms"
+echo "NCMP overhead: $ncmpOverhead ms"