blob: 1e6d31053cb5454999048ef30a0160cdb9f0467e [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}
15 Wait Until Keyword Succeeds 10x 3000ms Check CBS ready
Marcin Migdal8d000c32019-06-12 11:55:05 +020016 Wait Until Keyword Succeeds 10x 3000ms Check created PNF_READY notification ${expected_pnf_ready_event}
kurczews859154a2019-04-26 11:31:51 +020017
Joanna Jeremiczc4a9b7e2019-07-02 14:02:19 +020018Verify PNF ready sent and old logical link replaced in AAI
Joanna Jeremicz4a70dd32019-06-25 13:39:33 +020019 [Arguments] ${test_case_directory}
20 ${logical_link}= Get Data From File ${test_case_directory}/logical-link.json
Joanna Jeremiczc4a9b7e2019-07-02 14:02:19 +020021 ${expected_logical_link}= Get Data From File ${test_case_directory}/expected-logical-link.json
Joanna Jeremicz4a70dd32019-06-25 13:39:33 +020022 Add logical link entry in AAI ${logical_link}
23 Verify PNF ready sent ${test_case_directory}
Joanna Jeremiczc4a9b7e2019-07-02 14:02:19 +020024 Wait Until Keyword Succeeds 10x 3000ms Check created Logical Link ${expected_logical_link}
Joanna Jeremicz4a70dd32019-06-25 13:39:33 +020025
kurczews859154a2019-04-26 11:31:51 +020026Verify PNF ready sent and logical link created
27 [Arguments] ${test_case_directory}
28 ${expected_logical_link}= Get Data From File ${test_case_directory}/expected-logical-link.json
29 Verify PNF ready sent ${test_case_directory}
Marcin Migdal8d000c32019-06-12 11:55:05 +020030 Check created Logical Link ${expected_logical_link}
kurczews859154a2019-04-26 11:31:51 +020031
32Verify event with missing required field is logged
33 [Arguments] ${test_case_directory}
34 ${invalid_ves_event}= Get Data From File ${test_case_directory}/invalid-ves-event.json
35 Set VES event in DMaaP ${invalid_ves_event}
grabinsk8bc68e22019-06-14 13:56:17 +020036 Log Invalid ves event: ${invalid_ves_event}
binieke98a7252019-06-03 11:46:23 +020037 ${notification}= Create invalid notification ${invalid_ves_event}
38 ${error_msg}= Set Variable Incorrect json, consumerDmaapModel can not be created:
grabinsk3bee4892019-07-17 08:43:33 +020039 Wait for PRH json log entry 20s ${error_msg} ${notification}
kurczews859154a2019-04-26 11:31:51 +020040
41Verify incorrect JSON event is logged
kurczews859154a2019-04-26 11:31:51 +020042 [Arguments] ${test_case_directory}
43 ${invalid_ves_event}= Get Data From File ${test_case_directory}/invalid-ves-event.json
44 Set VES event in DMaaP ${invalid_ves_event}
grabinsk3bee4892019-07-17 08:43:33 +020045 Wait for PRH log entry 20s java.lang.IllegalStateException: Not a JSON Object
kurczews859154a2019-04-26 11:31:51 +020046
47Verify missing AAI record is logged
48 [Arguments] ${test_case_directory}
49 ${incorrect_aai_entry}= Get Data From File ${test_case_directory}/incorrect-aai-entry.json
50 ${ves_event}= Get Data From File ${test_case_directory}/ves-event.json
51 Add PNF entry in AAI ${incorrect_aai_entry}
52 Set VES event in DMaaP ${ves_event}
grabinsk3bee4892019-07-17 08:43:33 +020053 Wait for PRH log entry 20s Request failed for URL 'https://aai:3334/aai/v12/network/pnfs/pnf/NOK6061ZW8'. Response code: 404 Not Found
kurczews859154a2019-04-26 11:31:51 +020054
55Verify AAI not responding is logged
56 [Arguments] ${test_case_directory}
57 ${ves_event}= Get Data From File ${test_case_directory}/ves-event.json
58 Ensure Container Is Exited aai_simulator
59 Set VES event in DMaaP ${ves_event}
grabinsk3bee4892019-07-17 08:43:33 +020060 Wait for one of PRH log entries 90s connection timed out: aai Host is unreachable: aai
61 [Teardown] Ensure Container Is Running aai_simulator
kurczews859154a2019-04-26 11:31:51 +020062
Marcin Migdalc47ac0f2019-06-10 14:36:50 +020063Verify PNF re registration
Marcin Migdal1d1e5652019-06-21 12:17:36 +020064 [Timeout] 500s
Marcin Migdalc47ac0f2019-06-10 14:36:50 +020065 [Arguments] ${test_case_directory}
Marcin Migdald2448922019-06-17 15:22:44 +020066 ${aai_entry}= Get Data From File ${test_case_directory}/aai-entry.json
Marcin Migdal1d1e5652019-06-21 12:17:36 +020067 Log PNF Re-registration: AAI entry for AAI Simulator ${aai_entry}
Marcin Migdald2448922019-06-17 15:22:44 +020068 Add PNF entry in AAI ${aai_entry}
69 ${service_instance}= Get Data From File ${test_case_directory}/aai-entry-service-instance.json
70 Add service instance entry in AAI ${service_instance}
Joanna Jeremicz4a70dd32019-06-25 13:39:33 +020071 ${logical_link}= Get Data From File ${test_case_directory}/logical-link.json
72 Add logical link entry in AAI ${logical_link}
Marcin Migdal8d000c32019-06-12 11:55:05 +020073
74 ${ves_event}= Get Data From File ${test_case_directory}/ves-event.json
75 Set VES event in DMaaP ${ves_event}
76 ${expected_pnf_update_event}= Get Data From File ${test_case_directory}/expected-pnf-update-event.json
Marcin Migdal1d1e5652019-06-21 12:17:36 +020077 Wait Until Keyword Succeeds 10x 3000ms Check created PNF_UPDATE notification ${expected_pnf_update_event}
Joanna Jeremicz4a70dd32019-06-25 13:39:33 +020078 Wait Until Keyword Succeeds 10x 3000ms Check logical link not modified ${test_case_directory}
79
80Verify PNF ready sent when service instance non active
81 [Arguments] ${test_case_directory}
82 ${pnf_entry}= Get Data From File ${test_case_directory}/aai-entry.json
83 ${ves_event}= Get Data From File ${test_case_directory}/ves-event.json
84 ${expected_pnf_ready_event}= Get Data From File ${test_case_directory}/expected-pnf-ready-event.json
85 ${service_instance}= Get Data From File ${test_case_directory}/aai-entry-service-instance.json
86 Add PNF entry in AAI ${pnf_entry}
87 Add service instance entry in AAI ${service_instance}
88
89 Set VES event in DMaaP ${ves_event}
90 Wait Until Keyword Succeeds 10x 3000ms Check CBS ready
91 Wait Until Keyword Succeeds 10x 3000ms Check created PNF_READY notification ${expected_pnf_ready_event}
92
93Check logical link not modified
94 [Arguments] ${test_case_directory}
95 ${expected_logical_link}= Get Data From File ${test_case_directory}/logical-link.json
Joanna Jeremiczc4a9b7e2019-07-02 14:02:19 +020096 ${existing_logical_link}= Get Request ${aai_session} /verify/logical-link headers=${suite_headers}
97 Should Be Equal As JSON ${expected_logical_link} ${existing_logical_link.content}
Marcin Migdalc47ac0f2019-06-10 14:36:50 +020098
kurczews859154a2019-04-26 11:31:51 +020099Check CBS ready
grabinskc68c2ee2019-06-19 12:36:42 +0200100 ${resp}= Get Request ${consul_session} /v1/catalog/services
kurczews859154a2019-04-26 11:31:51 +0200101 Should Be Equal As Strings ${resp.status_code} 200
grabinsk78ef07a2019-05-06 11:26:25 +0200102 Log Service Catalog response: ${resp.content}
103 Dictionary Should Contain Key ${resp.json()} cbs |Consul service catalog should contain CBS entry
kurczews859154a2019-04-26 11:31:51 +0200104
Marcin Migdal8d000c32019-06-12 11:55:05 +0200105Check created PNF_READY notification
Joanna Jeremiczc4a9b7e2019-07-02 14:02:19 +0200106 [Arguments] ${expected_event_pnf_ready_in_dmaap}
grabinskc68c2ee2019-06-19 12:36:42 +0200107 ${resp}= Get Request ${dmaap_session} /verify/pnf_ready headers=${suite_headers}
kurczews859154a2019-04-26 11:31:51 +0200108 Should Be Equal As Strings ${resp.status_code} 200
Joanna Jeremiczc4a9b7e2019-07-02 14:02:19 +0200109 Should Be Equal As JSON ${resp.content} ${expected_event_pnf_ready_in_dmaap}
kurczews859154a2019-04-26 11:31:51 +0200110
Marcin Migdal8d000c32019-06-12 11:55:05 +0200111Check created PNF_UPDATE notification
Joanna Jeremiczc4a9b7e2019-07-02 14:02:19 +0200112 [Arguments] ${expected_event_pnf_update_in_dmaap}
grabinskc68c2ee2019-06-19 12:36:42 +0200113 ${resp}= Get Request ${dmaap_session} /verify/pnf_update headers=${suite_headers}
Marcin Migdal8d000c32019-06-12 11:55:05 +0200114 Log Response from DMaaP: ${resp.content}
115 Should Be Equal As Strings ${resp.status_code} 200
Joanna Jeremiczc4a9b7e2019-07-02 14:02:19 +0200116 Should Be Equal As JSON ${resp.content} ${expected_event_pnf_update_in_dmaap}
Marcin Migdal8d000c32019-06-12 11:55:05 +0200117
118Check created Logical Link
kurczews859154a2019-04-26 11:31:51 +0200119 [Arguments] ${expected_logical_link_in_aai}
Joanna Jeremiczc4a9b7e2019-07-02 14:02:19 +0200120 ${resp}= Get Request ${aai_session} /verify/logical-link headers=${suite_headers}
kurczews859154a2019-04-26 11:31:51 +0200121 Should Be Equal As Strings ${resp.status_code} 200
122 Should Be Equal As JSON ${resp.content} ${expected_logical_link_in_aai}
123
grabinsk3bee4892019-07-17 08:43:33 +0200124Wait for PRH log entry
125 [Arguments] ${timeout} ${log_entry}
126 Wait for one of PRH log entries ${timeout} ${log_entry}
127
128Wait for one of PRH log entries
129 [Arguments] ${timeout} @{log_entries}
130 [Timeout] ${timeout}
131 ${found}= Wait for one of docker log entries prh ${log_entries}
kurczews859154a2019-04-26 11:31:51 +0200132 Should Be True ${found}
133
grabinsk3bee4892019-07-17 08:43:33 +0200134Wait for PRH json log entry
135 [Arguments] ${timeout} ${prefix} ${json}
136 [Timeout] ${timeout}
137 ${found}= Wait for log entry with json message ${prefix} ${json}
binieke98a7252019-06-03 11:46:23 +0200138 Should Be True ${found}
139
kurczews859154a2019-04-26 11:31:51 +0200140Create event parsing error
141 [Arguments] ${ves_event}
142 ${notification}= Create invalid notification ${ves_event}
143 ${error_msg}= Catenate SEPARATOR= \\n |Incorrect json, consumerDmaapModel can not be created: ${notification}
144 [Return] ${error_msg}
145
146Add PNF entry in AAI
147 [Arguments] ${pnf_entry}
Gary Wu9abb61c2018-09-27 10:38:50 -0700148 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
kurczews859154a2019-04-26 11:31:51 +0200149 Log AAI url ${AAI_SIMULATOR_SETUP_URL}
grabinskc68c2ee2019-06-19 12:36:42 +0200150 ${resp}= Put Request ${aai_session} /setup/add_pnf_entry headers=${suite_headers} data=${pnf_entry}
kurczews859154a2019-04-26 11:31:51 +0200151 Should Be Equal As Strings ${resp.status_code} 200
152
Marcin Migdald2448922019-06-17 15:22:44 +0200153Add service instance entry in AAI
154 [Arguments] ${aai_service_instance}
155 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
156 Log AAI url ${AAI_SIMULATOR_SETUP_URL}
Joanna Jeremiczbbabae72019-08-19 09:24:53 +0200157 ${resp}= Put Request ${aai_session} /setup/add_service_instance headers=${suite_headers} data=${aai_service_instance}
Marcin Migdald2448922019-06-17 15:22:44 +0200158 Should Be Equal As Strings ${resp.status_code} 200
159
Joanna Jeremicz4a70dd32019-06-25 13:39:33 +0200160Add logical link entry in AAI
161 [Arguments] ${logical_link}
162 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
163 Log AAI url ${AAI_SIMULATOR_SETUP_URL}
164 ${resp}= Put Request ${aai_session} /setup/add_logical_link headers=${suite_headers} data=${logical_link}
165 Should Be Equal As Strings ${resp.status_code} 200
166
kurczews859154a2019-04-26 11:31:51 +0200167Set VES event in DMaaP
168 [Arguments] ${ves_event}
grabinskc68c2ee2019-06-19 12:36:42 +0200169 ${resp}= Put Request ${dmaap_session} /setup/ves_event headers=${suite_headers} data=${ves_event}
kurczews859154a2019-04-26 11:31:51 +0200170 Should Be Equal As Strings ${resp.status_code} 200
171
172Should Be Equal As JSON
grabinsk08a9c632019-05-23 13:34:38 +0200173 [Arguments] ${actual} ${expected}
174 Log EXPECTED: ${expected}
175 Log ACTUAL: ${actual}
176 ${expected_json}= Evaluate json.loads("""${expected}""") json
177 ${actual_json}= Evaluate json.loads("""${actual}""") json
178 Should Be Equal ${actual_json} ${expected_json}
Gary Wu9abb61c2018-09-27 10:38:50 -0700179
pkaras55d36862018-10-17 15:08:34 +0200180Reset Simulators
181 Reset AAI simulator
pkarasc7abba82018-10-22 12:22:35 +0200182 Reset DMaaP simulator
Gary Wu9abb61c2018-09-27 10:38:50 -0700183
pkaras55d36862018-10-17 15:08:34 +0200184Reset AAI simulator
grabinskc68c2ee2019-06-19 12:36:42 +0200185 ${resp}= Post Request ${aai_session} /reset
pkaras55d36862018-10-17 15:08:34 +0200186 Should Be Equal As Strings ${resp.status_code} 200
pkarasc7abba82018-10-22 12:22:35 +0200187
188Reset DMaaP simulator
grabinskc68c2ee2019-06-19 12:36:42 +0200189 ${resp}= Post Request ${dmaap_session} /reset
Marcin Migdalfba99a52019-04-15 14:36:45 +0200190 Should Be Equal As Strings ${resp.status_code} 200
191
micdzied9c7d8f02019-06-17 14:08:27 +0200192
193Verify change logging level
grabinskad1421e2019-06-21 15:08:21 +0200194 ${logger}= Set Variable org.onap.dcaegen2.services.prh.controllers.AppInfoController
195 Change logging level ${logger} TRACE
196 Verify logging level ${logger} TRACE
micdzied9c7d8f02019-06-17 14:08:27 +0200197 Verify logs with heartbeat
grabinskad1421e2019-06-21 15:08:21 +0200198 [Teardown] Change logging level ${logger} INFO
micdzied9c7d8f02019-06-17 14:08:27 +0200199
200Change logging level
grabinskad1421e2019-06-21 15:08:21 +0200201 [Arguments] ${logger} ${log_level}
202 ${request_body}= Create Dictionary configuredLevel=${log_level}
203 ${resp}= Post Request prh_session /actuator/loggers/${logger} json=${request_body}
204 Should Be Equal As Integers ${resp.status_code} 204
micdzied9c7d8f02019-06-17 14:08:27 +0200205
206Verify logging level
grabinskad1421e2019-06-21 15:08:21 +0200207 [Arguments] ${logger} ${expected_log_level}
208 ${resp}= Get Request prh_session /actuator/loggers/${logger}
209 Should Be Equal As Integers ${resp.status_code} 200
210 Log ${resp.content}
211 Should Be Equal As Strings ${resp.json()["configuredLevel"]} ${expected_log_level} ignore_case=true
micdzied9c7d8f02019-06-17 14:08:27 +0200212
213Verify logs with heartbeat
grabinskc68c2ee2019-06-19 12:36:42 +0200214 Get Request prh_session /heartbeat
grabinsk3bee4892019-07-17 08:43:33 +0200215 Verify PRH logs contains Heartbeat request received
216
217Verify PRH logs contains
218 [Arguments] ${expected_entry}
219 ${log}= Get docker logs since test start prh
220 Should Contain ${log} ${expected_entry}