3 Library RequestsLibrary
4 Library OperatingSystem
7 Resource ${CURDIR}/common-library.robot
13 [Documentation] Runs Apex PDP Health check
14 ${hcauth}= PolicyAdminAuth
15 ${resp}= PerformGetRequest ${APEX_IP} /policy/apex-pdp/v1/healthcheck 200 null ${hcauth}
16 Should Be Equal As Strings ${resp.json()['code']} 200
17 Set Suite Variable ${pdpName} ${resp.json()['name']}
19 ExecuteApexSampleDomainPolicy
21 Set Test Variable ${policyName} onap.policies.native.apex.Sampledomain
22 ${postjson}= Get File ${CURDIR}/data/${policyName}.json
23 CreatePolicy /policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies 200 ${postjson} ${policyName} 1.0.0
24 Wait Until Keyword Succeeds 3 min 5 sec VerifyPdpStatistics 0 0 0 0
26 Wait Until Keyword Succeeds 2 min 5 sec QueryPolicyStatus ${policyName} defaultGroup apex ${pdpName} onap.policies.native.Apex
27 Wait Until Keyword Succeeds 3 min 5 sec VerifyPdpStatistics 1 1 0 0
28 Wait Until Keyword Succeeds 4 min 5 sec RunEventOnApexEngine
29 Wait Until Keyword Succeeds 3 min 5 sec VerifyPdpStatistics 1 1 1 1
31 ExecuteApexTestPnfPolicy
32 Set Test Variable ${policyName} onap.policies.apex.pnf.Test
33 ${postjson}= Get File ${CURDIR}/data/${policyName}.json
34 CreatePolicy /policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies 200 ${postjson} ${policyName} 1.0.0
36 Wait Until Keyword Succeeds 2 min 5 sec QueryPolicyStatus ${policyName} defaultGroup apex ${pdpName} onap.policies.native.Apex
38 Wait Until Keyword Succeeds 2 min 5 sec TriggerAndVerifyTestPnfPolicy
40 ExecuteApexTestVnfPolicy
41 Set Test Variable ${policyName} onap.policies.apex.vnf.Test
42 ${postjson}= Get File ${CURDIR}/data/${policyName}.json
43 CreatePolicy /policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies 200 ${postjson} ${policyName} 1.0.0
45 Wait Until Keyword Succeeds 2 min 5 sec QueryPolicyStatus ${policyName} defaultGroup apex ${pdpName} onap.policies.native.Apex
47 Wait Until Keyword Succeeds 2 min 5 sec TriggerAndVerifyTestVnfPolicy
49 ExecuteApexTestPnfPolicyWithMetadataSet
50 Set Test Variable ${policyName} onap.policies.apex.pnf.metadataSet.Test
51 ${postjson}= Get File ${CURDIR}/data/${policyName}.json
52 CreatePolicy /policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies 200 ${postjson} ${policyName} 1.0.0
53 ${postjson}= Get File ${CURDIR}/data/onap.pnf.metadataSet.Test.json
54 CreateNodeTemplate /policy/api/v1/nodetemplates 200 ${postjson} 1
56 Wait Until Keyword Succeeds 2 min 5 sec QueryPolicyStatus ${policyName} defaultGroup apex ${pdpName} onap.policies.native.Apex
58 Wait Until Keyword Succeeds 2 min 5 sec TriggerAndVerifyTestPnfPolicy
61 [Documentation] Verify policy-apex-pdp is exporting prometheus metrics
62 ${auth}= PolicyAdminAuth
63 ${resp}= PerformGetRequest ${APEX_IP} /metrics 200 null ${auth}
64 Should Contain ${resp.text} pdpa_policy_deployments_total{operation="deploy",status="TOTAL",} 4.0
65 Should Contain ${resp.text} pdpa_policy_deployments_total{operation="deploy",status="SUCCESS",} 4.0
66 Should Contain ${resp.text} pdpa_policy_executions_total{status="SUCCESS",} 3.0
67 Should Contain ${resp.text} pdpa_policy_executions_total{status="TOTAL",} 3.0
68 Should Match ${resp.text} *pdpa_engine_event_executions{engine_instance_id="NSOApexEngine-*:0.0.1",}*
69 Should Match ${resp.text} *pdpa_engine_event_executions{engine_instance_id="MyApexEngine-*:0.0.1",}*
70 Should Match ${resp.text} *pdpa_engine_state{engine_instance_id=*,} 2.0*
71 Should Contain ${resp.text} pdpa_engine_event_executions
72 Should Contain ${resp.text} pdpa_engine_average_execution_time_seconds
73 Should Contain ${resp.text} pdpa_engine_last_execution_time_bucket
74 Should Contain ${resp.text} pdpa_engine_last_execution_time_count
75 Should Contain ${resp.text} pdpa_engine_last_execution_time_sum
76 Should Match ${resp.text} *pdpa_engine_last_start_timestamp_epoch{engine_instance_id="NSOApexEngine-*:0.0.1",}*E12*
77 Should Match ${resp.text} *pdpa_engine_last_start_timestamp_epoch{engine_instance_id="MyApexEngine-*:0.0.1",}*E12*
78 Should Contain ${resp.text} jvm_threads_current
83 [Documentation] Deploy the policy in apex-pdp engine
84 ${postjson}= Get File ${CURDIR}/data/policy_deploy.json
85 ${postjson}= evaluate json.loads('''${postjson}''') json
86 set to dictionary ${postjson['groups'][0]['deploymentSubgroups'][0]['policies'][0]} name=${policyName}
87 ${postjson}= evaluate json.dumps(${postjson}) json
88 ${policyadmin}= PolicyAdminAuth
89 PerformPostRequest ${POLICY_PAP_IP} /policy/pap/v1/pdps/deployments/batch 202 ${postjson} null ${policyadmin}
92 [Documentation] Send event to verify policy execution
93 Create Session apexSession http://${APEX_EVENTS_IP} max_retries=1
94 ${data}= Get Binary File ${CURDIR}/data/event.json
95 &{headers}= Create Dictionary Content-Type=application/json Accept=application/json
96 ${resp}= PUT On Session apexSession /apex/FirstConsumer/EventIn data=${data} headers=${headers}
97 Should Be Equal As Strings ${resp.status_code} 200
99 TriggerAndVerifyTestPnfPolicy
100 [Documentation] Send TestPnf policy trigger event to DMaaP and read notifications to verify policy execution
101 Create Session apexSession http://${DMAAP_IP} max_retries=1
102 ${data}= Get Binary File ${CURDIR}/data/VesEventForPnfPolicy.json
103 &{headers}= Create Dictionary Content-Type=application/json Accept=application/json
104 ${resp}= POST On Session apexSession /events/unauthenticated.DCAE_CL_OUTPUT data=${data} headers=${headers}
105 Should Be Equal As Strings ${resp.status_code} 200
106 Run Keyword CheckLogMessage ACTIVE VES event has been received. Going to fetch details from AAI.
107 Run Keyword CheckLogMessage SUCCESS Received response from AAI successfully. Hostname in AAI matches with the one in Ves event. Going to make the update-config request to CDS.
108 Run Keyword CheckLogMessage FINAL_SUCCESS Successfully processed the VES event. Hostname is updated.
110 TriggerAndVerifyTestVnfPolicy
111 [Documentation] Send TestVnf policy trigger event to DMaaP and read notifications to verify policy execution
112 Create Session apexSession http://${DMAAP_IP} max_retries=1
113 ${data}= Get Binary File ${CURDIR}/data/VesEventForVnfPolicy.json
114 &{headers}= Create Dictionary Content-Type=application/json Accept=application/json
115 ${resp}= POST On Session apexSession /events/unauthenticated.DCAE_POLICY_EXAMPLE_OUTPUT data=${data} headers=${headers}
116 Should Be Equal As Strings ${resp.status_code} 200
117 Run Keyword CheckLogMessage ACTIVE VES event has been received. Going to fetch VNF details from AAI.
118 Run Keyword CheckLogMessage SUCCESS VNF details are received from AAI successfully. Sending ConfigModify request to CDS.
119 Run Keyword CheckLogMessage SUCCESS ConfigModify request is successful. Sending restart request to CDS.
120 Run Keyword CheckLogMessage FINAL_SUCCESS Successfully processed the VES Event. Restart is complete.
123 [Documentation] Read log messages received and check for expected content.
124 [Arguments] ${status} ${expectedMsg}
125 ${result}= CheckTopic APEX-CL-MGT ${status}
126 Should Contain ${result} ${expectedMsg}
129 [Documentation] Verify pdp statistics after policy execution
130 [Arguments] ${deployCount} ${deploySuccessCount} ${executedCount} ${executedSuccessCount}
131 ${policyadmin}= PolicyAdminAuth
132 ${resp}= PerformGetRequest ${POLICY_PAP_IP} /policy/pap/v1/pdps/statistics/defaultGroup/apex/${pdpName} 200 null ${policyadmin}
133 Should Be Equal As Strings ${resp.status_code} 200
134 Should Be Equal As Strings ${resp.json()['defaultGroup']['apex'][0]['pdpInstanceId']} ${pdpName}
135 Should Be Equal As Strings ${resp.json()['defaultGroup']['apex'][0]['pdpGroupName']} defaultGroup
136 Should Be Equal As Strings ${resp.json()['defaultGroup']['apex'][0]['pdpSubGroupName']} apex
137 Should Be Equal As Strings ${resp.json()['defaultGroup']['apex'][0]['policyDeployCount']} ${deployCount}
138 Should Be Equal As Strings ${resp.json()['defaultGroup']['apex'][0]['policyDeploySuccessCount']} ${deploySuccessCount}
139 Should Be Equal As Strings ${resp.json()['defaultGroup']['apex'][0]['policyDeployFailCount']} 0
140 Should Be Equal As Strings ${resp.json()['defaultGroup']['apex'][0]['policyExecutedCount']} ${executedCount}
141 Should Be Equal As Strings ${resp.json()['defaultGroup']['apex'][0]['policyExecutedSuccessCount']} ${executedSuccessCount}
142 Should Be Equal As Strings ${resp.json()['defaultGroup']['apex'][0]['policyExecutedFailCount']} 0