blob: 9fdbc12e6f346dafcd6b85ab03d990a7c79ba5c5 [file] [log] [blame]
Gary Wu9abb61c2018-09-27 10:38:50 -07001*** Settings ***
2Library Collections
3Library RequestsLibrary
4Library OperatingSystem
5Library json
6
7*** Test Cases ***
8
a.sreekumar7d80c382019-05-07 13:36:39 +00009Healthcheck
10 [Documentation] Runs Apex PDP Health check
11 ${auth}= Create List healthcheck zb!XztG34
12 Log Creating session https://${APEX_IP}:6969
13 ${session}= Create Session policy https://${APEX_IP}:6969 auth=${auth}
14 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
15 ${resp}= Get Request policy /policy/apex-pdp/v1/healthcheck headers=${headers}
16 Log Received response from policy1 ${resp.text}
17 Should Be Equal As Strings ${resp.status_code} 200
18 Should Be Equal As Strings ${resp.json()['code']} 200
19
20ExecuteApexPolicy
Ram Krishna Verma6bddbf32020-05-04 15:40:59 -040021 Wait Until Keyword Succeeds 2 min 5 sec CreatePolicy
22 Wait Until Keyword Succeeds 2 min 5 sec DeployPolicy
a.sreekumar7d80c382019-05-07 13:36:39 +000023 Wait Until Keyword Succeeds 4 min 10 sec RunEventOnApexEngine
24
25*** Keywords ***
26
Ram Krishna Verma6bddbf32020-05-04 15:40:59 -040027CreatePolicy
28 [Documentation] Create a new Apex policy
a.sreekumar7d80c382019-05-07 13:36:39 +000029 ${auth}= Create List healthcheck zb!XztG34
Ram Krishna Verma6bddbf32020-05-04 15:40:59 -040030 ${postjson}= Get file ${CURDIR}/data/onap.policies.native.Apex.tosca.json
a.sreekumar7d80c382019-05-07 13:36:39 +000031 Log Creating session https://${POLICY_API_IP}:6969
32 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth}
33 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
Ram Krishna Verma6bddbf32020-05-04 15:40:59 -040034 ${resp}= Post Request policy /policy/api/v1/policytypes/onap.policies.native.Apex/versions/1.0.0/policies data=${postjson} headers=${headers}
a.sreekumar7d80c382019-05-07 13:36:39 +000035 Log Received response from policy4 ${resp.text}
36 ${postjsonobject} To Json ${postjson}
37 Should Be Equal As Strings ${resp.status_code} 200
38 Dictionary Should Contain Key ${resp.json()} tosca_definitions_version
39 Dictionary Should Contain Key ${postjsonobject} tosca_definitions_version
40
Ram Krishna Verma6bddbf32020-05-04 15:40:59 -040041DeployPolicy
42 [Documentation] Deploy the policy in apex-pdp engine
a.sreekumar7d80c382019-05-07 13:36:39 +000043 ${auth}= Create List healthcheck zb!XztG34
44 ${postjson}= Get file ${CURDIR}/data/pdp_update.json
45 Log Creating session https://${POLICY_PAP_IP}:6969
46 ${session}= Create Session policy https://${POLICY_PAP_IP}:6969 auth=${auth}
47 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
Jim Hahn25721ec2019-12-09 09:56:39 -050048 ${resp}= Post Request policy /policy/pap/v1/pdps/deployments/batch data=${postjson} headers=${headers}
a.sreekumar7d80c382019-05-07 13:36:39 +000049 Log Received response from policy5 ${resp.text}
50 ${postjsonobject} To Json ${postjson}
51 Should Be Equal As Strings ${resp.status_code} 200
52
53RunEventOnApexEngine
54 Create Session apexSession http://${APEX_IP}:23324 max_retries=1
Gary Wu9abb61c2018-09-27 10:38:50 -070055 ${data}= Get Binary File ${CURDIR}${/}data${/}event.json
56 &{headers}= Create Dictionary Content-Type=application/json Accept=application/json
57 ${resp}= Put Request apexSession /apex/FirstConsumer/EventIn data=${data} headers=${headers}
58 Should Be Equal As Strings ${resp.status_code} 200