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
28 GetKafkaTopic apex-cl-mgt2
29 ${data}= Get Binary File ${CURDIR}/data/VesEventForVnfPolicy.json
30 ${eventStartTime}= Get Current Date
31 ${resp}= Run Process ${CURDIR}/kafka_producer.py unauthenticated.dcae_policy_example_output ${data} ${KAFKA_IP}
32 ${eventEndTime}= Get Current Date
33 ValidateEventExecution ${eventStartTime} ${eventEndTime} 100
35 ValidatePolicyExecutionAndEventRateHighComplexity
36 [Documentation] Validate that a high complexity policity can be executed in less than 5000ms and minimum 2 events triggered per second
37 Set Test Variable ${policyName} onap.policies.native.apex.Sampledomain
38 ${postjson}= Get File ${CURDIR}/data/${policyName}.json
39 CreatePolicy /policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies 200 ${postjson} ${policyName} 1.0.0
41 Create Session apexSession http://${APEX_EVENTS_IP} max_retries=1
42 ${data}= Get Binary File ${CURDIR}/data/event.json
43 &{headers}= Create Dictionary Content-Type=application/json Accept=application/json
45 ${eventStartTime}= Get Current Date
46 ${resp}= PUT On Session apexSession /apex/FirstConsumer/EventIn data=${data} headers=${headers}
47 ${eventEndTime}= Get Current Date
48 Should Be Equal As Strings ${resp.status_code} 200
49 ValidateEventExecution ${eventStartTime} ${eventEndTime} 2
51 ValidatePolicyExecutionAndEventRateModerateComplexity
52 [Documentation] Validate that a low complexity policity can be executed in less than 1000ms and minimum 10 events triggered per second
53 Set Test Variable ${policyName} onap.policies.apex.pnf.Test
54 ${postjson}= Get File ${CURDIR}/data/${policyName}.json
55 CreatePolicy /policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies 200 ${postjson} ${policyName} 1.0.0
57 Wait Until Keyword Succeeds 2 min 5 sec QueryPolicyStatus ${policyName} defaultGroup apex ${pdpName} onap.policies.native.Apex
58 GetKafkaTopic apex-cl-mgt
59 ${data}= Get Binary File ${CURDIR}/data/VesEventForPnfPolicy.json
60 ${eventStartTime}= Get Current Date
61 ${resp}= Run Process ${CURDIR}/kafka_producer.py unauthenticated.dcae_cl_output ${data} ${KAFKA_IP}
62 ${eventEndTime}= Get Current Date
63 ValidateEventExecution ${eventStartTime} ${eventEndTime} 10
65 WaitForPrometheusServer
66 [Documentation] Sleep time to wait for Prometheus server to gather all metrics
69 ValidatePolicyExecutionTimes
70 [Documentation] Validate policy execution times using prometheus metrics
71 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
72 ValidatePolicyExecution pdpa_engine_average_execution_time_seconds{engine_instance_id="MyApexEngine-0:0.0.1"} 1000
73 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