From b2487df835ced40f20403ac1e0f95dd1407e9eca Mon Sep 17 00:00:00 2001 From: srinivasyanamadala Date: Fri, 20 Dec 2024 15:49:24 +0100 Subject: [PATCH] Added changes for performance and stability for opa-pdp Issue-ID: POLICY-5215 Change-Id: I4153b1aafe9cc7d8e94812733c946a0e1eb0c42c Signed-off-by: srinivasyanamadala --- .../src/main/resources/testplans/perf.jmx | 870 +++++++++++++++++++++ .../src/main/resources/testplans/results.sh | 38 + testsuites/run-s3p-test.sh | 49 ++ .../src/main/resources/testplans/stability.jmx | 741 ++++++++++++++++++ 4 files changed, 1698 insertions(+) create mode 100644 testsuites/performance/src/main/resources/testplans/perf.jmx create mode 100644 testsuites/performance/src/main/resources/testplans/results.sh create mode 100644 testsuites/run-s3p-test.sh create mode 100644 testsuites/stability/src/main/resources/testplans/stability.jmx diff --git a/testsuites/performance/src/main/resources/testplans/perf.jmx b/testsuites/performance/src/main/resources/testplans/perf.jmx new file mode 100644 index 0000000..0152066 --- /dev/null +++ b/testsuites/performance/src/main/resources/testplans/perf.jmx @@ -0,0 +1,870 @@ + + + + + Policy OPA PDP Performance Tests + true + + + + DURATION + ${__P(duration, 1200)} + = + + + USERS + ${__P(users, 10)} + = + + + HTTP + http + = + + + API_HOST + localhost + = + + + PAP_HOST + localhost + = + + + OPA_PDP_HOST + localhost + = + + + API_PORT + ${__P(api_port, 30002)} + = + + + PAP_PORT + ${__P(pap_port, 30003)} + = + + + OPA_PDP_PORT + ${__P(opa_pdp_port, 30012)} + = + + + API_USER + policyadmin + = + + + PAP_USER + policyadmin + = + + + OPA_PDP_USER + policyadmin + = + + + API_PASSWORD + zb!XztG34 + = + + + PAP_PASSWORD + zb!XztG34 + = + + + OPA_PDP_PASSWORD + zb!XztG34 + = + + + + + + + + + Content-Type + application/json + + + Accept + application/json + + + + + + ${USERS} + 10 + ${DURATION} + 1 + true + true + continue + + -1 + false + + + + + Basic Health Check + 6 + ${OPA_PDP_HOST} + ${OPA_PDP_PORT} + ${HTTP} + policy/pdpx/v1/healthcheck + true + GET + true + false + + + + + + + + 200 + + + Assertion.response_code + false + 8 + all + + + + groovy + + + true + import groovy.json.JsonSlurper; + +def res = []; +if (prev.getResponseCode() == '200') { + def jsonSlurper = new JsonSlurper(); + res = jsonSlurper.parseText(prev.getResponseDataAsString()); + + assert res instanceof Map; + assert res.code == 200; + +} + + + + + + + ${HTTP}://${OPA_PDP_HOST}:${OPA_PDP_PORT}/policy/pdpx/v1 + ${OPA_PDP_USER} + ${OPA_PDP_PASSWORD} + + + + + true + false + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + /tmp/pdpx_perf_health.log + + + + + + ${USERS} + 10 + ${DURATION} + 1 + true + true + continue + + -1 + false + + + + + Get Verification API Call 1 + 6 + ${OPA_PDP_HOST} + ${OPA_PDP_PORT} + ${HTTP} + policy/pdpx/v1/decision + true + POST + true + true + + + + false + { + "onapName": "CDS", + "onapComponent": "CDS", + "onapInstance": "CDS", + "currentDate": "2024-11-22", + "currentTime": "2024-11-22T11:34:56Z", + "timeZone": "UTC", + "timeOffset": "+05:30", + "currentDateTime": "2024-11-22T12:08:00Z", + "policyName": "example/allow", + "input": { + "method": "POST", + "path": [ + "users" + ] + } +} + = + + + + + + + + 200 + + + Assertion.response_code + false + 8 + + + + + PERMIT + + + Assertion.response_data + false + 2 + + + + + Get Verification API Call 2 + 6 + ${OPA_PDP_HOST} + ${OPA_PDP_PORT} + ${HTTP} + policy/pdpx/v1/decision + true + POST + true + true + + + + false + { + "onapName": "CDS", + "onapComponent": "CDS", + "onapInstance": "CDS", + "currentDate": "2024-11-22", + "currentTime": "2024-11-22T11:34:56Z", + "timeZone": "UTC", + "timeOffset": "+05:30", + "currentDateTime": "2024-11-22T12:08:00Z", + "policyName": "role/allow", + "input": { + "user": "alice", + "action": "write", + "object": "id123", + "type": "dog" + } +} + = + + + + + + + + 200 + + + Assertion.response_code + false + 8 + + + + + PERMIT + + + Assertion.response_data + false + 2 + + + + + PERMIT for policy:action + 6 + ${OPA_PDP_HOST} + ${OPA_PDP_PORT} + ${HTTP} + policy/pdpx/v1/decision + true + POST + true + true + + + + false + { + "onapName": "CDS", + "onapComponent": "CDS", + "onapInstance": "CDS", + "currentDate": "2024-11-22", + "currentTime": "2024-11-22T11:34:56Z", + "timeZone": "UTC", + "timeOffset": "+05:30", + "currentDateTime": "2024-11-22T12:08:00Z", + "policyName": "action/allow", + "input": { + "user": "alice", + "action": "delete", + "type": "server" + } +} + = + + + + + + + + 200 + + + Assertion.response_code + false + 8 + + + + + PERMIT + + + Assertion.response_data + false + 2 + + + + + DENY for policy:action + 6 + ${OPA_PDP_HOST} + ${OPA_PDP_PORT} + ${HTTP} + policy/pdpx/v1/decision + true + POST + true + true + + + + false + { + "onapName": "CDS", + "onapComponent": "CDS", + "onapInstance": "CDS", + "currentDate": "2024-11-22", + "currentTime": "2024-11-22T11:34:56Z", + "timeZone": "UTC", + "timeOffset": "+05:30", + "currentDateTime": "2024-11-22T12:08:00Z", + "policyName": "action/allow", + "input": { + "user": "charlie", + "action": "delete", + "type": "server" + } +} + = + + + + + + + + 200 + + + Assertion.response_code + false + 8 + + + + + DENY + + + Assertion.response_data + false + 2 + + + + + PERMIT for policy:account + 6 + ${OPA_PDP_HOST} + ${OPA_PDP_PORT} + ${HTTP} + policy/pdpx/v1/decision + true + POST + true + true + + + + false + { + "onapName": "CDS", + "onapComponent": "CDS", + "onapInstance": "CDS", + "currentDate": "2024-11-22", + "currentTime": "2024-11-22T11:34:56Z", + "timeZone": "UTC", + "timeOffset": "+05:30", + "currentDateTime": "2024-11-22T12:08:00Z", + "policyName": "account/allow", + "input": { + "creditor_account": 11111, + "creditor": "alice", + "debtor_account": 22222, + "debtor": "bob", + "period": 30, + "amount": 1000 + } +} + = + + + + + + + + 200 + + + Assertion.response_code + false + 8 + + + + + PERMIT + + + Assertion.response_data + false + 2 + + + + + DENY for policy:account + 6 + ${OPA_PDP_HOST} + ${OPA_PDP_PORT} + ${HTTP} + policy/pdpx/v1/decision + true + POST + true + true + + + + false + { + "onapName": "CDS", + "onapComponent": "CDS", + "onapInstance": "CDS", + "currentDate": "2024-11-22", + "currentTime": "2024-11-22T11:34:56Z", + "timeZone": "UTC", + "timeOffset": "+05:30", + "currentDateTime": "2024-11-22T12:08:00Z", + "policyName": "account/allow", + "input": { + "creditor_account": 11111, + "creditor": "alice", + "debtor_account": 22222, + "debtor": "bob", + "period": 31, + "amount": 1000 + } +} + = + + + + + + + + 200 + + + Assertion.response_code + false + 8 + + + + + DENY + + + Assertion.response_data + false + 2 + + + + + PERMIT for policy:organization + 6 + ${OPA_PDP_HOST} + ${OPA_PDP_PORT} + ${HTTP} + policy/pdpx/v1/decision + true + POST + true + true + + + + false + { + "onapName": "CDS", + "onapComponent": "CDS", + "onapInstance": "CDS", + "currentDate": "2024-11-22", + "currentTime": "2024-11-22T11:34:56Z", + "timeZone": "UTC", + "timeOffset": "+05:30", + "currentDateTime": "2024-11-22T12:08:00Z", + "policyName": "organization/allow", + "input": { + "user": "alice", + "action": "read", + "component": "component_A", + "project": "project_A", + "organization": "org_A" + } +} + = + + + + + + + + 200 + + + Assertion.response_code + false + 8 + + + + + PERMIT + + + Assertion.response_data + false + 2 + + + + + DENY for policy:organization + 6 + ${OPA_PDP_HOST} + ${OPA_PDP_PORT} + ${HTTP} + policy/pdpx/v1/decision + true + POST + true + true + + + + false + { + "onapName": "CDS", + "onapComponent": "CDS", + "onapInstance": "CDS", + "currentDate": "2024-11-22", + "currentTime": "2024-11-22T11:34:56Z", + "timeZone": "UTC", + "timeOffset": "+05:30", + "currentDateTime": "2024-11-22T12:08:00Z", + "policyName": "organization/allow", + "input": { + "user": "charlie", + "action": "edit", + "component": "component_A", + "project": "project_A", + "organization": "org_A" + } +} + = + + + + + + + + 200 + + + Assertion.response_code + false + 8 + + + + + DENY + + + Assertion.response_data + false + 2 + + + + + + + ${HTTP}://${OPA_PDP_HOST}:${OPA_PDP_PORT}/policy/pdpx/v1 + ${OPA_PDP_USER} + ${OPA_PDP_PASSWORD} + + + + + true + false + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + /tmp/pdpx_perf_decisions.log + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + /tmp/pdpx_perf_summaryReport.log + true + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + /tmp/pdpx_perf_resultsTree.log + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + /tmp/pdpx_perf_resultsTable.log + + + + + diff --git a/testsuites/performance/src/main/resources/testplans/results.sh b/testsuites/performance/src/main/resources/testplans/results.sh new file mode 100644 index 0000000..e747d13 --- /dev/null +++ b/testsuites/performance/src/main/resources/testplans/results.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# ============LICENSE_START======================================================= +# Copyright (C) 2024 Deutsche Telekom Intellectual Property. 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. +# 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========================================================= + +LOGFILE=$1 +if [[ ! -f $LOGFILE ]]; then + echo "The file '$LOGFILE' in not provided." + echo "Please provide log file to process." + exit 1 +fi + +echo "File being processed: " $LOGFILE +MS=$(awk -F "," 'NR==2 { tbeg = $1 } + NR>1 { tend = $1 } + END { print tend-tbeg }' $LOGFILE) +RES=$(awk -F "," 'NR>1 { total += $15 } END { print total/NR }' $LOGFILE) +echo "Average Latency (ms): " $RES +LC=$(awk 'END{print NR}' $LOGFILE) +echo "Total Requests:" $LC +MPS=$(echo $LC $MS | awk '{ print 1000*$1/$2 }') +echo "Measured requests/sec:" $MPS + diff --git a/testsuites/run-s3p-test.sh b/testsuites/run-s3p-test.sh new file mode 100644 index 0000000..85b9f08 --- /dev/null +++ b/testsuites/run-s3p-test.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# ============LICENSE_START======================================================= +# Copyright (C) 2024 Deutsche Telekom Intellectual Property. 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. +# 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========================================================= + +#===MAIN===# +if [ -z "${WORKSPACE}" ]; then + export WORKSPACE=$(git rev-parse --show-toplevel) +fi + +export TESTDIR=${WORKSPACE}/testsuites +export OPA_PERF_TEST_FILE=$TESTDIR/performance/src/main/resources/testplans/perf.jmx +export OPA_STAB_TEST_FILE=$TESTDIR/stability/src/main/resources/testplans/stability.jmx + +if [ $1 == "run" ] +then + + mkdir automate-s3p-test;cd automate-s3p-test; + git clone "https://gerrit.onap.org/r/policy/docker" + cd docker/csit + + if [ $2 == "performance" ] + then + bash start-s3p-tests.sh run $OPA_PERF_TEST_FILE opa-pdp; + elif [ $2 == "stability" ] + then + bash start-s3p-tests.sh run $OPA_STAB_TEST_FILE opa-pdp; + else + echo "echo Invalid arguments provided. Usage: $0 [option..] {performance | stability}" + fi + +else + echo "Invalid arguments provided. Usage: $0 [option..] {run | uninstall}" +fi + diff --git a/testsuites/stability/src/main/resources/testplans/stability.jmx b/testsuites/stability/src/main/resources/testplans/stability.jmx new file mode 100644 index 0000000..a4cda3b --- /dev/null +++ b/testsuites/stability/src/main/resources/testplans/stability.jmx @@ -0,0 +1,741 @@ + + + + + Policy OPA PDP Stability Tests + true + + + + DURATION + ${__P(duration, 1800)} + = + + + USERS + ${__P(users, 2)} + = + + + HTTP + http + = + + + API_HOST + localhost + = + + + PAP_HOST + localhost + = + + + OPA_PDP_HOST + localhost + = + + + API_PORT + ${__P(api_port, 30002)} + = + + + PAP_PORT + ${__P(pap_port, 30003)} + = + + + OPA_PDP_PORT + ${__P(opa_pdp_port, 30012)} + = + + + API_USER + policyadmin + = + + + PAP_USER + policyadmin + = + + + OPA_PDP_USER + policyadmin + = + + + API_PASSWORD + zb!XztG34 + = + + + PAP_PASSWORD + zb!XztG34 + = + + + OPA_PDP_PASSWORD + zb!XztG34 + = + + + + false + false + + + + + + Content-Type + application/json + + + Accept + application/json + + + + + + ${USERS} + 10 + ${DURATION} + 1 + true + true + continue + + -1 + false + + + + + Basic Health Check + 6 + ${OPA_PDP_HOST} + ${OPA_PDP_PORT} + ${HTTP} + policy/pdpx/v1/healthcheck + true + GET + true + false + + + + + + + + 200 + + + Assertion.response_code + false + 8 + all + + + + groovy + + + true + import groovy.json.JsonSlurper; + +def res = []; +if (prev.getResponseCode() == '200') { + def jsonSlurper = new JsonSlurper(); + res = jsonSlurper.parseText(prev.getResponseDataAsString()); + + assert res instanceof Map; + assert res.code == 200; + +} + + + + + + + ${HTTP}://${OPA_PDP_HOST}:${OPA_PDP_PORT}/policy/pdpx/v1 + ${OPA_PDP_USER} + ${OPA_PDP_PASSWORD} + + + + + true + false + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + /tmp/pdpx_stability_health.log + + + + + + ${USERS} + 10 + ${DURATION} + 1 + true + true + continue + + -1 + false + + + + + Verification API Call 1 + 6 + ${OPA_PDP_HOST} + ${OPA_PDP_PORT} + ${HTTP} + policy/pdpx/v1/decision + true + POST + true + true + + + + false + {"onapName":"CDS","onapComponent":"CDS","onapInstance":"CDS","currentDate": "2024-11-22", "currentTime": "2024-11-22T11:34:56Z", "timeZone": "UTC", "timeOffset": "+05:30", "currentDateTime": "2024-11-22T12:08:00Z","policyName":"example/allow","input":{"method":"POST","path":["users"]}} + = + + + + + + + + 200 + + + Assertion.response_code + false + 8 + + + + + PERMIT + + + Assertion.response_data + false + 2 + + + + + Verification API Call 2 + 6 + ${OPA_PDP_HOST} + ${OPA_PDP_PORT} + ${HTTP} + policy/pdpx/v1/decision + true + POST + true + true + + + + false + {"onapName":"CDS","onapComponent":"CDS","onapInstance":"CDS","currentDate": "2024-11-22", "currentTime": "2024-11-22T11:34:56Z", "timeZone": "UTC", "timeOffset": "+05:30", "currentDateTime": "2024-11-22T12:08:00Z", "policyName":"role/allow","input":{"user":"alice","action":"write","object":"id123","type":"dog"}} + = + + + + + + + + 200 + + + Assertion.response_code + false + 8 + + + + + PERMIT + + + Assertion.response_data + false + 2 + + + + + PERMIT for policy:action + 6 + ${OPA_PDP_HOST} + ${OPA_PDP_PORT} + ${HTTP} + policy/pdpx/v1/decision + true + POST + true + true + + + + false + {"onapName":"CDS","onapComponent":"CDS","onapInstance":"CDS", "currentDate": "2024-11-22", "currentTime": "2024-11-22T11:34:56Z", "timeZone": "UTC", "timeOffset": "+05:30", "currentDateTime": "2024-11-22T12:08:00Z","policyName":"action/allow","input":{"user":"alice","action":"delete","type":"server"}} + = + + + + + + + + 200 + + + Assertion.response_code + false + 8 + + + + + PERMIT + + + Assertion.response_data + false + 2 + + + + + DENY for policy:action + 6 + ${OPA_PDP_HOST} + ${OPA_PDP_PORT} + ${HTTP} + policy/pdpx/v1/decision + true + POST + true + true + + + + false + {"onapName":"CDS","onapComponent":"CDS","onapInstance":"CDS", "currentDate": "2024-11-22", "currentTime": "2024-11-22T11:34:56Z", "timeZone": "UTC", "timeOffset": "+05:30", "currentDateTime": "2024-11-22T12:08:00Z","policyName":"action/allow","input":{"user":"charlie","action":"delete","type":"server"}} + = + + + + + + + + 200 + + + Assertion.response_code + false + 8 + + + + + DENY + + + Assertion.response_data + false + 2 + + + + + PERMIT for policy:account + 6 + ${OPA_PDP_HOST} + ${OPA_PDP_PORT} + ${HTTP} + policy/pdpx/v1/decision + true + POST + true + true + + + + false + {"onapName":"CDS","onapComponent":"CDS","onapInstance":"CDS", "currentDate": "2024-11-22", "currentTime": "2024-11-22T11:34:56Z", "timeZone": "UTC","timeOffset": "+05:30", "currentDateTime": "2024-11-22T12:08:00Z","policyName":"account/allow", "input":{"creditor_account":11111,"creditor":"alice","debtor_account":22222,"debtor":"bob","period":30,"amount":1000}} + = + + + + + + + + 200 + + + Assertion.response_code + false + 8 + + + + + PERMIT + + + Assertion.response_data + false + 2 + + + + + DENY for policy:account + 6 + ${OPA_PDP_HOST} + ${OPA_PDP_PORT} + ${HTTP} + policy/pdpx/v1/decision + true + POST + true + true + + + + false + {"onapName":"CDS","onapComponent":"CDS","onapInstance":"CDS", "currentDate": "2024-11-22", "currentTime": "2024-11-22T11:34:56Z", "timeZone": "UTC", "timeOffset": "+05:30", "currentDateTime": "2024-11-22T12:08:00Z","policyName":"account/allow", "input":{"creditor_account":11111,"creditor":"alice","debtor_account":22222,"debtor":"bob","period":31,"amount":1000}} + + + = + + + + + + + + 200 + + + Assertion.response_code + false + 8 + + + + + DENY + + + Assertion.response_data + false + 2 + + + + + PERMIT for policy:organization + 6 + ${OPA_PDP_HOST} + ${OPA_PDP_PORT} + ${HTTP} + policy/pdpx/v1/decision + true + POST + true + true + + + + false + {"onapName":"CDS","onapComponent":"CDS","onapInstance":"CDS", "currentDate": "2024-11-22", "currentTime": "2024-11-22T11:34:56Z", "timeZone": "UTC", "timeOffset": "+05:30", "currentDateTime": "2024-11-22T12:08:00Z","policyName":"organization/allow", "input":{"user":"alice","action": "read","component": "component_A","project": "project_A", "organization": "org_A"}} + = + + + + + + + + 200 + + + Assertion.response_code + false + 8 + + + + + PERMIT + + + Assertion.response_data + false + 2 + + + + + DENY for policy:organization + 6 + ${OPA_PDP_HOST} + ${OPA_PDP_PORT} + ${HTTP} + policy/pdpx/v1/decision + true + POST + true + true + + + + false + {"onapName":"CDS","onapComponent":"CDS","onapInstance":"CDS", "currentDate": "2024-11-22", "currentTime": "2024-11-22T11:34:56Z", "timeZone": "UTC", "timeOffset": "+05:30", "currentDateTime": "2024-11-22T12:08:00Z","policyName":"organization/allow", "input":{"user":"charlie","action": "edit","component": "component_A","project": "project_A", "organization": "org_A"}} + = + + + + + + + + 200 + + + Assertion.response_code + false + 8 + + + + + DENY + + + Assertion.response_data + false + 2 + + + + + + + ${HTTP}://${OPA_PDP_HOST}:${OPA_PDP_PORT}/policy/pdpx/v1 + ${OPA_PDP_USER} + ${OPA_PDP_PASSWORD} + + + + + true + false + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + /tmp/pdpx_stability_decisions.log + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + + + /tmp/pdpx_stability_summaryReport.log + true + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + /tmp/pdpx_stability_resultsTree.log + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + /tmp/pdpx_stability_resultsTable.log + + + + + -- 2.16.6