Attempt to check CSIT
[integration/csit.git] / tests / dcaegen2 / prh-testcases / resources / prh_library.robot
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_setup_session    ${DMAAP_SIMULATOR_SETUP_URL}
14     Set Suite Variable    ${dmaap_setup_session}    dmaap_setup_session
15     Create Session    aai_setup_session    ${AAI_SIMULATOR_SETUP_URL}
16     Set Suite Variable    ${aai_setup_session}    aai_setup_session
17     Create Session    consul_setup_session    ${CONSUL_SETUP_URL}
18     Set Suite Variable    ${consul_setup_session}    consul_setup_session
19     Sleep    60s
20
21 Reset Simulators
22     Reset AAI simulator
23     Reset DMaaP simulator
24
25 Invalid event processing
26     [Arguments]    ${input_invalid_event_in_dmaap}
27     [Timeout]    30s
28     ${data}=    Get Data From File    ${input_invalid_event_in_dmaap}
29     Set event in DMaaP    ${data}
30     ${invalid_notification}=    Create invalid notification    ${data}
31     ${notification}=    Catenate    SEPARATOR= \\n    |Incorrect json, consumerDmaapModel can not be created:     ${invalid_notification}
32     #TODO to fix after CBS merge
33     #Wait Until Keyword Succeeds    100x    100ms    Check PRH log    ${notification}
34
35 Valid event processing
36     [Arguments]    ${input_valid__ves_event_in_dmaap}    ${input_aai}
37     [Timeout]    150s
38     Wait Until Keyword Succeeds    10x    3000ms    Check CBS ready
39     ${data}=    Get Data From File    ${input_valid__ves_event_in_dmaap}
40     ${aai_entry_to_be_set}=    Get Data From File    ${input_aai}
41     Set event in DMaaP    ${data}
42     ${pnf_name}=    Create PNF name    ${data}
43     Set PNF name in AAI    ${pnf_name}
44     Set PNF content in AAI    ${aai_entry_to_be_set}
45     ${expected_event_pnf_ready_in_dpaap}=    create pnf ready_notification as pnf ready    ${data}
46     #TODO to fix after CBS merge
47     Wait Until Keyword Succeeds    10x    3000ms    Check PNF_READY notification    ${expected_event_pnf_ready_in_dpaap}
48     #Wait Until Keyword Succeeds    10x    3000ms    Check PRH log    Mandingo
49
50 Check PRH log
51     [Arguments]    ${searched_log}
52     ${status}=    Check for log    ${searched_log}
53     Should Be Equal As Strings    ${status}    True
54
55 Check PNF_READY notification
56     [Arguments]    ${expected_event_pnf_ready_in_dpaap}
57     ${resp}=    Get Request    ${dmaap_setup_session}    /events/pnfReady    headers=${suite_headers}
58     Should Be Equal    ${resp.text}    ${expected_event_pnf_ready_in_dpaap}
59
60 Set PNF name in AAI
61     [Arguments]    ${pnf_name}
62     ${headers}=    Create Dictionary    Accept=application/json    Content-Type=text/html
63     Log    AAI url ${AAI_SIMULATOR_SETUP_URL}
64     Log    Http headers ${headers}
65     Log    PNF name ${pnf_name}
66     ${resp}=    Put Request    ${aai_setup_session}    /set_pnf    headers=${headers}    data=${pnf_name}
67     Should Be Equal As Strings    ${resp.status_code}    200
68
69 Set PNF content in AAI
70     [Arguments]    ${aai_pnf_content}
71     ${headers}=    Create Dictionary    Accept=application/json    Content-Type=text/html
72     Log    AAI url ${AAI_SIMULATOR_SETUP_URL}
73     Log    Http headers ${headers}
74     Log    PNF AAI content ${aai_pnf_content}
75     ${resp}=    Put Request    ${aai_setup_session}    /setup/add_pnf_entry    headers=${headers}    data=${aai_pnf_content}
76     Should Be Equal As Strings    ${resp.status_code}    200
77
78 Set event in DMaaP
79     [Arguments]    ${event_in_dmaap}
80     ${resp}=    Put Request    ${dmaap_setup_session}    /set_get_event    headers=${suite_headers}    data=${event_in_dmaap}
81     Should Be Equal As Strings    ${resp.status_code}    200
82
83 Reset AAI simulator
84     ${resp}=    Post Request     ${aai_setup_session}    /reset
85     Should Be Equal As Strings    ${resp.status_code}    200
86
87 Reset DMaaP simulator
88     ${resp}=    Post Request     ${dmaap_setup_session}    /reset
89     Should Be Equal As Strings    ${resp.status_code}    200
90
91
92 Check CBS ready
93     ${resp}=    Get Request    ${consul_setup_session}    /v1/catalog/service/cbs
94     Should Be Equal As Strings    ${resp.status_code}    200
95     Log    CBS ${resp.content}