Add CSIT for son-handler
Issue-ID: DCAEGEN2-1433
Signed-off-by: Niranjana <niranjana.y60@wipro.com>
Change-Id: Id7ea296ebef70964f5e8b751969595320b49d00a
diff --git a/tests/dcaegen2-services-son-handler/testcases/data/expected_payload_fm.json b/tests/dcaegen2-services-son-handler/testcases/data/expected_payload_fm.json
new file mode 100644
index 0000000..d542a7d
--- /dev/null
+++ b/tests/dcaegen2-services-son-handler/testcases/data/expected_payload_fm.json
@@ -0,0 +1 @@
+{"Configurations":[{"data":{"FAPService":{"alias":"Chn0071","X0005b9Lte":{"phyCellIdInUse":5,"pnfName":"ncserver5"},"CellConfig":{"LTE":{"RAN":{"Common":{"CellIdentity":"Chn0071"}}}}}}}]}
diff --git a/tests/dcaegen2-services-son-handler/testcases/data/expected_payload_pm.json b/tests/dcaegen2-services-son-handler/testcases/data/expected_payload_pm.json
new file mode 100644
index 0000000..2a56f2c
--- /dev/null
+++ b/tests/dcaegen2-services-son-handler/testcases/data/expected_payload_pm.json
@@ -0,0 +1 @@
+{"Configurations":[{"data":{"FAPService":{"alias":"Chn0002","CellConfig":{"LTE":{"RAN":{"Common":{"CellIdentity":"Chn0002"},"NeighborListInUse":{"LTECell":[{"PNFName":"ncserver1","PLMNID":"plmnid1","CID":"Chn0004","PhyCellID":0,"Blacklisted":"true"},{"PNFName":"ncserver1","CID":"Chn0001","PhyCellID":0,"Blacklisted":"true"}],"LTECellNumberOfEntries":"2"}}}}}}}]}
diff --git a/tests/dcaegen2-services-son-handler/testcases/data/fault_notification.json b/tests/dcaegen2-services-son-handler/testcases/data/fault_notification.json
new file mode 100644
index 0000000..e5a327a
--- /dev/null
+++ b/tests/dcaegen2-services-son-handler/testcases/data/fault_notification.json
@@ -0,0 +1,35 @@
+{
+ "event": {
+ "commonEventHeader": {
+ "version": "4.0.1",
+ "vesEventListenerVersion": "7.0.1",
+ "domain": "fault",
+ "eventName": "Fault_RansimAgent-Wipro_RanPCIProblem",
+ "eventId": "fault000001",
+ "sequence": 1,
+ "priority": "High",
+ "reportingEntityId": "de305d54-75b4-431b-adb2-eb6b9e546014",
+ "reportingEntityName": "ncserver5",
+ "sourceId": "cc305d54-75b4-431b-adb2-eb6b9e541234",
+ "sourceName": "Chn0071",
+ "startEpochMicrosec": 1451772223000000,
+ "lastEpochMicrosec": 1451772403000000,
+ "timeZoneOffset": "UTC-05:30",
+ "nfNamingCode": "RansimAgent",
+ "nfVendorName": "Wipro"
+ },
+ "faultFields": {
+ "faultFieldsVersion": "4.0",
+ "alarmCondition": "RanPciCollisionConfusionOccurred",
+ "eventSourceType": "other",
+ "specificProblem": "Collision",
+ "eventSeverity": "CRITICAL",
+ "vfStatus": "Active",
+ "alarmAdditionalInformation": {
+ "networkId": "ran-1",
+ "collisions": "1",
+ "confusions": "0"
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/dcaegen2-services-son-handler/testcases/data/negative_ack_from_policy.json b/tests/dcaegen2-services-son-handler/testcases/data/negative_ack_from_policy.json
new file mode 100644
index 0000000..8988f1c
--- /dev/null
+++ b/tests/dcaegen2-services-son-handler/testcases/data/negative_ack_from_policy.json
@@ -0,0 +1,10 @@
+{
+ "requestID": "d9a6d3de-c7b9-4dc7-bbb3-54953c62f7a9",
+ "closedLoopControlName": "ControlLoop-vPCI-fb41f388-a5f2-11e8-98d0-529269fb1459",
+ "version": "1.0.2",
+ "target": "DCAE",
+ "from": "SDNR",
+ "policyName": "PCI",
+ "policyVersion": "1.0.2",
+ "payload": " { \"Configurations\":[{ \"Status\": { \"Code\": 400, \"Value\": \"FAILURE\" }, \"data\":{\"FAPService\":{\"alias\":\"Chn0071\",\"X0005b9Lte\":{\"phyCellIdInUse\":5,\"pnfName\":\"ncserver5\"},\"CellConfig\":{\"LTE\":{\"RAN\":{\"Common\":{\"CellIdentity\":\"Chn0071\"}}}}}}} ]}"
+}
diff --git a/tests/dcaegen2-services-son-handler/testcases/data/performance_notification.json b/tests/dcaegen2-services-son-handler/testcases/data/performance_notification.json
new file mode 100644
index 0000000..7721163
--- /dev/null
+++ b/tests/dcaegen2-services-son-handler/testcases/data/performance_notification.json
@@ -0,0 +1,42 @@
+{
+ "event": {
+ "commonEventHeader": {
+ "version": "4.0",
+ "domain": "measurement",
+ "eventName": "Measurement_RansimAgent-Wipro_HandoffMetric",
+ "eventId": "measurement000002",
+ "sequence": 0,
+ "priority": "Normal",
+ "reportingEntityId": "cc305d54-75b4-431b-adb2-eb6b9e544567",
+ "reportingEntityName": "ncserver1",
+ "sourceId": "de305d54-75b4-431b-adb2-eb6b9e546456",
+ "sourceName": "Chn0002",
+ "startEpochMicrosec": 1551772223000000,
+ "lastEpochMicrosec": 1551790542000000,
+ "nfNamingCode": "RansimAgent",
+ "nfVendorName": "Wipro",
+ "vesEventListenerVersion": "7.0.1",
+ "timeZoneOffset": "UTC-05:30"
+ },
+ "measurementFields": {
+ "measurementInterval": 180,
+ "measurementFieldsVersion": "4.0",
+ "additionalMeasurements": [{
+ "hashMap": {
+ "networkId": "plmnid1",
+ "InterEnbOutAtt_X2HO": "300",
+ "InterEnbOutSucc_X2HO": "90"
+ },
+ "name": "Chn0004"
+ },
+ {
+ "hashMap": {
+ "InterEnbOutAtt_X2HO": "250",
+ "InterEnbOutSucc_X2HO": "70"
+ },
+ "name": "Chn0001"
+ }
+ ]
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/dcaegen2-services-son-handler/testcases/sonhandler-test.robot b/tests/dcaegen2-services-son-handler/testcases/sonhandler-test.robot
new file mode 100644
index 0000000..6e93ffb
--- /dev/null
+++ b/tests/dcaegen2-services-son-handler/testcases/sonhandler-test.robot
@@ -0,0 +1,95 @@
+*** Settings ***
+Library Collections
+Library Process
+Library RequestsLibrary
+Library String
+Library OperatingSystem
+
+Suite Teardown Delete All Sessions
+
+*** Variables ***
+${SON_HANDLER_BASE_URL} http://${SONHMS_IP}:8080
+${HEALTHCHECK_ENDPOINT} /healthcheck
+${DMAAP_URL} http://${DMAAP_IP}:3904/events
+${unauthenticated.DCAE_CL_OUTPUT} /unauthenticated.DCAE_CL_OUTPUT/23/23
+${POST_DMAAP_EVENT_FOR_FM_NOTIF_URL} http://${DMAAP_IP}:3904/events/unauthenticated.SEC_FAULT_OUTPUT
+${POST_DMAAP_EVENT_FOR_PM_NOTIF_URL} http://${DMAAP_IP}:3904/events/unauthenticated.VES_MEASUREMENT_OUTPUT
+${POST_DMAAP_EVENT_FOR_POLICY_RESPONSE} http://${DMAAP_IP}:3904/events/DCAE_CL_RSP
+
+*** Test Cases ***
+
+HealthCheck
+
+ Create Session sonhms ${SON_HANDLER_BASE_URL}
+ ${resp}= Get Request sonhms ${HEALTHCHECK_ENDPOINT}
+ Should Be Equal As Strings ${resp.status_code} 200
+
+
+Post fm notification to dmaap
+ Create Session dmaap ${DMAAP_URL}
+ ${headers}= Create Dictionary Content-Type application/json
+ ${data}= Get File ${TEST_ROBOT_DIR}/data/fault_notification.json
+ ${response}= Evaluate requests.post('${POST_DMAAP_EVENT_FOR_FM_NOTIF_URL}', data=$data)
+ Should Be Equal As Strings ${response.status_code} 200
+
+
+Verify fm notification trigger in sonhms
+ Create Session dmaap ${DMAAP_URL}
+ FOR ${i} IN RANGE 10
+ ${result}= Get Request dmaap ${unauthenticated.DCAE_CL_OUTPUT}
+ Exit For Loop If ${result.json()} != @{EMPTY}
+ Log Waiting for sonhms to handle trigger... console=${True}
+ Sleep 30s
+ END
+ ${expected_payload}= Get File ${TEST_ROBOT_DIR}/data/expected_payload_fm.json
+ ${result}= Convert To String ${result.content}
+ ${result_string}= Get Substring ${result} 2 -2
+ ${actual_data}= Evaluate json.loads("""${result_string}""") json
+ ${actual_payload}= Set Variable ${actual_data['payload']}
+ Should Be True """${actual_payload}""".strip() == """${expected_payload}""".strip()
+
+
+Post pm notification to dmaap
+ ${data}= Get File ${TEST_ROBOT_DIR}/data/performance_notification.json
+ ${response}= Evaluate requests.post('${POST_DMAAP_EVENT_FOR_PM_NOTIF_URL}', data=$data)
+ Should Be Equal As Strings ${response.status_code} 200
+
+
+Verify pm notification trigger in sonhms
+ Create Session dmaap ${DMAAP_URL}
+ FOR ${i} IN RANGE 5
+ ${result}= Get Request dmaap ${unauthenticated.DCAE_CL_OUTPUT}
+ Exit For Loop If ${result.json()} != @{EMPTY}
+ Log Waiting for sonhms to handle trigger... console=${True}
+ Sleep 30s
+ END
+ ${expected_payload}= Get File ${TEST_ROBOT_DIR}/data/expected_payload_pm.json
+ ${result}= Convert To String ${result.content}
+ ${result_string}= Get Substring ${result} 2 -2
+ ${actual_data}= Evaluate json.loads("""${result_string}""") json
+ ${actual_payload}= Set Variable ${actual_data['payload']}
+ Should Be True """${actual_payload}""".strip() == """${expected_payload}""".strip()
+
+
+Post policy negative acknowledgement to dmaap
+ ${data}= Get File ${TEST_ROBOT_DIR}/data/negative_ack_from_policy.json
+ FOR ${i} IN RANGE 3
+ ${response}= Evaluate requests.post('${POST_DMAAP_EVENT_FOR_POLICY_RESPONSE}', data=$data)
+ END
+ Should Be Equal As Strings ${response.status_code} 200
+
+
+Oof trigger for fixed Pci cells
+ Create Session dmaap ${DMAAP_URL}
+ FOR ${i} IN RANGE 15
+ ${result}= Get Request dmaap ${unauthenticated.DCAE_CL_OUTPUT}
+ Exit For Loop If ${result.json()} != @{EMPTY}
+ Log Waiting for sonhms to handle trigger... console=${True}
+ Sleep 30s
+ END
+ ${expected_payload}= Get File ${TEST_ROBOT_DIR}/data/expected_payload_fm.json
+ ${result}= Convert To String ${result.content}
+ ${result_string}= Get Substring ${result} 2 -2
+ ${actual_data}= Evaluate json.loads("""${result_string}""") json
+ ${actual_payload}= Set Variable ${actual_data['payload']}
+ Should Be True """${actual_payload}""".strip() == """${expected_payload}""".strip()