blob: 13d58957b22cb77ec0a6196bcc8f30fcbd1d86cf [file] [log] [blame]
waynedunicane4ff7e52023-03-01 09:07:31 +00001*** Settings ***
2Library Collections
3Library RequestsLibrary
4Library OperatingSystem
5Library DateTime
6Library Process
7Library json
8Resource ${CURDIR}/common-library.robot
9Resource ${CURDIR}/apex-pdp-common.robot
10
11*** Test Cases ***
12Healthcheck
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']}
18
19ValidatePolicyExecutionAndEventRateLowComplexity
20 [Documentation] Validate that a moderate complexity policity can be executed in less than 100ms and minimum 30 events triggered per second
21 Set Test Variable ${policyName} onap.policies.apex.pnf.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 DeployPolicy
25 Wait Until Keyword Succeeds 2 min 5 sec QueryPolicyStatus ${policyName} defaultGroup apex ${pdpName} onap.policies.native.Apex
26 GetTopic APEX-CL-MGT
27 Create Session apexSession http://${DMAAP_IP} max_retries=1
28 ${data}= Get Binary File ${CURDIR}/data/VesEventForPnfPolicy.json
29 &{headers}= Create Dictionary Content-Type=application/json Accept=application/json
30 ${eventStartTime}= Get Current Date
31 ${resp}= POST On Session apexSession /events/unauthenticated.DCAE_CL_OUTPUT data=${data} headers=${headers}
32 Should Be Equal As Strings ${resp.status_code} 200
33 ${eventEndTime}= Get Current Date
34 ValidateEventExecution ${eventStartTime} ${eventEndTime} 30
35
36ValidatePolicyExecutionAndEventRateHighComplexity
37 [Documentation] Validate that a high complexity policity can be executed in less than 5000ms and minimum 0.6 events triggered per second
38 Set Test Variable ${policyName} onap.policies.apex.pnf.metadataSet.Test
39 ${postjson}= Get File ${CURDIR}/data/${policyName}.json
40 CreatePolicy /policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies 200 ${postjson} ${policyName} 1.0.0
41 ${postjson}= Get File ${CURDIR}/data/onap.pnf.metadataSet.Test.json
42 CreateNodeTemplate /policy/api/v1/nodetemplates 200 ${postjson} 1
43 DeployPolicy
44 Wait Until Keyword Succeeds 2 min 5 sec QueryPolicyStatus ${policyName} defaultGroup apex ${pdpName} onap.policies.native.Apex
45 GetTopic APEX-CL-MGT2
46 Create Session apexSession http://${DMAAP_IP} max_retries=1
47 ${data}= Get Binary File ${CURDIR}/data/VesEventForVnfPolicy.json
48 &{headers}= Create Dictionary Content-Type=application/json Accept=application/json
49 ${eventStartTime}= Get Current Date
50 ${resp}= POST On Session apexSession /events/unauthenticated.DCAE_POLICY_EXAMPLE_OUTPUT data=${data} headers=${headers}
51 Should Be Equal As Strings ${resp.status_code} 200
52 ${eventEndTime}= Get Current Date
53 ValidateEventExecution ${eventStartTime} ${eventEndTime} 0.6
54
55ValidatePolicyExecutionAndEventRateModerateComplexity
56 [Documentation] Validate that a low complexity policity can be executed in less than 1000ms and minimum 3 events triggered per second
57 Set Test Variable ${policyName} onap.policies.native.apex.Sampledomain
58 ${postjson}= Get File ${CURDIR}/data/${policyName}.json
59 CreatePolicy /policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies 200 ${postjson} ${policyName} 1.0.0
60 DeployPolicy
61 #Wait Until Keyword Succeeds 4 min 5 sec RunEventOnApexEngine
62 Create Session apexSession http://${APEX_EVENTS_IP} max_retries=1
63 ${data}= Get Binary File ${CURDIR}/data/event.json
64 &{headers}= Create Dictionary Content-Type=application/json Accept=application/json
65 Sleep 60s
66 ${eventStartTime}= Get Current Date
67 ${resp}= PUT On Session apexSession /apex/FirstConsumer/EventIn data=${data} headers=${headers}
68 Should Be Equal As Strings ${resp.status_code} 200
69 ${eventEndTime}= Get Current Date
70 ValidateEventExecution ${eventStartTime} ${eventEndTime} 3
71
72WaitForPrometheusServer
73 [Documentation] Sleep time to wait for Prometheus server to gather all metrics
74 Sleep 2 minutes
75
76ValidatePolicyExecutionTimes
77 [Documentation] Validate policy execution times using prometheus metrics
78 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
79 ValidatePolicyExecution pdpa_engine_average_execution_time_seconds{engine_instance_id="MyApexEngine-0:0.0.1"} 1000
80 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