4 Library RequestsLibrary
6 Library OperatingSystem
8 Suite Teardown Delete All Sessions
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/23/23
15 ${POST_DMAAP_EVENT_FOR_ML_NOTIF_URL} http://${DMAAP_IP}:3904/events/unauthenticated.ML_RESPONSE_TOPIC
16 ${POST_DMAAP_EVENT_FOR_PM_NOTIF_URL} http://${DMAAP_IP}:3904/events/unauthenticated.PERFORMANCE_MEASUREMENTS
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
28 Post ml notification to dmaap
29 Create Session dmaap ${DMAAP_URL}
30 ${headers}= Create Dictionary Content-Type application/json
31 ${data}= Get File ${TEST_ROBOT_DIR}/data/ml_response.json
32 ${response}= Evaluate requests.post('${POST_DMAAP_EVENT_FOR_ML_NOTIF_URL}', data=$data)
33 Should Be Equal As Strings ${response.status_code} 200
36 Verify ml notification trigger
37 Create Session dmaap ${DMAAP_URL}
39 ${result}= Get Request dmaap ${unauthenticated.DCAE_CL_OUTPUT}
40 Exit For Loop If ${result.json()} != @{EMPTY}
41 Log Waiting for slice-analysis-ms to handle trigger... console=${True}
45 ${expected_string}= Get File ${TEST_ROBOT_DIR}/data/expected_ml_payload.json
46 ${expected_payload}= Evaluate json.loads("""${expected_string}""") json
47 ${result}= Convert To String ${result.content}
48 ${result_string}= Get Substring ${result} 2 -2
49 ${actual_data}= Evaluate json.loads("""${result_string}""") json
50 ${actual_payload_str}= Set Variable ${actual_data['payload']}
51 ${actual_payload}= Evaluate json.loads("""${actual_payload_str}""") json
52 set to dictionary ${expected_payload['additionalProperties']['nsiInfo']} nsiId=${actual_payload['additionalProperties']['nsiInfo']['nsiId']}
53 Should Be True """${actual_payload}""".strip() == """${expected_payload}""".strip()
56 Post pm notification-1 to dmaap
57 ${data}= Get File ${TEST_ROBOT_DIR}/data/performance_notification1.json
59 ${response}= Evaluate requests.post('${POST_DMAAP_EVENT_FOR_PM_NOTIF_URL}', data=$data)
62 Should Be Equal As Strings ${response.status_code} 200
65 Verify pm notification-1 trigger
66 Create Session dmaap ${DMAAP_URL}
68 ${result}= Get Request dmaap ${unauthenticated.DCAE_CL_OUTPUT}
69 Exit For Loop If ${result.json()} != @{EMPTY}
70 Log Waiting for sliceanalysisms to handle trigger... console=${True}
73 ${expected_string}= Get File ${TEST_ROBOT_DIR}/data/expected_payload_pm1.json
74 ${expected_payload}= Evaluate json.loads("""${expected_string}""") json
75 ${result}= Convert To String ${result.content}
76 ${result_string}= Get Substring ${result} 2 -2
77 ${actual_data}= Evaluate json.loads("""${result_string}""") json
78 ${actual_payload_str}= Set Variable ${actual_data['payload']}
79 ${actual_payload}= Evaluate json.loads("""${actual_payload_str}""") json
80 set to dictionary ${expected_payload['additionalProperties']['nsiInfo']} nsiId=${actual_payload['additionalProperties']['nsiInfo']['nsiId']}
81 Should Be True """${actual_payload}""".strip() == """${expected_payload}""".strip()
85 Post pm notification-2 to dmaap
86 ${data}= Get File ${TEST_ROBOT_DIR}/data/performance_notification3.json
87 ${data1}= Get File ${TEST_ROBOT_DIR}/data/performance_notification4.json
88 ${data2}= Get File ${TEST_ROBOT_DIR}/data/performance_notification5.json
89 ${data3}= Get File ${TEST_ROBOT_DIR}/data/performance_notification6.json
90 ${data4}= Get File ${TEST_ROBOT_DIR}/data/performance_notification7.json
91 ${data5}= Get File ${TEST_ROBOT_DIR}/data/performance_notification8.json
93 ${response}= Evaluate requests.post('${POST_DMAAP_EVENT_FOR_PM_NOTIF_URL}', data=$data)
94 ${response1}= Evaluate requests.post('${POST_DMAAP_EVENT_FOR_PM_NOTIF_URL}', data=$data1)
95 ${response2}= Evaluate requests.post('${POST_DMAAP_EVENT_FOR_PM_NOTIF_URL}', data=$data2)
96 ${response3}= Evaluate requests.post('${POST_DMAAP_EVENT_FOR_PM_NOTIF_URL}', data=$data3)
97 ${response4}= Evaluate requests.post('${POST_DMAAP_EVENT_FOR_PM_NOTIF_URL}', data=$data4)
98 ${response5}= Evaluate requests.post('${POST_DMAAP_EVENT_FOR_PM_NOTIF_URL}', data=$data5)
100 Should Be Equal As Strings ${response.status_code} 200
101 Should Be Equal As Strings ${response1.status_code} 200
102 Should Be Equal As Strings ${response2.status_code} 200
103 Should Be Equal As Strings ${response3.status_code} 200
104 Should Be Equal As Strings ${response4.status_code} 200
105 Should Be Equal As Strings ${response5.status_code} 200
108 Verify pm notification-2 trigger
109 Create Session dmaap ${DMAAP_URL}
111 ${result}= Get Request dmaap ${unauthenticated.DCAE_CL_OUTPUT}
112 Exit For Loop If ${result.json()} != @{EMPTY}
113 Log Waiting for sliceanalysisms to handle trigger... console=${True}
116 ${expected_string}= Get File ${TEST_ROBOT_DIR}/data/expected_payload_pm2.json
117 ${expected_payload}= Evaluate json.loads("""${expected_string}""") json
118 ${result}= Convert To String ${result.content}
119 ${result_string}= Get Substring ${result} 2 -2
120 ${actual_data}= Evaluate json.loads("""${result_string}""") json
121 ${actual_payload_str}= Set Variable ${actual_data['payload']}
122 ${actual_payload}= Evaluate json.loads("""${actual_payload_str}""") json
123 set to dictionary ${expected_payload['additionalProperties']['nsiInfo']} nsiId=${actual_payload['additionalProperties']['nsiInfo']['nsiId']}
124 Should Be True """${actual_payload}""".strip() == """${expected_payload}""".strip()