diff options
Diffstat (limited to 'helm/tests')
-rwxr-xr-x | helm/tests/data/wait_for_rest.sh | 77 | ||||
-rw-r--r-- | helm/tests/xacml-pdp-test.robot | 150 |
2 files changed, 77 insertions, 150 deletions
diff --git a/helm/tests/data/wait_for_rest.sh b/helm/tests/data/wait_for_rest.sh new file mode 100755 index 00000000..a64c3063 --- /dev/null +++ b/helm/tests/data/wait_for_rest.sh @@ -0,0 +1,77 @@ +#!/bin/sh +# ============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====================================================== +usage() { + echo args: [-t timeout] [-c command] hostname1 port1 hostname2 port2 ... >&2 + exit 1 +} +tmout=300 +cmd= +while getopts c:t: opt +do + case "$opt" in + c) + cmd="$OPTARG" + ;; + t) + tmout="$OPTARG" + ;; + *) + usage + ;; + esac +done +nargs=$((OPTIND-1)) +shift "$nargs" +even_args=$(($#%2)) +if [ $# -lt 2 ] || [ "$even_args" -ne 0 ] +then + usage +fi +while [ $# -ge 2 ] +do + export host="$1" + export port="$2" + shift + shift + echo "Waiting for REST to come up on $host port $port..." + while [ "$tmout" -gt 0 ] + do + if command -v docker > /dev/null 2>&1 + then + docker ps --format "table {{ .Names }}\t{{ .Status }}" + fi + curl "http://$host:$port" > /dev/null 2>&1 + rc=$? + if [ $rc -eq 0 ] + then + break + else + tmout=$((tmout-1)) + sleep 1 + fi + done + if [ $rc -ne 0 ] + then + echo "$host port $port REST cannot be detected" + exit $rc + fi +done +$cmd +exit 0 + diff --git a/helm/tests/xacml-pdp-test.robot b/helm/tests/xacml-pdp-test.robot deleted file mode 100644 index 2ae52a7e..00000000 --- a/helm/tests/xacml-pdp-test.robot +++ /dev/null @@ -1,150 +0,0 @@ -*** Settings *** -Library Collections -Library RequestsLibrary -Library OperatingSystem -Library Process -Library json -Resource common-library.robot - -*** Test Cases *** -Healthcheck - [Documentation] Verify policy xacml-pdp health check - ${resp}= PdpxGetReq /policy/pdpx/v1/healthcheck - Should Be Equal As Strings ${resp.json()['code']} 200 - -Statistics - [Documentation] Verify policy xacml-pdp statistics - ${resp}= PdpxGetReq /policy/pdpx/v1/statistics - Should Be Equal As Strings ${resp.json()['code']} 200 - -Metrics - [Documentation] Verify policy-xacml-pdp is exporting prometheus metrics - ${resp}= PdpxGetReq /metrics - Should Contain ${resp.text} jvm_threads_current - -MakeTopics - [Documentation] Creates the Policy topics - ${result}= Run Process ${SCR_DMAAP}/make_topic.sh POLICY-PDP-PAP - Should Be Equal As Integers ${result.rc} 0 - -ExecuteXacmlPolicy - CreateMonitorPolicy - CreateOptimizationPolicy - Wait Until Keyword Succeeds 1 min 15 sec GetDefaultDecision - DeployPolicies - Wait Until Keyword Succeeds 1 min 15 sec GetStatisticsAfterDeployed - Wait Until Keyword Succeeds 1 min 15 sec GetAbbreviatedDecisionResult - Wait Until Keyword Succeeds 1 min 15 sec GetMonitoringDecision - Wait Until Keyword Succeeds 1 min 15 sec GetNamingDecision - Wait Until Keyword Succeeds 1 min 15 sec GetOptimizationDecision - Wait Until Keyword Succeeds 1 min 15 sec GetStatisticsAfterDecision - UndeployMonitorPolicy - Wait Until Keyword Succeeds 1 min 15 sec GetStatisticsAfterUndeploy - -*** Keywords *** - -CreateMonitorPolicy - [Documentation] Create a Monitoring policy - ${postjson}= Get file ${DATA2}/vCPE.policy.monitoring.input.tosca.json - CreatePolicy /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0/policies 200 ${postjson} onap.restart.tca 1.0.0 - -CreateOptimizationPolicy - [Documentation] Create an Optimization policy - ${postjson}= Get file ${DATA2}/vCPE.policies.optimization.input.tosca.json - CreatePolicy /policy/api/v1/policytypes/onap.policies.optimization.resource.AffinityPolicy/versions/1.0.0/policies 200 ${postjson} OSDF_CASABLANCA.Affinity_Default 1.0.0 - -GetDefaultDecision - [Documentation] Get Default Decision with no policies in Xacml PDP - ${postjson}= Get file ${CURDIR}/data/onap.policy.guard.decision.request.json - ${resp}= DecisionPostReq ${postjson} abbrev=true - ${status}= Get From Dictionary ${resp.json()} status - Should Be Equal As Strings ${status} Permit - -DeployPolicies - [Documentation] Runs Policy PAP to deploy a policy - ${postjson}= Get file ${CURDIR}/data/vCPE.policy.input.tosca.deploy.json - ${policyadmin}= PolicyAdminAuth - PerformPostRequest ${POLICY_PAP_IP} /policy/pap/v1/pdps/policies 202 ${postjson} null ${policyadmin} - ${result}= Run Process ${SCR_DMAAP}/wait_topic.sh POLICY-PDP-PAP - ... responseTo xacml ACTIVE onap.restart.tca - Should Be Equal As Integers ${result.rc} 0 - -GetStatisticsAfterDeployed - [Documentation] Verify policy xacml-pdp statistics after policy is deployed - ${resp}= PdpxGetReq /policy/pdpx/v1/statistics - Should Be Equal As Strings ${resp.json()['code']} 200 - Should Be Equal As Strings ${resp.json()['totalPoliciesCount']} 3 - -GetAbbreviatedDecisionResult - [Documentation] Get Decision with abbreviated results from Policy Xacml PDP - ${postjson}= Get file ${CURDIR}/data/onap.policy.monitoring.decision.request.json - ${resp}= DecisionPostReq ${postjson} abbrev=true - ${policy}= Get From Dictionary ${resp.json()['policies']} onap.restart.tca - Dictionary Should Contain Key ${policy} type - Dictionary Should Contain Key ${policy} metadata - Dictionary Should Not Contain Key ${policy} type_version - Dictionary Should Not Contain Key ${policy} properties - Dictionary Should Not Contain Key ${policy} name - Dictionary Should Not Contain Key ${policy} version - -GetMonitoringDecision - [Documentation] Get Decision from Monitoring Policy Xacml PDP - ${postjson}= Get file ${CURDIR}/data/onap.policy.monitoring.decision.request.json - ${resp}= DecisionPostReq ${postjson} null - ${policy}= Get From Dictionary ${resp.json()['policies']} onap.restart.tca - Dictionary Should Contain Key ${policy} type - Dictionary Should Contain Key ${policy} metadata - Dictionary Should Contain Key ${policy} type_version - Dictionary Should Contain Key ${policy} properties - Dictionary Should Contain Key ${policy} name - Dictionary Should Contain Key ${policy} version - -GetNamingDecision - [Documentation] Get Decision from Naming Policy Xacml PDP - ${postjson}= Get file ${CURDIR}/data/onap.policy.naming.decision.request.json - ${resp}= DecisionPostReq ${postjson} null - ${policy}= Get From Dictionary ${resp.json()['policies']} SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP - Dictionary Should Contain Key ${policy} type - Dictionary Should Contain Key ${policy} type_version - Dictionary Should Contain Key ${policy} properties - Dictionary Should Contain Key ${policy} name - -GetOptimizationDecision - [Documentation] Get Decision from Optimization Policy Xacml PDP - ${postjson}= Get file ${CURDIR}/data/onap.policy.optimization.decision.request.json - ${resp}= DecisionPostReq ${postjson} null - ${policy}= Get From Dictionary ${resp.json()['policies']} OSDF_CASABLANCA.Affinity_Default - Dictionary Should Contain Key ${policy} type - Dictionary Should Contain Key ${policy} type_version - Dictionary Should Contain Key ${policy} properties - Dictionary Should Contain Key ${policy} name - -GetStatisticsAfterDecision - [Documentation] Runs Policy Xacml PDP Statistics after Decision request - ${resp}= PdpxGetReq /policy/pdpx/v1/statistics - Should Be Equal As Strings ${resp.json()['code']} 200 - Should Be Equal As Strings ${resp.json()['permitDecisionsCount']} 4 - Should Be Equal As Strings ${resp.json()['notApplicableDecisionsCount']} 1 - -UndeployMonitorPolicy - [Documentation] Runs Policy PAP to undeploy a policy - ${policyadmin}= PolicyAdminAuth - PerformDeleteRequest ${POLICY_PAP_IP} /policy/pap/v1/pdps/policies/onap.restart.tca 202 ${policyadmin} - -GetStatisticsAfterUndeploy - [Documentation] Runs Policy Xacml PDP Statistics after policy is undeployed - ${resp}= PdpxGetReq /policy/pdpx/v1/statistics - Should Be Equal As Strings ${resp.json()['code']} 200 - Should Be Equal As Strings ${resp.json()['totalPoliciesCount']} 2 - -PdpxGetReq - [Arguments] ${url} - ${hcauth}= HealthCheckAuth - ${resp}= PerformGetRequest ${POLICY_PDPX_IP} ${url} 200 null ${hcauth} - [return] ${resp} - -DecisionPostReq - [Arguments] ${postjson} ${abbr} - ${hcauth}= HealthCheckAuth - ${resp}= PerformPostRequest ${POLICY_PDPX_IP} /policy/pdpx/v1/decision 200 ${postjson} ${abbr} ${hcauth} - [return] ${resp} |