fdd9dc4fd2f2c97c5321c84988c558c04d694bfa
[testsuite.git] / robot / resources / test_templates / pnf_registration_without_SO_template.robot
1 *** Settings ***
2 Documentation     PNF Registration Handler (PRH) test cases
3 Resource        ../aai/aai_interface.robot
4 Resource        ../mr_interface.robot
5 Resource        ../json_templater.robot
6 Library         OpenstackLibrary
7 Library         OperatingSystem
8 Library         UUID
9 Library         Collections
10 Library         JSONUtils
11 Library         HTTPUtils
12
13
14 *** Variables ***
15 ${aai_so_registration_entry_template}=  robot/assets/templates/aai/add_pnf_registration_info.template
16 ${pnf_ves_integration_request}=  robot/assets/templates/ves/pnf_registration_request.template
17 ${DMAAP_MESSAGE_ROUTER_UNAUTHENTICATED_PNF_PATH}  /events/unauthenticated.PNF_READY/2/1
18 ${VES_ENDPOINT}     http://${GLOBAL_DNS_VES_NAME}:${GLOBAL_VES_SERVER_PORT}
19 ${VES_data_path}   /eventListener/v7
20
21
22 *** Keywords ***
23 Create A&AI antry without SO and succesfully registrate PNF
24     [Documentation]   Test case template for create A&AI antry without SO and succesfully registrate PNF
25     [Arguments]   ${PNF_entry_dict}
26     Create PNF initial entry in A&AI  ${PNF_entry_dict}
27     Send VES integration request  ${PNF_entry_dict}
28     Verify PNF Integration Request in A&AI  ${PNF_entry_dict}
29
30 Create PNF initial entry in A&AI
31     [Documentation]   Creates PNF initial entry in A&AI registry. Entry contains only correlation id (pnf-name)
32     [Arguments]  ${PNF_entry_dict}
33     ${template}=  Fill Json Template File  ${aai_so_registration_entry_template}  ${PNF_entry_dict}
34     Log  Filled A&AI entry template ${template}
35     ${correlation_id}=  Get From Dictionary  ${PNF_entry_dict}  correlation_id
36     ${del_resp}=  Delete A&AI Entity  /network/pnfs/pnf/${PNF_entry_dict.correlation_id}
37     Log  Removing existing entry "${PNF_entry_dict.correlation_id}" from A&AI registry
38     ${put_resp}=  Run A&AI Put Request  /aai/v11/network/pnfs/pnf/${PNF_entry_dict.correlation_id}  ${template}
39     Log  Adding new entry with correlation ID "${PNF_entry_dict.correlation_id}" to A&AI registry (empty IPv4 and IPv6 address)
40
41 Send VES integration request
42     [Documentation]   Send VES integration request. Request contains correlation id (sourceName), oamV4IpAddress and oamV6IpAddress
43     [Arguments]  ${PNF_entry_dict}
44     ${template}=  Fill Json Template File  ${pnf_ves_integration_request}  ${PNF_entry_dict}
45     ${post_resp}=  Run VES HTTP Post Request   ${template}
46     Should Be Equal As Strings  ${post_resp.status_code}        202
47     Log  VES integration request has been send
48
49 Verify PNF integration request in A&AI
50     [Documentation]   Verify if PNF integration request entries are present in A&AI
51     [Arguments]  ${PNF_entry_dict}
52     Wait Until Keyword Succeeds  10x  5s  Query PNF A&AI updated entry  ${PNF_entry_dict}
53     Log  PNF integration request in A&AI has been verified and contains all necessary entries
54
55 Verify PNF integration request in MR
56     [Documentation]   Verify if PNF integration request entries are present in MR unauthenticated.PNF_READY/ topic
57     [Arguments]  ${PNF_entry_dict}
58     Wait Until Keyword Succeeds  10x  1s  Query PNF MR entry  ${PNF_entry_dict}
59     Log  PNF integration request in MR has been verified and contains all necessary entries
60
61 Query PNF A&AI updated entry
62     [Documentation]   Query PNF A&AI updated entry
63     [Arguments]  ${PNF_entry_dict}
64     ${get_resp}=  Run A&AI Get Request  /aai/v11/network/pnfs/pnf/${PNF_entry_dict.correlation_id}
65     Should Be Equal As Strings  ${get_resp.status_code}        200
66     ${json_resp}=  Set Variable  ${get_resp.json()}
67     Log  JSON recieved from A&AI endpoint ${json_resp}
68     Should Be Equal As Strings  ${json_resp["ipaddress-v4-oam"]}      ${PNF_entry_dict.PNF_IPv4_address}
69     Should Be Equal As Strings  ${json_resp["ipaddress-v6-oam"]}       ${PNF_entry_dict.PNF_IPv6_address}
70     Should Be Equal As Strings  ${json_resp["pnf-name"]}       ${PNF_entry_dict.correlation_id}
71     Log  PNF integration request in A&AI has been verified and contains all necessary entries
72
73 Query PNF MR entry
74     [Documentation]   Query PNF MR updated entry
75     [Arguments]  ${PNF_entry_dict}
76     ${get_resp}=  Run MR Get Request  ${DMAAP_MESSAGE_ROUTER_UNAUTHENTICATED_PNF_PATH}
77     Should Be Equal As Strings  ${get_resp.status_code}        200
78     ${json_resp_item}=  Get From List  ${get_resp.json()}  0
79     ${json}=    evaluate    json.loads('${json_resp_item}')    json
80     Log  JSON recieved from MR ${DMAAP_MESSAGE_ROUTER_UNAUTHENTICATED_PNF_PATH} endpoint ${json}
81     Should Be Equal As Strings  ${json["ipaddress-v4-oam"]}      ${PNF_entry_dict.PNF_IPv4_address}
82     Should Be Equal As Strings  ${json["ipaddress-v6-oam"]}       ${PNF_entry_dict.PNF_IPv6_address}
83     Should Be Equal As Strings  ${json["correlationId"]}       ${PNF_entry_dict.correlation_id}
84     Log  PNF integration request in MR has been verified and contains all necessary entries
85
86 Run VES HTTP Post Request
87     [Documentation]    Runs a VES Post request
88     [Arguments]     ${data}
89     Disable Warnings
90     ${session}=    Create Session       ves     ${VES_ENDPOINT}
91     ${headers}=  Create Dictionary   Accept=application/json    Content-Type=application/json
92     ${post_resp}=       Post Request    ves     ${VES_data_path}      data=${data}    headers=${headers}
93     Log  PNF integration request ${data}
94     Should Be Equal As Strings  ${post_resp.status_code}        202
95     Log  VES has accepted event with status code ${post_resp.status_code}
96     [Return]  ${post_resp}
97
98 Cleanup PNF entry in A&AI
99     [Documentation]   Creates PNF initial entry in A&AI registry
100     [Arguments]  ${PNF_entry_dict}
101     ${del_resp}=  Delete A&AI Entity  /network/pnfs/pnf/${PNF_entry_dict.correlation_id}
102     Log    Teardown complete