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 ${SLICE_CONFIG_ENDPOINT} ${SLICE_ANALYSIS_MS_BASE_URL}/api/v1/slices-config
13 ${HEALTHCHECK_ENDPOINT} /healthcheck
14 ${DMAAP_URL} http://${DMAAP_IP}:3904/events
15 ${unauthenticated.DCAE_CL_OUTPUT} /unauthenticated.DCAE_CL_OUTPUT/23/23
16 ${POST_DMAAP_EVENT_FOR_ML_NOTIF_URL} http://${DMAAP_IP}:3904/events/unauthenticated.ML_RESPONSE_TOPIC
17 ${POST_DMAAP_EVENT_FOR_PM_NOTIF_URL} http://${DMAAP_IP}:3904/events/unauthenticated.PERFORMANCE_MEASUREMENTS
18 &{headers} Content-Type=application/json
25 Create Session sliceanalysisms ${SLICE_ANALYSIS_MS_BASE_URL}
26 ${resp}= Get On Session sliceanalysisms ${HEALTHCHECK_ENDPOINT}
27 Should Be Equal As Strings ${resp.status_code} 200
30 Post ml notification to dmaap
31 Create Session dmaap ${DMAAP_URL}
32 ${headers}= Create Dictionary Content-Type application/json
33 ${data}= Get File ${TEST_ROBOT_DIR}/data/ml_response0.json
34 ${response}= Evaluate requests.post('${POST_DMAAP_EVENT_FOR_ML_NOTIF_URL}', data=$data)
35 Should Be Equal As Strings ${response.status_code} 200
38 Verify ml notification trigger
39 Create Session dmaap ${DMAAP_URL}
41 ${result}= Get On Session dmaap ${unauthenticated.DCAE_CL_OUTPUT}
42 Exit For Loop If ${result.json()} != @{EMPTY}
43 Log Waiting for slice-analysis-ms to handle trigger... console=${True}
47 ${expected_string}= Get File ${TEST_ROBOT_DIR}/data/expected_ml_payload0.json
48 ${expected_payload}= Evaluate json.loads("""${expected_string}""") json
49 ${result}= Convert To String ${result.content}
50 ${result_string}= Get Substring ${result} 2 -2
51 ${actual_data}= Evaluate json.loads("""${result_string}""") json
52 ${actual_payload_str}= Set Variable ${actual_data['payload']}
53 ${actual_payload}= Evaluate json.loads("""${actual_payload_str}""") json
55 Post pm notification-1 to dmaap
56 ${data}= Get File ${TEST_ROBOT_DIR}/data/performance_notification0.json
58 ${response}= Evaluate requests.post('${POST_DMAAP_EVENT_FOR_PM_NOTIF_URL}', data=$data)
61 Should Be Equal As Strings ${response.status_code} 200
64 Verify pm notification-1 trigger
65 Create Session dmaap ${DMAAP_URL}
67 ${result}= Get On Session dmaap ${unauthenticated.DCAE_CL_OUTPUT}
68 Exit For Loop If ${result.json()} != @{EMPTY}
69 Log Waiting for sliceanalysisms to handle trigger... console=${True}
72 ${expected_string}= Get File ${TEST_ROBOT_DIR}/data/expected_payload_pm0.json
73 ${expected_payload}= Evaluate json.loads("""${expected_string}""") json
74 ${result}= Convert To String ${result.content}
75 ${result_string}= Get Substring ${result} 2 -2
76 ${actual_data}= Evaluate json.loads("""${result_string}""") json
77 ${actual_payload_str}= Set Variable ${actual_data['payload']}
78 ${actual_payload}= Evaluate json.loads("""${actual_payload_str}""") json
79 set to dictionary ${expected_payload['additionalProperties']['nsiInfo']} nsiId=${actual_payload['additionalProperties']['nsiInfo']['nsiId']}
80 Should Be True """${actual_payload}""".strip() == """${expected_payload}""".strip()
83 Verify slice utilization respose
84 ${data}= Get File ${TEST_ROBOT_DIR}/data/slice_config_request.json
85 ${result}= Evaluate requests.get('${SLICE_CONFIG_ENDPOINT}', data=$data, headers=${headers})
86 ${expected_slice_config}= Get File ${TEST_ROBOT_DIR}/data/slice_config_response.json
87 ${actual_slice_config}= Convert To String ${result.content}
88 Should Be True """${actual_slice_config}""".strip() == """${expected_slice_config}""".strip()