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