[DCAEGEN2-SLICEANALYSISMS] Add new robot for CCVPN/IBN closed-loop functionality...
[integration/csit.git] / tests / dcaegen2-services-slice-analysis-ms / testcases / slice-analysis-ms-test-aai-dcae.robot
1 *** Settings ***
2 Library           Collections
3 Library           Process
4 Library           RequestsLibrary
5 Library           String
6 Library           OperatingSystem
7
8 Suite Teardown  Delete All Sessions
9
10 *** Variables ***
11 ${SLICE_ANALYSIS_MS_BASE_URL}             http://${SLICE_ANALYSIS_MS_IP}:8080
12 ${HEALTHCHECK_ENDPOINT}                   /healthcheck
13 ${DMAAP_URL}                              http://${DMAAP_IP}:3904/events
14 ${unauthenticated.DCAE_CL_OUTPUT}         /unauthenticated.DCAE_CL_OUTPUT/24/24
15 ${AAI_EVENT_OUTPUT}                       /AAI-EVENT/24/24
16 ${POST_DMAAP_EVENT_FOR_AAI_EVENT_URL}     http://${DMAAP_IP}:3904/events/AAI-EVENT
17 ${VESCOLLECTOR_URL}                       https://${VESCOLLECTOR_IP}:8443/eventListener/v7
18 ${AAI_NETWORK_POLICY_URL}                 https://${AAI_RESOURCES_IP}:8447/aai/v24/network/network-policies/network-policy/933dacc1-56e0-4b94-8808-4d099ebc4de5
19 *** Test Cases ***
20
21 HealthCheck
22
23         Create Session  sliceanalysisms  ${SLICE_ANALYSIS_MS_BASE_URL}
24         ${resp}=  Get Request   sliceanalysisms   ${HEALTHCHECK_ENDPOINT}
25         Should Be Equal As Strings  ${resp.status_code}  200
26
27 Post pm ves notification to vescollector
28
29         Log     posting 6 VES_Notification         console=${True}
30         Create Session  ves  ${VESCOLLECTOR_URL}
31         ${headers}=    Create Dictionary    Content-Type=application/json
32         ${user_pass}=    Evaluate   ('sample1', 'sample1')
33         ${data}=   Get File      ${TEST_ROBOT_DIR}/data/ves_notification_pmdata.json
34         FOR    ${i}    IN RANGE   6
35                 ${response}=    Evaluate    requests.post('${VESCOLLECTOR_URL}', headers=${headers}, data=$data, auth=${user_pass}, verify=False)
36                 Should Be Equal As Strings  ${response.status_code}  202
37                 Sleep   2s
38         END
39
40 Verify periodic checking from dmaap
41
42         Create Session  dmaap  ${DMAAP_URL}
43         FOR    ${i}    IN RANGE   30
44                 ${result}=  Get Request  dmaap   ${unauthenticated.DCAE_CL_OUTPUT}
45                 Exit For Loop If    ${result.json()} != @{EMPTY}
46                 Log     Waiting for slice-analysis-ms to handle periodic checking...         console=${True}
47                 Sleep   5s
48         END
49         ${expected_string}=   Get File            ${TEST_ROBOT_DIR}/data/expected_payload_ccvpn1.json
50         ${expected_payload}=    Evaluate     json.loads("""${expected_string}""")     json
51         ${result}=  Convert To String  ${result.content}
52         ${result_string}=    Get Substring    ${result}  2    -2
53         ${actual_data}=      Evaluate     json.loads("""${result_string}""")     json
54         ${actual_payload_str}=    Set Variable     ${actual_data['payload']}
55         ${actual_payload}=       Evaluate     json.loads("""${actual_payload_str}""")     json
56         Should Be True   """${actual_payload}""".strip() == """${expected_payload}""".strip()
57
58
59 Post ccvpn modification to dmaap
60
61         ${headers}=    Create Dictionary    Content-Type=application/merge-patch+json    X-HTTP-Method-Override=PATCH    Accept=application/json    X-FromAppId=AAI    X-TransactionId=808b54e3-e563-4144-a1b9-e24e2ed93d4f
62         ${user_pass}=    Evaluate   ('AAI', 'AAI')
63         ${data}=   Get File      ${TEST_ROBOT_DIR}/data/network_policy_after.json
64         ${response}=    Evaluate    requests.post('${AAI_NETWORK_POLICY_URL}', headers=${headers}, data=$data, auth=${user_pass}, verify=False)
65         Should Be Equal As Strings  ${response.status_code}  200
66         Log     Wait 20s before posting AAI-EVENT         console=${True}
67         Sleep   20s
68         Log     posting AAI-EVENT         console=${True}
69         Create Session  dmaap  ${DMAAP_URL}
70         ${headers}=    Create Dictionary    Content-Type    application/json
71         ${data}=   Get File      ${TEST_ROBOT_DIR}/data/aai_event_svc_modification_bw.json
72         ${response}=    Evaluate    requests.post('${POST_DMAAP_EVENT_FOR_AAI_EVENT_URL}', data=$data)
73         Should Be Equal As Strings  ${response.status_code}  200
74
75
76 Verify ccvpn modification from dmaap
77
78         Create Session  dmaap  ${DMAAP_URL}
79         FOR    ${i}    IN RANGE   30
80                 ${result}=  Get Request  dmaap   ${unauthenticated.DCAE_CL_OUTPUT}
81                 Exit For Loop If    ${result.json()} != @{EMPTY}
82                 Log     Waiting for slice-analysis-ms to handle trigger...         console=${True}
83                 Sleep   5s
84         END
85         ${expected_string}=   Get File            ${TEST_ROBOT_DIR}/data/expected_payload_ccvpn0.json
86         ${expected_payload}=    Evaluate     json.loads("""${expected_string}""")     json
87         ${result}=  Convert To String  ${result.content}
88         ${result_string}=    Get Substring    ${result}  2    -2
89         ${actual_data}=      Evaluate     json.loads("""${result_string}""")     json
90         ${actual_payload_str}=    Set Variable     ${actual_data['payload']}
91         ${actual_payload}=       Evaluate     json.loads("""${actual_payload_str}""")     json
92         Should Be True   """${actual_payload}""".strip() == """${expected_payload}""".strip()
93
94 *** Keywords ***
95 Provided precondition
96     Setup system under test