aboutsummaryrefslogtreecommitdiffstats
path: root/tests/dcaegen2/prh-testcases/resources/prh_library.robot
blob: 7c486eabc7ebe1c07f3c9fa0e01e07beb3c0989e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
*** Settings ***
Library           RequestsLibrary
Library           Collections
Library           PrhLibrary.py
Resource          ../../../common.robot

*** Keywords ***
Create header
    ${headers}=    Create Dictionary    Accept=application/json    Content-Type=application/json
    Set Suite Variable    ${suite_headers}    ${headers}

Create sessions
    Create Session    dmaap_setup_session    ${DMAAP_SIMULATOR_SETUP_URL}
    Set Suite Variable    ${dmaap_setup_session}    dmaap_setup_session
    Create Session    aai_setup_session    ${AAI_SIMULATOR_SETUP_URL}
    Set Suite Variable    ${aai_setup_session}    aai_setup_session
    Create Session    consul_setup_session    ${CONSUL_SETUP_URL}
    Set Suite Variable    ${consul_setup_session}    consul_setup_session
    Sleep    60s

Reset Simulators
    Reset AAI simulator
    Reset DMaaP simulator

Invalid event processing
    [Arguments]    ${input_invalid_event_in_dmaap}
    [Timeout]    30s
    ${data}=    Get Data From File    ${input_invalid_event_in_dmaap}
    Set event in DMaaP    ${data}
    ${invalid_notification}=    Create invalid notification    ${data}
    ${notification}=    Catenate    SEPARATOR= \\n    |Incorrect json, consumerDmaapModel can not be created:     ${invalid_notification}
    #TODO to fix after CBS merge
    #Wait Until Keyword Succeeds    100x    100ms    Check PRH log    ${notification}

Valid event processing
    [Arguments]    ${input_valid__ves_event_in_dmaap}    ${input_aai}
    [Timeout]    150s
    Wait Until Keyword Succeeds    10x    3000ms    Check CBS ready
    ${data}=    Get Data From File    ${input_valid__ves_event_in_dmaap}
    ${aai_entry_to_be_set}=    Get Data From File    ${input_aai}
    Set event in DMaaP    ${data}
    ${pnf_name}=    Create PNF name    ${data}
    Set PNF name in AAI    ${pnf_name}
    Set PNF content in AAI    ${aai_entry_to_be_set}
    ${expected_event_pnf_ready_in_dpaap}=    create pnf ready_notification as pnf ready    ${data}
    #TODO to fix after CBS merge
    Wait Until Keyword Succeeds    10x    3000ms    Check PNF_READY notification    ${expected_event_pnf_ready_in_dpaap}
    #Wait Until Keyword Succeeds    10x    3000ms    Check PRH log    Mandingo

Check PRH log
    [Arguments]    ${searched_log}
    ${status}=    Check for log    ${searched_log}
    Should Be Equal As Strings    ${status}    True

Check PNF_READY notification
    [Arguments]    ${expected_event_pnf_ready_in_dpaap}
    ${resp}=    Get Request    ${dmaap_setup_session}    /events/pnfReady    headers=${suite_headers}
    Should Be Equal    ${resp.text}    ${expected_event_pnf_ready_in_dpaap}

Set PNF name in AAI
    [Arguments]    ${pnf_name}
    ${headers}=    Create Dictionary    Accept=application/json    Content-Type=text/html
    Log    AAI url ${AAI_SIMULATOR_SETUP_URL}
    Log    Http headers ${headers}
    Log    PNF name ${pnf_name}
    ${resp}=    Put Request    ${aai_setup_session}    /set_pnf    headers=${headers}    data=${pnf_name}
    Should Be Equal As Strings    ${resp.status_code}    200

Set PNF content in AAI
    [Arguments]    ${aai_pnf_content}
    ${headers}=    Create Dictionary    Accept=application/json    Content-Type=text/html
    Log    AAI url ${AAI_SIMULATOR_SETUP_URL}
    Log    Http headers ${headers}
    Log    PNF AAI content ${aai_pnf_content}
    ${resp}=    Put Request    ${aai_setup_session}    /setup/add_pnf_entry    headers=${headers}    data=${aai_pnf_content}
    Should Be Equal As Strings    ${resp.status_code}    200

Set event in DMaaP
    [Arguments]    ${event_in_dmaap}
    ${resp}=    Put Request    ${dmaap_setup_session}    /set_get_event    headers=${suite_headers}    data=${event_in_dmaap}
    Should Be Equal As Strings    ${resp.status_code}    200

Reset AAI simulator
    ${resp}=    Post Request     ${aai_setup_session}    /reset
    Should Be Equal As Strings    ${resp.status_code}    200

Reset DMaaP simulator
    ${resp}=    Post Request     ${dmaap_setup_session}    /reset
    Should Be Equal As Strings    ${resp.status_code}    200


Check CBS ready
    ${resp}=    Get Request    ${consul_setup_session}    /v1/catalog/service/cbs
    Should Be Equal As Strings    ${resp.status_code}    200
    Log    CBS ${resp.content}