[SO] SO release image for CSIT testing
[integration/csit.git] / tests / policy / apex-pdp / apex-pdp-test.robot
1 *** Settings ***
2 Library     Collections
3 Library     RequestsLibrary
4 Library     OperatingSystem
5 Library     json
6
7 *** Test Cases ***
8
9 Healthcheck
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
20 ExecuteApexPolicy
21      Wait Until Keyword Succeeds    2 min    5 sec    CreateOperationalPolicyType
22      Wait Until Keyword Succeeds    2 min    5 sec    CreateNewOperationalPolicy
23      Wait Until Keyword Succeeds    2 min    5 sec    DeployOperationalPolicy
24      Wait Until Keyword Succeeds    4 min    10 sec    RunEventOnApexEngine
25
26 *** Keywords ***
27
28 CreateOperationalPolicyType
29      [Documentation]    Create Operational Policy Type
30      ${auth}=    Create List    healthcheck    zb!XztG34
31      ${postjson}=  Get file  ${CURDIR}/data/onap.policies.controlloop.operational.Apex.json
32      Log    Creating session https://${POLICY_API_IP}:6969
33      ${session}=    Create Session      policy  https://${POLICY_API_IP}:6969   auth=${auth}
34      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
35      ${resp}=   Post Request   policy  /policy/api/v1/policytypes  data=${postjson}   headers=${headers}
36      Log    Received response from policy2 ${resp.text}
37      Should Be Equal As Strings    ${resp.status_code}     200
38      ${postjsonobject}   To Json    ${postjson}
39      Dictionary Should Contain Key    ${resp.json()}    tosca_definitions_version
40      Dictionary Should Contain Key    ${postjsonobject}    tosca_definitions_version
41
42 CreateNewOperationalPolicy
43      [Documentation]    Create a new Operational Apex policy
44      ${auth}=    Create List    healthcheck    zb!XztG34
45      ${postjson}=  Get file  ${CURDIR}/data/onap.policies.controlloop.operational.Apex.tosca.json
46      Log    Creating session https://${POLICY_API_IP}:6969
47      ${session}=    Create Session      policy  https://${POLICY_API_IP}:6969   auth=${auth}
48      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
49      ${resp}=   Post Request   policy  /policy/api/v1/policytypes/onap.policies.controlloop.operational.Apex/versions/1.0.0/policies  data=${postjson}   headers=${headers}
50      Log    Received response from policy4 ${resp.text}
51      ${postjsonobject}   To Json    ${postjson}
52      Should Be Equal As Strings    ${resp.status_code}     200
53      Dictionary Should Contain Key    ${resp.json()}    tosca_definitions_version
54      Dictionary Should Contain Key    ${postjsonobject}    tosca_definitions_version
55
56 DeployOperationalPolicy
57      [Documentation]    Make the PAP to initiate a PDP_UPDATE with policies
58      ${auth}=    Create List    healthcheck    zb!XztG34
59      ${postjson}=  Get file  ${CURDIR}/data/pdp_update.json
60      Log    Creating session https://${POLICY_PAP_IP}:6969
61      ${session}=    Create Session      policy  https://${POLICY_PAP_IP}:6969   auth=${auth}
62      ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
63      ${resp}=   Post Request   policy  /policy/pap/v1/pdps/deployments/batch  data=${postjson}   headers=${headers}
64      Log    Received response from policy5 ${resp.text}
65      ${postjsonobject}   To Json    ${postjson}
66      Should Be Equal As Strings    ${resp.status_code}     200
67
68 RunEventOnApexEngine
69     Create Session   apexSession  http://${APEX_IP}:23324   max_retries=1
70     ${data}=    Get Binary File     ${CURDIR}${/}data${/}event.json
71     &{headers}=  Create Dictionary    Content-Type=application/json    Accept=application/json
72     ${resp}=    Put Request    apexSession    /apex/FirstConsumer/EventIn    data=${data}   headers=${headers}
73     Should Be Equal As Strings    ${resp.status_code}   200