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_response0.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_payload0.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
53 Post pm notification-1 to dmaap
54 ${data}= Get File ${TEST_ROBOT_DIR}/data/performance_notification0.json
56 ${response}= Evaluate requests.post('${POST_DMAAP_EVENT_FOR_PM_NOTIF_URL}', data=$data)
59 Should Be Equal As Strings ${response.status_code} 200
62 Verify pm notification-1 trigger
63 Create Session dmaap ${DMAAP_URL}
65 ${result}= Get Request dmaap ${unauthenticated.DCAE_CL_OUTPUT}
66 Exit For Loop If ${result.json()} != @{EMPTY}
67 Log Waiting for sliceanalysisms to handle trigger... console=${True}
70 ${expected_string}= Get File ${TEST_ROBOT_DIR}/data/expected_payload_pm0.json
71 ${expected_payload}= Evaluate json.loads("""${expected_string}""") json
72 ${result}= Convert To String ${result.content}
73 ${result_string}= Get Substring ${result} 2 -2
74 ${actual_data}= Evaluate json.loads("""${result_string}""") json
75 ${actual_payload_str}= Set Variable ${actual_data['payload']}
76 ${actual_payload}= Evaluate json.loads("""${actual_payload_str}""") json
77 set to dictionary ${expected_payload['additionalProperties']['nsiInfo']} nsiId=${actual_payload['additionalProperties']['nsiInfo']['nsiId']}
78 Should Be True """${actual_payload}""".strip() == """${expected_payload}""".strip()