4 # ============LICENSE_START=======================================================
6 # ================================================================================
7 # Copyright (C) 2021 AT&T Intellectual Property. All rights
9 # ================================================================================
10 # Licensed under the Apache License, Version 2.0 (the "License");
11 # you may not use this file except in compliance with the License.
12 # You may obtain a copy of the License at
14 # http://www.apache.org/licenses/LICENSE-2.0
16 # Unless required by applicable law or agreed to in writing, software
17 # distributed under the License is distributed on an "AS IS" BASIS,
18 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 # See the License for the specific language governing permissions and
20 # limitations under the License.
21 # ============LICENSE_END============================================
22 # ===================================================================
30 pap_url=`kubectl get services policy-pap -n onap |grep policy-pap | awk '{print $3}'`:$pap_port
31 echo "Policy pap url: $pap_url"
33 api_url=`kubectl get services policy-api -n onap |grep policy-api | awk '{print $3}'`:$api_port
34 echo "Policy api url: $api_url"
36 dmaap_url=`kubectl get services message-router -n onap |grep message-router | awk '{print $3}'`:$dmaap_port
37 echo "Dmaap url: $dmaap_url"
39 sdnc_url=`kubectl get services -n onap | grep sdnc-oam | awk '{print $3}'`:$sdnc_port
40 echo "SDNC url: $sdnc_url"
43 verifyApexPolicyStatus(){
45 curl -s -o /dev/null -X POST -H accept:application/json -H Content-Type:application/json "http://$dmaap_url/events/unauthenticated.SEC_FAULT_OUTPUT/" -d @./data/LinkFailureEvent.json
47 res=`kubectl logs onap-policy-apex-pdp-0 -n onap | grep "Task Selection Execution: 'LinkMonitorPolicy:0.0.1:NULL:LinkFailureOrClearedState'" | wc -l`
48 if [[ $res != 0 ]]; then
49 echo -e "LinkFailureEvent sent to Dmaap\n"
59 if [ "$1" == "$2" ]; then
62 echo -e "Result is not as expected: $2\n"
69 res=$(curl -sk -u 'healthcheck:zb!XztG34' -X GET "https://$pap_url/policy/pap/v1/components/healthcheck")
70 apex_info=$(echo $res| cut -d'{' -f 4)
72 echo "Verify policy Pap"
73 if [[ $res == *"url\":\"https://$1:6969/policy/pap/v1/healthcheck\",\"healthy\":true"* ]]; then
74 echo "Policy Pap is ready"
75 echo "Verify policy api"
76 if [[ $res == *"url\":\"https://$2:6969/policy/api/v1/healthcheck\",\"healthy\":true"* ]]; then
77 echo "Policy API is ready"
78 echo "Verify policy Apex pdp"
79 if [[ $apex_info == *"instanceId\":\"apex"* && $apex_info == *"healthy\":\"HEALTHY"* ]]; then
80 echo "Policy APEX pdp is ready"
83 echo "Policy Apex pdp not ready yet. Wait for a while and retry."
87 echo "Policy api not ready yet. Wait for a while and retry."
91 echo "Policy Pap not ready yet. Wait for a while and retry."
97 checkPolicyDeployment (){
98 res=$(curl -sk -u 'healthcheck:zb!XztG34' -X GET "https://$pap_url/policy/pap/v1/policies/status")
99 str1="onap.policies.native.apex.LinkMonitor\",\"version\":\"1.0.0\"},\"policyType\":{\"name\":\"onap.policies.native.Apex\",\"version\":\"1.0.0\"},\"deploy\":true"
100 if [[ $res == *"$str1"* ]]; then
101 echo "Policy successfully deployed"
103 echo "Policy deployment failed"
109 curl -sk -X POST "http://$dmaap_url/topics/create" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"topicName\": \"unauthenticated.SEC_FAULT_OUTPUT\", \"topicDescription\": \"test topic\", \"partitionCount\": 1, \"replicationCnCount\": 1, \"transactionEnabled\": \"false\"}"
111 curl -sk http://$dmaap_url/topics/listAll
114 echo "Policy component healthcheck:"
115 pap_pod=`kubectl get pods -n onap | grep onap-policy-pap | awk '{print $1}'`
116 api_pod=`kubectl get pods -n onap | grep onap-policy-api | awk '{print $1}'`
117 checkPolicyStatus $pap_pod $api_pod
120 echo "Create policy:"
121 res=`curl -sk -u 'healthcheck:zb!XztG34' -X POST "https://$api_url/policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies" -H "Accept: application/json" -H "Content-Type: application/json" -d @./data/ToscaPolicy.json`
122 res2=`curl -sk -u 'healthcheck:zb!XztG34' -X GET "https://$api_url/policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies/onap.policies.native.apex.LinkMonitor/versions/1.0.0"`
124 echo "Policy created successfully"
128 echo "Deploy the policy to apex-pdp via Policy PAP:"
129 curl -sk -u 'healthcheck:zb!XztG34' -X POST "https://$pap_url/policy/pap/v1/pdps/policies" -H "Accept: application/json" -H "Content-Type: application/json" -d @./data/DeployPolicyPAP.json
132 echo "Verify policy deployed:"
133 checkPolicyDeployment
136 echo "Check O-du/O-ru status"
137 res=$(curl -sk -H "Authorization: Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==" -X GET "http://$sdnc_url/rests/data/network-topology:network-topology/topology=topology-netconf/node=o-du-1122/yang-ext:mount/o-ran-sc-du-hello-world:network-function/du-to-ru-connection=o-ru-11221")
138 expected="{\"o-ran-sc-du-hello-world:du-to-ru-connection\":[{\"name\":\"o-ru-11221\",\"operational-state\":\"ENABLED\",\"administrative-state\":\"LOCKED\",\"status\":\"disconnected\"}]}"
139 checkStatus $res $expected "O-ru has status LOCKED"
142 echo "Wait for a while for Apex engine to be ready before sending Dmaap event"
143 verifyApexPolicyStatus
146 echo "Wait for a while and check O-du/O-ru status again"
148 res=$(curl -sk -H "Authorization: Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==" -X GET "http://$sdnc_url/rests/data/network-topology:network-topology/topology=topology-netconf/node=o-du-1122/yang-ext:mount/o-ran-sc-du-hello-world:network-function/du-to-ru-connection=o-ru-11221")
149 expected="{\"o-ran-sc-du-hello-world:du-to-ru-connection\":[{\"name\":\"o-ru-11221\",\"operational-state\":\"ENABLED\",\"administrative-state\":\"UNLOCKED\",\"status\":\"disconnected\"}]}"
150 checkStatus $res $expected "O-ru has status UNLOCKED"