3 Library RequestsLibrary
4 Library OperatingSystem
8 Resource ${CURDIR}/common-library.robot
9 Resource ${CURDIR}/apex-pdp-common.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 ValidatePolicyExecutionAndEventRateLowComplexity
20 [Documentation] Validate that a moderate complexity policity can be executed in less than 100ms and minimum 100 events triggered per second
21 Set Test Variable ${policyName} onap.policies.apex.pnf.metadataSet.Test
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 ${postjson}= Get File ${CURDIR}/data/onap.pnf.metadataSet.Test.json
25 CreateNodeTemplate /policy/api/v1/nodetemplates 200 ${postjson} 1
27 Wait Until Keyword Succeeds 2 min 5 sec QueryPolicyStatus ${policyName} defaultGroup apex ${pdpName} onap.policies.native.Apex
29 Create Session apexSession http://${DMAAP_IP} max_retries=1
30 ${data}= Get Binary File ${CURDIR}/data/VesEventForVnfPolicy.json
31 &{headers}= Create Dictionary Content-Type=application/json Accept=application/json
32 ${eventStartTime}= Get Current Date
33 ${resp}= POST On Session apexSession /events/unauthenticated.DCAE_POLICY_EXAMPLE_OUTPUT data=${data} headers=${headers}
34 ${eventEndTime}= Get Current Date
35 Should Be Equal As Strings ${resp.status_code} 200
36 ValidateEventExecution ${eventStartTime} ${eventEndTime} 100
38 ValidatePolicyExecutionAndEventRateHighComplexity
39 [Documentation] Validate that a high complexity policity can be executed in less than 5000ms and minimum 2 events triggered per second
40 Set Test Variable ${policyName} onap.policies.native.apex.Sampledomain
41 ${postjson}= Get File ${CURDIR}/data/${policyName}.json
42 CreatePolicy /policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies 200 ${postjson} ${policyName} 1.0.0
44 Create Session apexSession http://${APEX_EVENTS_IP} max_retries=1
45 ${data}= Get Binary File ${CURDIR}/data/event.json
46 &{headers}= Create Dictionary Content-Type=application/json Accept=application/json
48 ${eventStartTime}= Get Current Date
49 ${resp}= PUT On Session apexSession /apex/FirstConsumer/EventIn data=${data} headers=${headers}
50 ${eventEndTime}= Get Current Date
51 Should Be Equal As Strings ${resp.status_code} 200
52 ValidateEventExecution ${eventStartTime} ${eventEndTime} 2
54 ValidatePolicyExecutionAndEventRateModerateComplexity
55 [Documentation] Validate that a low complexity policity can be executed in less than 1000ms and minimum 10 events triggered per second
56 Set Test Variable ${policyName} onap.policies.apex.pnf.Test
57 ${postjson}= Get File ${CURDIR}/data/${policyName}.json
58 CreatePolicy /policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies 200 ${postjson} ${policyName} 1.0.0
60 Wait Until Keyword Succeeds 2 min 5 sec QueryPolicyStatus ${policyName} defaultGroup apex ${pdpName} onap.policies.native.Apex
62 Create Session apexSession http://${DMAAP_IP} max_retries=1
63 ${data}= Get Binary File ${CURDIR}/data/VesEventForPnfPolicy.json
64 &{headers}= Create Dictionary Content-Type=application/json Accept=application/json
65 ${eventStartTime}= Get Current Date
66 ${resp}= POST On Session apexSession /events/unauthenticated.DCAE_CL_OUTPUT data=${data} headers=${headers}
67 ${eventEndTime}= Get Current Date
68 Should Be Equal As Strings ${resp.status_code} 200
69 ValidateEventExecution ${eventStartTime} ${eventEndTime} 10
71 WaitForPrometheusServer
72 [Documentation] Sleep time to wait for Prometheus server to gather all metrics
75 ValidatePolicyExecutionTimes
76 [Documentation] Validate policy execution times using prometheus metrics
77 ValidatePolicyExecution pdpa_engine_average_execution_time_seconds{engine_instance_id="NSOApexEngine-0:0.0.1", instance="policy-apex-pdp:6969", job="apex-pdp-metrics"} 5000
78 ValidatePolicyExecution pdpa_engine_average_execution_time_seconds{engine_instance_id="MyApexEngine-0:0.0.1"} 1000
79 ValidatePolicyExecution pdpa_engine_average_execution_time_seconds{engine_instance_id="NSOApexEngine-1:0.0.1", instance="policy-apex-pdp:6969", job="apex-pdp-metrics"} 100