Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Library RequestsLibrary |
| 3 | Library Collections |
| 4 | Library PrhLibrary.py |
| 5 | Resource ../../../common.robot |
| 6 | |
| 7 | *** Keywords *** |
| 8 | Create header |
| 9 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 10 | Set Suite Variable ${suite_headers} ${headers} |
| 11 | |
| 12 | Create sessions |
| 13 | Create Session dmaap_session ${DMAAP_SIMULATOR_URL} |
| 14 | Set Suite Variable ${suite_dmaap_session} dmaap_session |
| 15 | Create Session aai_session ${AAI_SIMULATOR_URL} |
| 16 | Set Suite Variable ${suite_aai_session} aai_session |
| 17 | |
| 18 | Invalid event processing |
| 19 | [Arguments] ${input_invalid_event_in_dmaap} |
| 20 | [Timeout] 30s |
| 21 | ${data}= Get Data From File ${input_invalid_event_in_dmaap} |
| 22 | Set event in DMaaP ${data} |
| 23 | ${invalid_notification}= Create invalid notification ${data} |
| 24 | ${notification}= Catenate SEPARATOR= \\n |org.onap.dcaegen2.services.prh.exceptions.DmaapNotFoundException: Incorrect json, consumerDmaapModel can not be created: ${invalid_notification} |
| 25 | Wait Until Keyword Succeeds 100x 100ms Check PRH log ${notification} |
| 26 | |
| 27 | Valid event processing |
| 28 | [Arguments] ${input_valid_event_in_dmaap} |
| 29 | [Timeout] 30s |
| 30 | ${data}= Get Data From File ${input_valid_event_in_dmaap} |
| 31 | ${posted_event_to_dmaap}= Create PNF_Ready notification ${data} |
| 32 | ${pnf_name}= Create PNF name ${data} |
| 33 | Set PNF name in AAI ${pnf_name} |
| 34 | Set event in DMaaP ${data} |
| 35 | Wait Until Keyword Succeeds 100x 300ms Check PNF_READY notification ${posted_event_to_dmaap} |
| 36 | |
| 37 | Check PRH log |
| 38 | [Arguments] ${searched_log} |
| 39 | ${status}= Check for log ${searched_log} |
| 40 | Should Be Equal As Strings ${status} True |
| 41 | |
| 42 | Check PNF_READY notification |
| 43 | [Arguments] ${posted_event_to_dmaap} |
| 44 | ${resp}= Get Request ${suite_dmaap_session} /events/pnfReady headers=${suite_headers} |
| 45 | Should Be Equal ${resp.text} ${posted_event_to_dmaap} |
| 46 | |
| 47 | Set PNF name in AAI |
| 48 | [Arguments] ${pnfs_name} |
| 49 | ${headers}= Create Dictionary Accept=application/json Content-Type=text/html |
| 50 | ${resp}= Put Request ${suite_aai_session} /set_pnfs headers=${headers} data=${pnfs_name} |
| 51 | Should Be Equal As Strings ${resp.status_code} 200 |
| 52 | |
| 53 | Set event in DMaaP |
| 54 | [Arguments] ${event_in_dmaap} |
| 55 | ${resp}= Put Request ${suite_dmaap_session} /set_get_event headers=${suite_headers} data=${event_in_dmaap} |
| 56 | Should Be Equal As Strings ${resp.status_code} 200 |