blob: ff02d7f84eb20f9300b804d81c07a9efa2b9ab6d [file] [log] [blame]
Gary Wu9abb61c2018-09-27 10:38:50 -07001*** Settings ***
2Library RequestsLibrary
grabinsk78ef07a2019-05-06 11:26:25 +02003Library Collections
Gary Wu9abb61c2018-09-27 10:38:50 -07004Library PrhLibrary.py
5Resource ../../../common.robot
6
7*** Keywords ***
kurczews859154a2019-04-26 11:31:51 +02008Verify PNF ready sent
9 [Arguments] ${test_case_directory}
10 ${pnf_entry}= Get Data From File ${test_case_directory}/aai-entry.json
11 ${ves_event}= Get Data From File ${test_case_directory}/ves-event.json
12 ${expected_pnf_ready_event}= Get Data From File ${test_case_directory}/expected-pnf-ready-event.json
13 Add PNF entry in AAI ${pnf_entry}
14 Set VES event in DMaaP ${ves_event}
Marcin Migdal8d000c32019-06-12 11:55:05 +020015 Wait Until Keyword Succeeds 10x 3000ms Check created PNF_READY notification ${expected_pnf_ready_event}
kurczews859154a2019-04-26 11:31:51 +020016
Joanna Jeremiczc4a9b7e2019-07-02 14:02:19 +020017Verify PNF ready sent and old logical link replaced in AAI
Joanna Jeremicz4a70dd32019-06-25 13:39:33 +020018 [Arguments] ${test_case_directory}
19 ${logical_link}= Get Data From File ${test_case_directory}/logical-link.json
Joanna Jeremiczc4a9b7e2019-07-02 14:02:19 +020020 ${expected_logical_link}= Get Data From File ${test_case_directory}/expected-logical-link.json
Joanna Jeremicz4a70dd32019-06-25 13:39:33 +020021 Add logical link entry in AAI ${logical_link}
22 Verify PNF ready sent ${test_case_directory}
Joanna Jeremiczc4a9b7e2019-07-02 14:02:19 +020023 Wait Until Keyword Succeeds 10x 3000ms Check created Logical Link ${expected_logical_link}
Joanna Jeremicz4a70dd32019-06-25 13:39:33 +020024
kurczews859154a2019-04-26 11:31:51 +020025Verify PNF ready sent and logical link created
26 [Arguments] ${test_case_directory}
27 ${expected_logical_link}= Get Data From File ${test_case_directory}/expected-logical-link.json
28 Verify PNF ready sent ${test_case_directory}
Marcin Migdal8d000c32019-06-12 11:55:05 +020029 Check created Logical Link ${expected_logical_link}
kurczews859154a2019-04-26 11:31:51 +020030
31Verify event with missing required field is logged
32 [Arguments] ${test_case_directory}
33 ${invalid_ves_event}= Get Data From File ${test_case_directory}/invalid-ves-event.json
34 Set VES event in DMaaP ${invalid_ves_event}
grabinsk8bc68e22019-06-14 13:56:17 +020035 Log Invalid ves event: ${invalid_ves_event}
binieke98a7252019-06-03 11:46:23 +020036 ${notification}= Create invalid notification ${invalid_ves_event}
37 ${error_msg}= Set Variable Incorrect json, consumerDmaapModel can not be created:
grabinsk3bee4892019-07-17 08:43:33 +020038 Wait for PRH json log entry 20s ${error_msg} ${notification}
kurczews859154a2019-04-26 11:31:51 +020039
40Verify incorrect JSON event is logged
kurczews859154a2019-04-26 11:31:51 +020041 [Arguments] ${test_case_directory}
42 ${invalid_ves_event}= Get Data From File ${test_case_directory}/invalid-ves-event.json
43 Set VES event in DMaaP ${invalid_ves_event}
grabinsk3bee4892019-07-17 08:43:33 +020044 Wait for PRH log entry 20s java.lang.IllegalStateException: Not a JSON Object
kurczews859154a2019-04-26 11:31:51 +020045
46Verify missing AAI record is logged
47 [Arguments] ${test_case_directory}
48 ${incorrect_aai_entry}= Get Data From File ${test_case_directory}/incorrect-aai-entry.json
49 ${ves_event}= Get Data From File ${test_case_directory}/ves-event.json
50 Add PNF entry in AAI ${incorrect_aai_entry}
51 Set VES event in DMaaP ${ves_event}
Tomasz Wrobel48d53d22021-08-12 10:47:36 +020052 Wait for PRH log entry 20s Request failed for URL 'https://aai:3334/aai/v23/network/pnfs/pnf/NOK6061ZW8'. Response code: 404 Not Found
kurczews859154a2019-04-26 11:31:51 +020053
54Verify AAI not responding is logged
55 [Arguments] ${test_case_directory}
56 ${ves_event}= Get Data From File ${test_case_directory}/ves-event.json
57 Ensure Container Is Exited aai_simulator
58 Set VES event in DMaaP ${ves_event}
Maciej Malewski25e7c7a2021-02-09 12:15:51 +010059 Wait for one of PRH log entries 90s connection timed out: aai Host is unreachable: aai No route to host: aai failed to resolve 'aai'
grabinsk3bee4892019-07-17 08:43:33 +020060 [Teardown] Ensure Container Is Running aai_simulator
kurczews859154a2019-04-26 11:31:51 +020061
Marcin Migdalc47ac0f2019-06-10 14:36:50 +020062Verify PNF re registration
Marcin Migdal1d1e5652019-06-21 12:17:36 +020063 [Timeout] 500s
Marcin Migdalc47ac0f2019-06-10 14:36:50 +020064 [Arguments] ${test_case_directory}
Marcin Migdald2448922019-06-17 15:22:44 +020065 ${aai_entry}= Get Data From File ${test_case_directory}/aai-entry.json
Marcin Migdal1d1e5652019-06-21 12:17:36 +020066 Log PNF Re-registration: AAI entry for AAI Simulator ${aai_entry}
Marcin Migdald2448922019-06-17 15:22:44 +020067 Add PNF entry in AAI ${aai_entry}
68 ${service_instance}= Get Data From File ${test_case_directory}/aai-entry-service-instance.json
69 Add service instance entry in AAI ${service_instance}
Joanna Jeremicz4a70dd32019-06-25 13:39:33 +020070 ${logical_link}= Get Data From File ${test_case_directory}/logical-link.json
71 Add logical link entry in AAI ${logical_link}
Marcin Migdal8d000c32019-06-12 11:55:05 +020072
73 ${ves_event}= Get Data From File ${test_case_directory}/ves-event.json
74 Set VES event in DMaaP ${ves_event}
75 ${expected_pnf_update_event}= Get Data From File ${test_case_directory}/expected-pnf-update-event.json
Marcin Migdal1d1e5652019-06-21 12:17:36 +020076 Wait Until Keyword Succeeds 10x 3000ms Check created PNF_UPDATE notification ${expected_pnf_update_event}
Joanna Jeremicz4a70dd32019-06-25 13:39:33 +020077 Wait Until Keyword Succeeds 10x 3000ms Check logical link not modified ${test_case_directory}
78
79Verify PNF ready sent when service instance non active
80 [Arguments] ${test_case_directory}
81 ${pnf_entry}= Get Data From File ${test_case_directory}/aai-entry.json
82 ${ves_event}= Get Data From File ${test_case_directory}/ves-event.json
83 ${expected_pnf_ready_event}= Get Data From File ${test_case_directory}/expected-pnf-ready-event.json
84 ${service_instance}= Get Data From File ${test_case_directory}/aai-entry-service-instance.json
85 Add PNF entry in AAI ${pnf_entry}
86 Add service instance entry in AAI ${service_instance}
87
88 Set VES event in DMaaP ${ves_event}
Joanna Jeremicz4a70dd32019-06-25 13:39:33 +020089 Wait Until Keyword Succeeds 10x 3000ms Check created PNF_READY notification ${expected_pnf_ready_event}
90
91Check logical link not modified
92 [Arguments] ${test_case_directory}
93 ${expected_logical_link}= Get Data From File ${test_case_directory}/logical-link.json
Joanna Jeremiczc4a9b7e2019-07-02 14:02:19 +020094 ${existing_logical_link}= Get Request ${aai_session} /verify/logical-link headers=${suite_headers}
95 Should Be Equal As JSON ${expected_logical_link} ${existing_logical_link.content}
Marcin Migdalc47ac0f2019-06-10 14:36:50 +020096
Marcin Migdal8d000c32019-06-12 11:55:05 +020097Check created PNF_READY notification
Joanna Jeremiczc4a9b7e2019-07-02 14:02:19 +020098 [Arguments] ${expected_event_pnf_ready_in_dmaap}
grabinskc68c2ee2019-06-19 12:36:42 +020099 ${resp}= Get Request ${dmaap_session} /verify/pnf_ready headers=${suite_headers}
kurczews859154a2019-04-26 11:31:51 +0200100 Should Be Equal As Strings ${resp.status_code} 200
Joanna Jeremiczc4a9b7e2019-07-02 14:02:19 +0200101 Should Be Equal As JSON ${resp.content} ${expected_event_pnf_ready_in_dmaap}
kurczews859154a2019-04-26 11:31:51 +0200102
Marcin Migdal8d000c32019-06-12 11:55:05 +0200103Check created PNF_UPDATE notification
Joanna Jeremiczc4a9b7e2019-07-02 14:02:19 +0200104 [Arguments] ${expected_event_pnf_update_in_dmaap}
grabinskc68c2ee2019-06-19 12:36:42 +0200105 ${resp}= Get Request ${dmaap_session} /verify/pnf_update headers=${suite_headers}
Marcin Migdal8d000c32019-06-12 11:55:05 +0200106 Log Response from DMaaP: ${resp.content}
107 Should Be Equal As Strings ${resp.status_code} 200
Joanna Jeremiczc4a9b7e2019-07-02 14:02:19 +0200108 Should Be Equal As JSON ${resp.content} ${expected_event_pnf_update_in_dmaap}
Marcin Migdal8d000c32019-06-12 11:55:05 +0200109
110Check created Logical Link
kurczews859154a2019-04-26 11:31:51 +0200111 [Arguments] ${expected_logical_link_in_aai}
Joanna Jeremiczc4a9b7e2019-07-02 14:02:19 +0200112 ${resp}= Get Request ${aai_session} /verify/logical-link headers=${suite_headers}
kurczews859154a2019-04-26 11:31:51 +0200113 Should Be Equal As Strings ${resp.status_code} 200
114 Should Be Equal As JSON ${resp.content} ${expected_logical_link_in_aai}
115
grabinsk3bee4892019-07-17 08:43:33 +0200116Wait for PRH log entry
117 [Arguments] ${timeout} ${log_entry}
118 Wait for one of PRH log entries ${timeout} ${log_entry}
119
120Wait for one of PRH log entries
121 [Arguments] ${timeout} @{log_entries}
122 [Timeout] ${timeout}
123 ${found}= Wait for one of docker log entries prh ${log_entries}
kurczews859154a2019-04-26 11:31:51 +0200124 Should Be True ${found}
125
grabinsk3bee4892019-07-17 08:43:33 +0200126Wait for PRH json log entry
127 [Arguments] ${timeout} ${prefix} ${json}
128 [Timeout] ${timeout}
129 ${found}= Wait for log entry with json message ${prefix} ${json}
binieke98a7252019-06-03 11:46:23 +0200130 Should Be True ${found}
131
kurczews859154a2019-04-26 11:31:51 +0200132Create event parsing error
133 [Arguments] ${ves_event}
134 ${notification}= Create invalid notification ${ves_event}
135 ${error_msg}= Catenate SEPARATOR= \\n |Incorrect json, consumerDmaapModel can not be created: ${notification}
136 [Return] ${error_msg}
137
138Add PNF entry in AAI
139 [Arguments] ${pnf_entry}
Gary Wu9abb61c2018-09-27 10:38:50 -0700140 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
kurczews859154a2019-04-26 11:31:51 +0200141 Log AAI url ${AAI_SIMULATOR_SETUP_URL}
grabinskc68c2ee2019-06-19 12:36:42 +0200142 ${resp}= Put Request ${aai_session} /setup/add_pnf_entry headers=${suite_headers} data=${pnf_entry}
kurczews859154a2019-04-26 11:31:51 +0200143 Should Be Equal As Strings ${resp.status_code} 200
144
Marcin Migdald2448922019-06-17 15:22:44 +0200145Add service instance entry in AAI
146 [Arguments] ${aai_service_instance}
147 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
148 Log AAI url ${AAI_SIMULATOR_SETUP_URL}
Joanna Jeremiczbbabae72019-08-19 09:24:53 +0200149 ${resp}= Put Request ${aai_session} /setup/add_service_instance headers=${suite_headers} data=${aai_service_instance}
Marcin Migdald2448922019-06-17 15:22:44 +0200150 Should Be Equal As Strings ${resp.status_code} 200
151
Joanna Jeremicz4a70dd32019-06-25 13:39:33 +0200152Add logical link entry in AAI
153 [Arguments] ${logical_link}
154 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
155 Log AAI url ${AAI_SIMULATOR_SETUP_URL}
156 ${resp}= Put Request ${aai_session} /setup/add_logical_link headers=${suite_headers} data=${logical_link}
157 Should Be Equal As Strings ${resp.status_code} 200
158
kurczews859154a2019-04-26 11:31:51 +0200159Set VES event in DMaaP
160 [Arguments] ${ves_event}
grabinskc68c2ee2019-06-19 12:36:42 +0200161 ${resp}= Put Request ${dmaap_session} /setup/ves_event headers=${suite_headers} data=${ves_event}
kurczews859154a2019-04-26 11:31:51 +0200162 Should Be Equal As Strings ${resp.status_code} 200
163
164Should Be Equal As JSON
grabinsk08a9c632019-05-23 13:34:38 +0200165 [Arguments] ${actual} ${expected}
166 Log EXPECTED: ${expected}
167 Log ACTUAL: ${actual}
168 ${expected_json}= Evaluate json.loads("""${expected}""") json
169 ${actual_json}= Evaluate json.loads("""${actual}""") json
170 Should Be Equal ${actual_json} ${expected_json}
Gary Wu9abb61c2018-09-27 10:38:50 -0700171
pkaras55d36862018-10-17 15:08:34 +0200172Reset Simulators
173 Reset AAI simulator
pkarasc7abba82018-10-22 12:22:35 +0200174 Reset DMaaP simulator
Gary Wu9abb61c2018-09-27 10:38:50 -0700175
pkaras55d36862018-10-17 15:08:34 +0200176Reset AAI simulator
grabinskc68c2ee2019-06-19 12:36:42 +0200177 ${resp}= Post Request ${aai_session} /reset
pkaras55d36862018-10-17 15:08:34 +0200178 Should Be Equal As Strings ${resp.status_code} 200
pkarasc7abba82018-10-22 12:22:35 +0200179
180Reset DMaaP simulator
grabinskc68c2ee2019-06-19 12:36:42 +0200181 ${resp}= Post Request ${dmaap_session} /reset
Marcin Migdalfba99a52019-04-15 14:36:45 +0200182 Should Be Equal As Strings ${resp.status_code} 200
183
micdzied9c7d8f02019-06-17 14:08:27 +0200184
185Verify change logging level
grabinskad1421e2019-06-21 15:08:21 +0200186 ${logger}= Set Variable org.onap.dcaegen2.services.prh.controllers.AppInfoController
187 Change logging level ${logger} TRACE
188 Verify logging level ${logger} TRACE
micdzied9c7d8f02019-06-17 14:08:27 +0200189 Verify logs with heartbeat
grabinskad1421e2019-06-21 15:08:21 +0200190 [Teardown] Change logging level ${logger} INFO
micdzied9c7d8f02019-06-17 14:08:27 +0200191
192Change logging level
grabinskad1421e2019-06-21 15:08:21 +0200193 [Arguments] ${logger} ${log_level}
194 ${request_body}= Create Dictionary configuredLevel=${log_level}
195 ${resp}= Post Request prh_session /actuator/loggers/${logger} json=${request_body}
196 Should Be Equal As Integers ${resp.status_code} 204
micdzied9c7d8f02019-06-17 14:08:27 +0200197
198Verify logging level
grabinskad1421e2019-06-21 15:08:21 +0200199 [Arguments] ${logger} ${expected_log_level}
200 ${resp}= Get Request prh_session /actuator/loggers/${logger}
201 Should Be Equal As Integers ${resp.status_code} 200
202 Log ${resp.content}
203 Should Be Equal As Strings ${resp.json()["configuredLevel"]} ${expected_log_level} ignore_case=true
micdzied9c7d8f02019-06-17 14:08:27 +0200204
205Verify logs with heartbeat
grabinskc68c2ee2019-06-19 12:36:42 +0200206 Get Request prh_session /heartbeat
grabinsk3bee4892019-07-17 08:43:33 +0200207 Verify PRH logs contains Heartbeat request received
208
209Verify PRH logs contains
210 [Arguments] ${expected_entry}
211 ${log}= Get docker logs since test start prh
Maciej Malewski25e7c7a2021-02-09 12:15:51 +0100212 Should Contain ${log} ${expected_entry}