diff options
Diffstat (limited to 'tests')
59 files changed, 1335 insertions, 922 deletions
diff --git a/tests/dcaegen2-services-bbs-event-processor/bbs-testcases/resources/BbsLibrary.py b/tests/dcaegen2-services-bbs-event-processor/bbs-testcases/resources/BbsLibrary.py index c58e67e2..640b33b0 100644 --- a/tests/dcaegen2-services-bbs-event-processor/bbs-testcases/resources/BbsLibrary.py +++ b/tests/dcaegen2-services-bbs-event-processor/bbs-testcases/resources/BbsLibrary.py @@ -18,7 +18,7 @@ class BbsLibrary(object): alog = container.logs(stream=False, tail=1000) try: - alog = alog.decode() + alog = alog.decode('utf-8').strip() except AttributeError: pass diff --git a/tests/dcaegen2-services-pmsh/testcases/assets/cbs-expectation-unlocked-config.json b/tests/dcaegen2-services-pmsh/testcases/assets/cbs-expectation-unlocked-config.json index b70b41d1..bad79d5f 100644 --- a/tests/dcaegen2-services-pmsh/testcases/assets/cbs-expectation-unlocked-config.json +++ b/tests/dcaegen2-services-pmsh/testcases/assets/cbs-expectation-unlocked-config.json @@ -84,7 +84,7 @@ "dmaap_info": { "client_id": "1475976809466", "client_role": "org.onap.dcae.pmPublisher", - "topic_url": "https://mr-sim:3095/events/org.onap.dmaap.mr.PM_SUBSCRIPTIONS", + "topic_url": "https://mr-sim:3095/events/unauthenticated.DCAE_CL_OUTPUT", "location": "san-francisco" }, "type": "message_router" @@ -103,7 +103,7 @@ "policy_pm_subscriber": { "dmaap_info": { "location": "san-francisco", - "topic_url": "https://mr-sim:3095/events/org.onap.dmaap.mr.PM_SUBSCRIPTIONS", + "topic_url": "https://mr-sim:3095/events/unauthenticated.PMSH_CL_INPUT", "client_role": "org.onap.dcae.pmSubscriber", "client_id": "1575876809456" }, diff --git a/tests/dcaegen2-services-pmsh/testcases/assets/mr-expectation-aai-pnf-created.json b/tests/dcaegen2-services-pmsh/testcases/assets/mr-expectation-aai-pnf-created.json index 1a027f21..860672f4 100644 --- a/tests/dcaegen2-services-pmsh/testcases/assets/mr-expectation-aai-pnf-created.json +++ b/tests/dcaegen2-services-pmsh/testcases/assets/mr-expectation-aai-pnf-created.json @@ -1,7 +1,7 @@ [ { "httpRequest": { - "path": "/events/AAI_EVENT/dcae_pmsh_cg/dcae_pmsh_aai_event", + "path": "/events/AAI_EVENT/.*", "queryStringParameters" : { "timeout" : [ "1000" ] } @@ -24,7 +24,7 @@ }, { "httpRequest": { - "path": "/events/AAI_EVENT/dcae_pmsh_cg/dcae_pmsh_aai_event", + "path": "/events/AAI_EVENT/.*", "queryStringParameters" : { "timeout" : [ "1000" ] } @@ -36,7 +36,7 @@ "application/json" ] }, - "body": "{}" + "body": [] } } ] diff --git a/tests/dcaegen2-services-pmsh/testcases/assets/mr-expectation-aai-pnf-deleted.json b/tests/dcaegen2-services-pmsh/testcases/assets/mr-expectation-aai-pnf-deleted.json index e5c4dd84..8dd58188 100644 --- a/tests/dcaegen2-services-pmsh/testcases/assets/mr-expectation-aai-pnf-deleted.json +++ b/tests/dcaegen2-services-pmsh/testcases/assets/mr-expectation-aai-pnf-deleted.json @@ -1,7 +1,7 @@ [ { "httpRequest": { - "path": "/events/AAI_EVENT/dcae_pmsh_cg/dcae_pmsh_aai_event", + "path": "/events/AAI_EVENT/.*", "queryStringParameters" : { "timeout" : [ "1000" ] } @@ -24,7 +24,7 @@ }, { "httpRequest": { - "path": "/events/AAI_EVENT/dcae_pmsh_cg/dcae_pmsh_aai_event", + "path": "/events/AAI_EVENT/.*", "queryStringParameters" : { "timeout" : [ "1000" ] } @@ -36,7 +36,7 @@ "application/json" ] }, - "body": "{}" + "body": [] } } ] diff --git a/tests/dcaegen2-services-pmsh/testcases/assets/mr-expectation-policy-subscription-created-pnf-existing.json b/tests/dcaegen2-services-pmsh/testcases/assets/mr-expectation-policy-subscription-created-pnf-existing.json index eba4e4ee..cd75deb3 100644 --- a/tests/dcaegen2-services-pmsh/testcases/assets/mr-expectation-policy-subscription-created-pnf-existing.json +++ b/tests/dcaegen2-services-pmsh/testcases/assets/mr-expectation-policy-subscription-created-pnf-existing.json @@ -1,7 +1,7 @@ [ { "httpRequest": { - "path": "/events/unauthenticated.PMSH_CL_INPUT/dcae_pmsh_cg/dcae_pmsh_policy_cl_input", + "path": "/events/unauthenticated.PMSH_CL_INPUT/.*", "queryStringParameters" : { "timeout" : [ "1000" ] } @@ -24,7 +24,7 @@ }, { "httpRequest": { - "path": "/events/unauthenticated.PMSH_CL_INPUT/dcae_pmsh_cg/dcae_pmsh_policy_cl_input", + "path": "/events/unauthenticated.PMSH_CL_INPUT/.*", "queryStringParameters" : { "timeout" : [ "1000" ] } @@ -36,10 +36,7 @@ "application/json" ] }, - "body": { - "type": "JSON", - "json": {} - } + "body": [] } } ] diff --git a/tests/dcaegen2-services-pmsh/testcases/assets/mr-expectation-policy-subscription-created-pnf-new.json b/tests/dcaegen2-services-pmsh/testcases/assets/mr-expectation-policy-subscription-created-pnf-new.json deleted file mode 100644 index f73fee82..00000000 --- a/tests/dcaegen2-services-pmsh/testcases/assets/mr-expectation-policy-subscription-created-pnf-new.json +++ /dev/null @@ -1,45 +0,0 @@ -[ - { - "httpRequest": { - "path": "/events/unauthenticated.PMSH_CL_INPUT/dcae_pmsh_cg/dcae_pmsh_policy_cl_input", - "queryStringParameters" : { - "timeout" : [ "1000" ] - } - }, - "httpResponse": { - "statusCode": 200, - "headers": { - "content-type": [ - "application/json" - ] - }, - "body": [ - "{\"name\": \"ResponseEvent\", \"nameSpace\": \"org.onap.policy.apex.onap.pmcontrol\", \"source\": \"APEX\", \"target\": \"DCAE\", \"version\": \"0.0.1\", \"status\": {\"subscriptionName\": \"ExtraPM-All-gNB-R2B\", \"nfName\": \"pnf_new\", \"changeType\": \"CREATE\", \"message\": \"success\"}}" - ] - }, - "times": { - "remainingTimes": 1, - "unlimited": false - } - }, - { - "httpRequest": { - "path": "/events/unauthenticated.PMSH_CL_INPUT/dcae_pmsh_cg/dcae_pmsh_policy_cl_input", - "queryStringParameters" : { - "timeout" : [ "1000" ] - } - }, - "httpResponse": { - "statusCode": 200, - "headers": { - "content-type": [ - "application/json" - ] - }, - "body": { - "type": "JSON", - "json": {} - } - } - } -] diff --git a/tests/dcaegen2-services-pmsh/testcases/pmsh.robot b/tests/dcaegen2-services-pmsh/testcases/pmsh.robot index a2b8cad6..def53caa 100644 --- a/tests/dcaegen2-services-pmsh/testcases/pmsh.robot +++ b/tests/dcaegen2-services-pmsh/testcases/pmsh.robot @@ -21,7 +21,6 @@ ${SUBSCRIPTIONS_ENDPOINT} /subscriptions ${MR_EXPECTATION_AAI_PNF_CREATED} %{WORKSPACE}/tests/dcaegen2-services-pmsh/testcases/assets/mr-expectation-aai-pnf-created.json ${MR_EXPECTATION_AAI_PNF_REMOVED} %{WORKSPACE}/tests/dcaegen2-services-pmsh/testcases/assets/mr-expectation-aai-pnf-deleted.json -${MR_EXPECTATION_POLICY_RESPONSE_PNF_NEW} %{WORKSPACE}/tests/dcaegen2-services-pmsh/testcases/assets/mr-expectation-policy-subscription-created-pnf-new.json ${MR_EXPECTATION_POLICY_RESPONSE_PNF_EXISTING} %{WORKSPACE}/tests/dcaegen2-services-pmsh/testcases/assets/mr-expectation-policy-subscription-created-pnf-existing.json ${CBS_EXPECTATION_ADMIN_STATE_UNLOCKED} %{WORKSPACE}/tests/dcaegen2-services-pmsh/testcases/assets/cbs-expectation-unlocked-config.json @@ -62,18 +61,18 @@ Verify PNF detected in AAI when administrative state unlocked Verify Policy response on MR is handled [Tags] PMSH_04 [Documentation] Verify policy response on MR is handled - [Timeout] 40 seconds + [Timeout] 60 seconds SimulatePolicyResponse ${MR_EXPECTATION_POLICY_RESPONSE_PNF_EXISTING} - Sleep 15 seconds Ensure Policy response on MR is picked up + Sleep 31 seconds Ensure Policy response on MR is picked up ${resp}= Get Request pmsh_session ${SUBSCRIPTIONS_ENDPOINT} Should Be Equal As Strings ${resp.json()[0]['network_functions'][0]['nf_sub_status']} CREATED Verify AAI event on MR detailing new PNF being detected is handled [Tags] PMSH_05 [Documentation] Verify PNF created AAI event on MR is handled - [Timeout] 30 seconds + [Timeout] 60 seconds SimulateNewPNF - Sleep 15 seconds Ensure AAI event on MR is picked up + Sleep 31 seconds Ensure AAI event on MR is picked up ${resp}= Get Request pmsh_session ${SUBSCRIPTIONS_ENDPOINT} Should Be Equal As Strings ${resp.json()[0]['network_functions'][1]['nf_name']} pnf_newly_discovered Should Be Equal As Strings ${resp.json()[0]['network_functions'][1]['orchestration_status']} Active @@ -82,9 +81,9 @@ Verify AAI event on MR detailing new PNF being detected is handled Verify AAI event on MR detailing PNF being deleted is handled [Tags] PMSH_06 [Documentation] Verify PNF deleted AAI event on MR is handled - [Timeout] 30 seconds + [Timeout] 60 seconds SimulateDeletedPNF - Sleep 12 seconds Ensure AAI event on MR is picked up + Sleep 31 seconds Ensure AAI event on MR is picked up ${resp}= Get Request pmsh_session ${SUBSCRIPTIONS_ENDPOINT} Should Not Contain ${resp.text} pnf_newly_discovered 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 00000000..d542a7dd --- /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 00000000..2a56f2cc --- /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 00000000..e5a327ad --- /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 00000000..8988f1cd --- /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 00000000..7721163a --- /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 00000000..6e93ffb9 --- /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() diff --git a/tests/dcaegen2/testcases/02__cert_basic_auth_tests.robot b/tests/dcaegen2/testcases/02__cert_basic_auth_tests.robot index 216f4055..dcc94de3 100644 --- a/tests/dcaegen2/testcases/02__cert_basic_auth_tests.robot +++ b/tests/dcaegen2/testcases/02__cert_basic_auth_tests.robot @@ -4,7 +4,7 @@ Resource ./resources/dcae_keywords.robot Enable VESC HTTPS with certBasicAuth [Tags] DCAE-VESC-R1 DCAE-VESC-HC [Documentation] Enable VESC Https and Authentication and Run Health Check - Enable VESC with certBasicAuth + Override Collector Properties ${VES_CERT_BASIC_AUTH_COLLECTOR_PROPERTIES} Run Healthcheck ${https_basic_auth_session} VES Collector HTTP Health Check with certBasicAuth @@ -53,11 +53,6 @@ Publish Single VES VNF Measurement Event with certBasicAuth over HTTPS [Documentation] Post single event with valid data and valid username/password to /eventListener/v7 endpoint over HTTPS and expect 202 Response Status Code Send Request And Validate Response Publish Event To VES Collector ${https_basic_auth_session} ${VES_EVENTLISTENER_V7} ${VES_VALID_JSON_V7} 202 ab305d54-85b4-a31b-7db2-fb6b9e546015 -Publish Single VES VNF Measurement Event with Standard Defined Fields with certBasicAuth over HTTPS - [Tags] DCAE-VESC-R1 - [Documentation] Post single event with valid data with Standard Defined Fields and valid username/password to /eventListener/v7 endpoint over HTTPS and expect 202 Response Status Code - Send Request And Validate Response Publish Event To VES Collector ${https_basic_auth_session} ${VES_EVENTLISTENER_V7} ${VES_VALID_JSON_V7_STND_DEF_FIELDS} 202 stndDefined-gNB-Nokia-PowerLost - Publish Single VES VNF Measurement Event over HTTPS with wrong JSON [Tags] DCAE-VESC-R1 [Documentation] Post single event with invalid data and valid username/password to /eventListener/v7 endpoint over HTTPS and expect 400 Response Status Code @@ -121,43 +116,3 @@ Publish V7 Batch Event Without Auth And Cert [Tags] DCAE-VESC-R1 [Documentation] Post single event with valid data and without certificate or username/password to /eventListener/v7/eventBatch endpoint over HTTPS and expect 401 Response Status Code Send Request And Validate Response Publish Event To VES Collector ${https_no_cert_no_auth_session} ${VES_BATCH_EVENT_ENDPOINT_V7} ${VES_VALID_BATCH_JSON_V7} 401 - -Publish VES Event With Empty Stnd Domain Namespace Parameter - [Tags] DCAE-VESC-R1 - [Documentation] Post single event with invalid data (empty stnd namespace parameter) to /eventListener/v7 endpoint, expect 400 Response Status Code and "Mandatory input event.commonEventHeader.stndDefinedNamespace is empty in request" message - Send Request And Validate Response And Error Message Publish Event To VES Collector ${https_basic_auth_session} ${VES_EVENTLISTENER_V7} ${VES_STDN_DEFINED_EMMPTY_NAMESPACE} 400 Mandatory input attribute event.commonEventHeader.stndDefinedNamespace is empty in request - -Publish VES Event With Missing Stnd Domain Namespace Parameter - [Tags] DCAE-VESC-R1 - [Documentation] Post single event with invalid data (missing stnd namespace parameter) to /eventListener/v7 endpoint, expect 400 Response Status Code and "Mandatory input attribute event.commonEventHeader.stndDefinedNamespace is missing from request" message - Send Request And Validate Response And Error Message Publish Event To VES Collector ${https_basic_auth_session} ${VES_EVENTLISTENER_V7} ${VES_STDN_DEFINED_MISSING_NAMESPACE} 400 Mandatory input attribute event.commonEventHeader.stndDefinedNamespace is missing from request - -Publish Single VES Event With Empty JSON - [Tags] DCAE-VESC-R1 - [Documentation] Post single event with empty json and expect 400 Response Status Code - Send Request And Validate Response Publish Event To VES Collector ${https_basic_auth_session} ${VES_EVENTLISTENER_V7} ${VES_EMPTY_JSON} 400 - -Publish Single VES Event With Missing SourceName Parameter - [Tags] DCAE-VESC-R1 - [Documentation] Post single event with empty json and expect 400 Response Status Code - Send Request And Validate Response Publish Event To VES Collector ${https_basic_auth_session} ${VES_EVENTLISTENER_V7} ${VES_NAMESPACE_3GPP_PROVISIONING_MISSING_SOURCENAME} 400 - -Publish Single VES Event With stndDefinedNamespace = 3GPP-Provisioning - [Tags] DCAE-VESC-R1 - [Documentation] Post single event with stndDefinedNamespace = 3GPP-Provisioning and event should routed to topic unauthenticated.SEC_3GPP_PROVISIONING_OUTPUT - Send Request And Validate Response Publish Event To VES Collector ${https_basic_auth_session} ${VES_EVENTLISTENER_V7} ${VES_STDN_DEFINED_3GPP_PROVISIONING} 202 unauthenticated.SEC_3GPP_PROVISIONING_OUTPUT - -Publish Single VES Event With stndDefinedNamespace = 3GPP-Heartbeat - [Tags] DCAE-VESC-R1 - [Documentation] Post single event with stndDefinedNamespace = 3GPP-Heartbeat and event should routed to topic unauthenticated.SEC_3GPP_HEARTBEAT_OUTPUT - Send Request And Validate Response Publish Event To VES Collector ${https_basic_auth_session} ${VES_EVENTLISTENER_V7} ${VES_STDN_DEFINED_3GPP_HEARTBEAT} 202 unauthenticated.SEC_3GPP_HEARTBEAT_OUTPUT - -Publish Single VES Event With stndDefinedNamespace = 3GPP-PerformanceAssurance - [Tags] DCAE-VESC-R1 - [Documentation] Post single event with stndDefinedNamespace = 3GPP-PerformanceAssurance and event should routed to topic unauthenticated.SEC_3GPP_PERFORMANCEASSURANCE_OUTPUT - Send Request And Validate Response Publish Event To VES Collector ${https_basic_auth_session} ${VES_EVENTLISTENER_V7} ${VES_STDN_DEFINED_3GPP_PERFORMANCE_ASSURANCE} 202 unauthenticated.SEC_3GPP_PERFORMANCEASSURANCE_OUTPUT - -Publish Single VES Event With stndDefinedNamespace = 3GPP-FaultSupervision - [Tags] DCAE-VESC-R1 - [Documentation] Post single event with stndDefinedNamespace = 3GPP-FaultSupervision and event should routed to topic unauthenticated.SEC_3GPP_FAULTSUPERVISION_OUTPUT - Send Request And Validate Response Publish Event To VES Collector ${https_basic_auth_session} ${VES_EVENTLISTENER_V7} ${VES_STDN_DEFINED_3GPP_FAULTSUPERVISION} 202 unauthenticated.SEC_3GPP_FAULTSUPERVISION_OUTPUT
\ No newline at end of file diff --git a/tests/dcaegen2/testcases/03__stndDefined_tests.robot b/tests/dcaegen2/testcases/03__stndDefined_tests.robot new file mode 100644 index 00000000..ddd11fa8 --- /dev/null +++ b/tests/dcaegen2/testcases/03__stndDefined_tests.robot @@ -0,0 +1,87 @@ +*** Settings *** +Resource ./resources/dcae_keywords.robot +*** Test Cases *** + +################################################### +# Section for tests with stndDefined validation ON +################################################### +Publish Single VES VNF Measurement Event with Standard Defined Fields with certBasicAuth over HTTPS + [Tags] DCAE-VESC-R1 + [Documentation] Post single event with valid data with Standard Defined Fields and valid username/password to /eventListener/v7 endpoint over HTTPS and expect 202 Response Status Code + Send Request And Validate Response Publish Event To VES Collector ${https_basic_auth_session} ${VES_EVENTLISTENER_V7} ${VES_VALID_JSON_V7_STND_DEF_FIELDS} 202 stndDefined-gNB-Nokia-PowerLost + +Publish VES Event With Empty Stnd Domain Namespace Parameter + [Tags] DCAE-VESC-R1 DCAE-VESC-STNDDEFINED + [Documentation] Post single event with invalid data (empty stnd namespace parameter) to /eventListener/v7 endpoint, expect 400 Response Status Code and "Mandatory input %1 %2 is empty in request" message + Send Request And Validate Response And Error Message Publish Event To VES Collector ${https_basic_auth_session} ${VES_EVENTLISTENER_V7} ${VES_STND_DEFINED_EMPTY_NAMESPACE} 400 Mandatory input %1 %2 is empty in request + +Publish VES Event With Missing Stnd Domain Namespace Parameter + [Tags] DCAE-VESC-R1 DCAE-VESC-STNDDEFINED + [Documentation] Post single event with invalid data (missing stnd namespace parameter) to /eventListener/v7 endpoint, expect 400 Response Status Code and "Mandatory input %1 %2 is missing from request" message + Send Request And Validate Response And Error Message Publish Event To VES Collector ${https_basic_auth_session} ${VES_EVENTLISTENER_V7} ${VES_STND_DEFINED_MISSING_NAMESPACE} 400 Mandatory input %1 %2 is missing from request + +Publish Single VES Event With Empty JSON + [Tags] DCAE-VESC-R1 DCAE-VESC-STNDDEFINED + [Documentation] Post single event with empty json and expect 400 Response Status Code + Send Request And Validate Response Publish Event To VES Collector ${https_basic_auth_session} ${VES_EVENTLISTENER_V7} ${VES_EMPTY_JSON} 400 + +Publish Single VES Event With Missing SourceName Parameter + [Tags] DCAE-VESC-R1 DCAE-VESC-STNDDEFINED + [Documentation] Post single event with empty json and expect 400 Response Status Code + Send Request And Validate Response Publish Event To VES Collector ${https_basic_auth_session} ${VES_EVENTLISTENER_V7} ${VES_NAMESPACE_3GPP_PROVISIONING_MISSING_SOURCENAME} 400 + +Publish Single VES Event With stndDefinedNamespace = 3GPP-Provisioning + [Tags] DCAE-VESC-R1 DCAE-VESC-STNDDEFINED + [Documentation] Post single event with stndDefinedNamespace = 3GPP-Provisioning and event should routed to topic unauthenticated.SEC_3GPP_PROVISIONING_OUTPUT + Send Request And Validate Response Publish Event To VES Collector ${https_basic_auth_session} ${VES_EVENTLISTENER_V7} ${VES_STND_DEFINED_3GPP_PROVISIONING} 202 unauthenticated.SEC_3GPP_PROVISIONING_OUTPUT + +Publish Single VES Event With stndDefinedNamespace = 3GPP-Heartbeat + [Tags] DCAE-VESC-R1 DCAE-VESC-STNDDEFINED + [Documentation] Post single event with stndDefinedNamespace = 3GPP-Heartbeat and event should routed to topic unauthenticated.SEC_3GPP_HEARTBEAT_OUTPUT + Send Request And Validate Response Publish Event To VES Collector ${https_basic_auth_session} ${VES_EVENTLISTENER_V7} ${VES_STND_DEFINED_3GPP_HEARTBEAT} 202 unauthenticated.SEC_3GPP_HEARTBEAT_OUTPUT + +Publish Single VES Event With stndDefinedNamespace = 3GPP-PerformanceAssurance + [Tags] DCAE-VESC-R1 DCAE-VESC-STNDDEFINED + [Documentation] Post single event with stndDefinedNamespace = 3GPP-PerformanceAssurance and event should routed to topic unauthenticated.SEC_3GPP_PERFORMANCEASSURANCE_OUTPUT + Send Request And Validate Response Publish Event To VES Collector ${https_basic_auth_session} ${VES_EVENTLISTENER_V7} ${VES_STND_DEFINED_3GPP_PERFORMANCE_ASSURANCE} 202 unauthenticated.SEC_3GPP_PERFORMANCEASSURANCE_OUTPUT + +Publish Single VES Event With stndDefinedNamespace = 3GPP-FaultSupervision + [Tags] DCAE-VESC-R1 DCAE-VESC-STNDDEFINED + [Documentation] Post single event with stndDefinedNamespace = 3GPP-FaultSupervision and event should routed to topic unauthenticated.SEC_3GPP_FAULTSUPERVISION_OUTPUT + Send Request And Validate Response Publish Event To VES Collector ${https_basic_auth_session} ${VES_EVENTLISTENER_V7} ${VES_STND_DEFINED_3GPP_FAULTSUPERVISION} 202 unauthenticated.SEC_3GPP_FAULTSUPERVISION_OUTPUT + +Publish Single VES Event With SchemaReference Field Not Set + [Tags] DCAE-VESC-R1 DCAE-VESC-STNDDEFINED + [Documentation] Post single event with schemaReference not set and not perform stndDefined validation, but pass general validation stage + Send Request And Validate Response Publish Event To VES Collector ${https_basic_auth_session} ${VES_EVENTLISTENER_V7} ${VES_STND_DEFINED_INVALID_DATA_NO_SCHEMA_REF} 202 unauthenticated.SEC_3GPP_FAULTSUPERVISION_OUTPUT + +Publish Single VES Event With Incorrect Schema Reference + [Tags] DCAE-VESC-R1 DCAE-VESC-STNDDEFINED + [Documentation] Post single event with incorrect schemaReference and return error + Send Request And Validate Response And Error Message Publish Event To VES Collector ${https_basic_auth_session} ${VES_EVENTLISTENER_V7} ${VES_STND_DEFINED_INCORRECT_SCHEMA_REF} 400 Invalid input value for %1 %2: %3 + +Publish Single VES Event With Empty StndDefined Data Field + [Tags] DCAE-VESC-R1 DCAE-VESC-STNDDEFINED + [Documentation] Post single event with Empty stndDefined data field and return error + Send Request And Validate Response And Error Message Publish Event To VES Collector ${https_basic_auth_session} ${VES_EVENTLISTENER_V7} ${VES_STND_DEFINED_EMPTY_DATA} 400 The following service error occurred: %1. Error code is %2 + +Publish Single VES Event With Invalid Type Of Multiply StndDefined Data Fields + [Tags] DCAE-VESC-R1 DCAE-VESC-STNDDEFINED + [Documentation] Post single event with invalid stndDefined data fields and return error + Send Request And Validate Response And Error Message Publish Event To VES Collector ${https_basic_auth_session} ${VES_EVENTLISTENER_V7} ${VES_STND_DEFINED_INVALID_TYPE_DATA} 400 The following service error occurred: %1. Error code is %2 + + +##################################################### +## Section for tests with stndDefined validation OFF +##################################################### +Disable VESC StndDefined Validation Checkflag + [Tags] DCAE-VESC-R1 DCAE-VESC-HC DCAE-VESC-STNDDEFINED + [Documentation] Disable VESC StndDefined Validation Checkflag and Run Health Check + Override Collector Properties ${VES_DISABLED_STNDDEFINED_COLLECTOR_PROPERTIES} + Run Healthcheck ${https_basic_auth_session} + +Publish Single VES Event With Incorrect StndDefined Data + [Tags] DCAE-VESC-R1 DCAE-VESC-STNDDEFINED + [Documentation] Post single event with incorrect stndDefined data + Send Request And Validate Response Publish Event To VES Collector ${https_basic_auth_session} ${VES_EVENTLISTENER_V7} ${VES_STND_DEFINED_INVALID_TYPE_DATA} 202 + diff --git a/tests/dcaegen2/testcases/assets/json_events/ves7_valid_eventWithStndDefinedFields.json b/tests/dcaegen2/testcases/assets/json_events/ves7_valid_eventWithStndDefinedFields.json index 5d40b9d9..99b7ce37 100644 --- a/tests/dcaegen2/testcases/assets/json_events/ves7_valid_eventWithStndDefinedFields.json +++ b/tests/dcaegen2/testcases/assets/json_events/ves7_valid_eventWithStndDefinedFields.json @@ -1,47 +1,52 @@ { "event": { "commonEventHeader": { + "version": "4.1", + "vesEventListenerVersion": "7.2", "domain": "stndDefined", "eventId": "stndDefined-gNB_Nokia000001", "eventName": "stndDefined-gNB-Nokia-PowerLost", "stndDefinedNamespace": "3GPP-FaultSupervision", - "lastEpochMicrosec": 1234567890, - "priority": "Normal", - "reportingEntityName": "Nokia123456", - "sequence": 0, - "sourceName": "Nokia123456", - "startEpochMicrosec": 1234567890, - "version": "4.1", - "vesEventListenerVersion": "7.2" + "startEpochMicrosec": 1413378172000000, + "lastEpochMicrosec": 1413378172000000, + "reportingEntityName": "ibcx0001vm002oam001", + "sourceName": "scfx0001vm002cap001", + "sequence": 1, + "priority": "High" }, "stndDefinedFields": { - "schemaReference": "https://www.3gpp.org/Rel-16/TS28532_generic_fault_supervision.json#definitions/schemas/notifyNewAlarm-NotifType", + "schemaReference": "https://forge.3gpp.org/rep/sa5/data-models/blob/REL-16/OpenAPI/faultMnS.yaml#components/schemas/NotifyNewAlarm", "data": { - "header": { - "uri": "xyz", - "notificationId": "xyz", - "notificationType": "notifyNewAlarm", - "eventTime": "xyz", - "systemDN": "xyz" + "href": 1, + "uri": "1", + "notificationId": 1, + "notificationType": "notifyNewAlarm", + "eventTime": "xyz", + "systemDN": "xyz", + "probableCause": 1, + "perceivedSeverity": "INDETERMINATE", + "rootCauseIndicator": false, + "specificProblem": "xyz", + "correlatedNotifications": [], + "backedUpStatus": true, + "backUpObject": "xyz", + "trendIndication": "MORE_SEVERE", + "thresholdInfo": { + "observedMeasurement": "new", + "observedValue": 123 + }, + "stateChangeDefinition": { + }, + "monitoredAttributes": { + "newAtt": "new" + }, + "proposedRepairActions": "xyz", + "additionalText": "xyz", + "additionalInformation": { + "addInfo": "new" }, - "body": { - "probableCause": "xyz", - "perceivedSeverity": "Major", - "rootCauseIndicator": false, - "specificProblem": "xyz", - "correlatedNotifications": [], - "backedUpStatus": true, - "backUpObject": "xyz", - "trendIndication": "No change", - "thresholdInfo": {}, - "stateChangeDefinition": [], - "monitoredAttributes": [], - "proposedRepairActions": "xyz", - "additionalText": "xyz", - "additionalInformation": [], - "alarmId": "xyz", - "alarmType": "Environmental Alarm" - } + "alarmId": "1", + "alarmType": "COMMUNICATIONS_ALARM" }, "stndDefinedFieldsVersion": "1.0" } diff --git a/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_3GPP-FaultSupervision.json b/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_3GPP-FaultSupervision.json index aa026e71..0d749f30 100644 --- a/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_3GPP-FaultSupervision.json +++ b/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_3GPP-FaultSupervision.json @@ -1,43 +1,52 @@ { "event": { "commonEventHeader": { + "version": "4.1", + "vesEventListenerVersion": "7.2", "domain": "stndDefined", "eventId": "stndDefined-gNB_Nokia000001", "eventName": "stndDefined-gNB-Nokia-PowerLost", "stndDefinedNamespace": "3GPP-FaultSupervision", - "lastEpochMicrosec": 1234567890, - "priority": "Normal", - "reportingEntityName": "Nokia123456", - "sequence": 0, - "sourceName": "Nokia123456", - "startEpochMicrosec": 1234567890, - "version": "4.1", - "vesEventListenerVersion": "7.2" + "startEpochMicrosec": 1413378172000000, + "lastEpochMicrosec": 1413378172000000, + "reportingEntityName": "ibcx0001vm002oam001", + "sourceName": "scfx0001vm002cap001", + "sequence": 1, + "priority": "High" }, "stndDefinedFields": { - "schemaReference": "https://www.3gpp.org/Rel-16/TS28532_generic_fault_supervision.json#definitions/schemas/notifyNewAlarm-NotifType", + "schemaReference": "https://forge.3gpp.org/rep/sa5/data-models/blob/REL-16/OpenAPI/faultMnS.yaml#components/schemas/NotifyNewAlarm", "data": { - "uri": "xyz", - "notificationId": "xyz", + "href": 1, + "uri": "1", + "notificationId": 1, "notificationType": "notifyNewAlarm", "eventTime": "xyz", "systemDN": "xyz", - "probableCause": "xyz", - "perceivedSeverity": "Major", + "probableCause": 1, + "perceivedSeverity": "INDETERMINATE", "rootCauseIndicator": false, "specificProblem": "xyz", "correlatedNotifications": [], "backedUpStatus": true, "backUpObject": "xyz", - "trendIndication": "No change", - "thresholdInfo": {}, - "stateChangeDefinition": [], - "monitoredAttributes": [], + "trendIndication": "MORE_SEVERE", + "thresholdInfo": { + "observedMeasurement": "new", + "observedValue": 123 + }, + "stateChangeDefinition": { + }, + "monitoredAttributes": { + "newAtt": "new" + }, "proposedRepairActions": "xyz", "additionalText": "xyz", - "additionalInformation": [], - "alarmId": "xyz", - "alarmType": "Environmental Alarm" + "additionalInformation": { + "addInfo": "new" + }, + "alarmId": "1", + "alarmType": "COMMUNICATIONS_ALARM" }, "stndDefinedFieldsVersion": "1.0" } diff --git a/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_3GPP-Heartbeat.json b/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_3GPP-Heartbeat.json index 7e274c20..414904f5 100644 --- a/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_3GPP-Heartbeat.json +++ b/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_3GPP-Heartbeat.json @@ -1,43 +1,52 @@ { "event": { "commonEventHeader": { + "version": "4.1", + "vesEventListenerVersion": "7.2", "domain": "stndDefined", "eventId": "stndDefined-gNB_Nokia000001", "eventName": "stndDefined-gNB-Nokia-PowerLost", "stndDefinedNamespace": "3GPP-Heartbeat", - "lastEpochMicrosec": 1234567890, - "priority": "Normal", - "reportingEntityName": "Nokia123456", - "sequence": 0, - "sourceName": "Nokia123456", - "startEpochMicrosec": 1234567890, - "version": "4.1", - "vesEventListenerVersion": "7.2" + "startEpochMicrosec": 1413378172000000, + "lastEpochMicrosec": 1413378172000000, + "reportingEntityName": "ibcx0001vm002oam001", + "sourceName": "scfx0001vm002cap001", + "sequence": 1, + "priority": "High" }, "stndDefinedFields": { - "schemaReference": "https://www.3gpp.org/Rel-16/TS28532_generic_fault_supervision.json#definitions/schemas/notifyNewAlarm-NotifType", + "schemaReference": "https://forge.3gpp.org/rep/sa5/data-models/blob/REL-16/OpenAPI/faultMnS.yaml#components/schemas/NotifyNewAlarm", "data": { - "uri": "xyz", - "notificationId": "xyz", + "href": 1, + "uri": "1", + "notificationId": 1, "notificationType": "notifyNewAlarm", "eventTime": "xyz", "systemDN": "xyz", - "probableCause": "xyz", - "perceivedSeverity": "Major", + "probableCause": 1, + "perceivedSeverity": "INDETERMINATE", "rootCauseIndicator": false, "specificProblem": "xyz", "correlatedNotifications": [], "backedUpStatus": true, "backUpObject": "xyz", - "trendIndication": "No change", - "thresholdInfo": {}, - "stateChangeDefinition": [], - "monitoredAttributes": [], + "trendIndication": "MORE_SEVERE", + "thresholdInfo": { + "observedMeasurement": "new", + "observedValue": 123 + }, + "stateChangeDefinition": { + }, + "monitoredAttributes": { + "newAtt": "new" + }, "proposedRepairActions": "xyz", "additionalText": "xyz", - "additionalInformation": [], - "alarmId": "xyz", - "alarmType": "Environmental Alarm" + "additionalInformation": { + "addInfo": "new" + }, + "alarmId": "1", + "alarmType": "COMMUNICATIONS_ALARM" }, "stndDefinedFieldsVersion": "1.0" } diff --git a/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_3GPP-PerformanceAssurance.json b/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_3GPP-PerformanceAssurance.json index 06520396..8e1f697f 100644 --- a/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_3GPP-PerformanceAssurance.json +++ b/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_3GPP-PerformanceAssurance.json @@ -1,43 +1,52 @@ { "event": { "commonEventHeader": { + "version": "4.1", + "vesEventListenerVersion": "7.2", "domain": "stndDefined", "eventId": "stndDefined-gNB_Nokia000001", "eventName": "stndDefined-gNB-Nokia-PowerLost", "stndDefinedNamespace": "3GPP-PerformanceAssurance", - "lastEpochMicrosec": 1234567890, - "priority": "Normal", - "reportingEntityName": "Nokia123456", - "sequence": 0, - "sourceName": "Nokia123456", - "startEpochMicrosec": 1234567890, - "version": "4.1", - "vesEventListenerVersion": "7.2" + "startEpochMicrosec": 1413378172000000, + "lastEpochMicrosec": 1413378172000000, + "reportingEntityName": "ibcx0001vm002oam001", + "sourceName": "scfx0001vm002cap001", + "sequence": 1, + "priority": "High" }, "stndDefinedFields": { - "schemaReference": "https://www.3gpp.org/Rel-16/TS28532_generic_fault_supervision.json#definitions/schemas/notifyNewAlarm-NotifType", + "schemaReference": "https://forge.3gpp.org/rep/sa5/data-models/blob/REL-16/OpenAPI/faultMnS.yaml#components/schemas/NotifyNewAlarm", "data": { - "uri": "xyz", - "notificationId": "xyz", + "href": 1, + "uri": "1", + "notificationId": 1, "notificationType": "notifyNewAlarm", "eventTime": "xyz", "systemDN": "xyz", - "probableCause": "xyz", - "perceivedSeverity": "Major", + "probableCause": 1, + "perceivedSeverity": "INDETERMINATE", "rootCauseIndicator": false, "specificProblem": "xyz", "correlatedNotifications": [], "backedUpStatus": true, "backUpObject": "xyz", - "trendIndication": "No change", - "thresholdInfo": {}, - "stateChangeDefinition": [], - "monitoredAttributes": [], + "trendIndication": "MORE_SEVERE", + "thresholdInfo": { + "observedMeasurement": "new", + "observedValue": 123 + }, + "stateChangeDefinition": { + }, + "monitoredAttributes": { + "newAtt": "new" + }, "proposedRepairActions": "xyz", "additionalText": "xyz", - "additionalInformation": [], - "alarmId": "xyz", - "alarmType": "Environmental Alarm" + "additionalInformation": { + "addInfo": "new" + }, + "alarmId": "1", + "alarmType": "COMMUNICATIONS_ALARM" }, "stndDefinedFieldsVersion": "1.0" } diff --git a/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_3GPP-Provisioning.json b/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_3GPP-Provisioning.json index d9406615..bb37d1e2 100644 --- a/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_3GPP-Provisioning.json +++ b/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_3GPP-Provisioning.json @@ -1,43 +1,52 @@ { "event": { "commonEventHeader": { + "version": "4.1", + "vesEventListenerVersion": "7.2", "domain": "stndDefined", "eventId": "stndDefined-gNB_Nokia000001", "eventName": "stndDefined-gNB-Nokia-PowerLost", "stndDefinedNamespace": "3GPP-Provisioning", - "lastEpochMicrosec": 1234567890, - "priority": "Normal", - "reportingEntityName": "Nokia123456", - "sequence": 0, - "sourceName": "Nokia123456", - "startEpochMicrosec": 1234567890, - "version": "4.1", - "vesEventListenerVersion": "7.2" + "startEpochMicrosec": 1413378172000000, + "lastEpochMicrosec": 1413378172000000, + "reportingEntityName": "ibcx0001vm002oam001", + "sourceName": "scfx0001vm002cap001", + "sequence": 1, + "priority": "High" }, "stndDefinedFields": { - "schemaReference": "https://www.3gpp.org/Rel-16/TS28532_generic_fault_supervision.json#definitions/schemas/notifyNewAlarm-NotifType", + "schemaReference": "https://forge.3gpp.org/rep/sa5/data-models/blob/REL-16/OpenAPI/faultMnS.yaml#components/schemas/NotifyNewAlarm", "data": { - "uri": "xyz", - "notificationId": "xyz", + "href": 1, + "uri": "1", + "notificationId": 1, "notificationType": "notifyNewAlarm", "eventTime": "xyz", "systemDN": "xyz", - "probableCause": "xyz", - "perceivedSeverity": "Major", + "probableCause": 1, + "perceivedSeverity": "INDETERMINATE", "rootCauseIndicator": false, "specificProblem": "xyz", "correlatedNotifications": [], "backedUpStatus": true, "backUpObject": "xyz", - "trendIndication": "No change", - "thresholdInfo": {}, - "stateChangeDefinition": [], - "monitoredAttributes": [], + "trendIndication": "MORE_SEVERE", + "thresholdInfo": { + "observedMeasurement": "new", + "observedValue": 123 + }, + "stateChangeDefinition": { + }, + "monitoredAttributes": { + "newAtt": "new" + }, "proposedRepairActions": "xyz", "additionalText": "xyz", - "additionalInformation": [], - "alarmId": "xyz", - "alarmType": "Environmental Alarm" + "additionalInformation": { + "addInfo": "new" + }, + "alarmId": "1", + "alarmType": "COMMUNICATIONS_ALARM" }, "stndDefinedFieldsVersion": "1.0" } diff --git a/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_empty_data_fields.json b/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_empty_data_fields.json new file mode 100644 index 00000000..963d8763 --- /dev/null +++ b/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_empty_data_fields.json @@ -0,0 +1,23 @@ +{ + "event": { + "commonEventHeader": { + "version": "4.1", + "vesEventListenerVersion": "7.2", + "domain": "stndDefined", + "eventId": "stndDefined-gNB_Nokia000001", + "eventName": "stndDefined-gNB-Nokia-PowerLost", + "stndDefinedNamespace": "3GPP-FaultSupervision", + "startEpochMicrosec": 1413378172000000, + "lastEpochMicrosec": 1413378172000000, + "reportingEntityName": "ibcx0001vm002oam001", + "sourceName": "scfx0001vm002cap001", + "sequence": 1, + "priority": "High" + }, + "stndDefinedFields": { + "schemaReference": "https://forge.3gpp.org/rep/sa5/data-models/blob/REL-16/OpenAPI/faultMnS.yaml#components/schemas/NotifyNewAlarm", + "data": {}, + "stndDefinedFieldsVersion": "1.0" + } + } +}
\ No newline at end of file diff --git a/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_empty_namespace.json b/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_empty_namespace.json index bf5f0953..49812e80 100644 --- a/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_empty_namespace.json +++ b/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_empty_namespace.json @@ -1,45 +1,54 @@ { "event": { "commonEventHeader": { + "version": "4.1", + "vesEventListenerVersion": "7.2", "domain": "stndDefined", "eventId": "stndDefined-gNB_Nokia000001", "eventName": "stndDefined-gNB-Nokia-PowerLost", "stndDefinedNamespace": "", - "lastEpochMicrosec": 1234567890, - "priority": "Normal", - "reportingEntityName": "Nokia123456", - "sequence": 0, - "sourceName": "Nokia123456", - "startEpochMicrosec": 1234567890, - "version": "4.1", - "vesEventListenerVersion": "7.2" + "startEpochMicrosec": 1413378172000000, + "lastEpochMicrosec": 1413378172000000, + "reportingEntityName": "ibcx0001vm002oam001", + "sourceName": "scfx0001vm002cap001", + "sequence": 1, + "priority": "High" }, "stndDefinedFields": { - "schemaReference": "https://www.3gpp.org/Rel-16/TS28532_generic_fault_supervision.json#definitions/schemas/notifyNewAlarm-NotifType", + "schemaReference": "https://forge.3gpp.org/rep/sa5/data-models/blob/REL-16/OpenAPI/faultMnS.yaml#components/schemas/NotifyNewAlarm", "data": { - "uri": "xyz", - "notificationId": "xyz", + "href": 1, + "uri": "1", + "notificationId": 1, "notificationType": "notifyNewAlarm", "eventTime": "xyz", "systemDN": "xyz", - "probableCause": "xyz", - "perceivedSeverity": "Major", + "probableCause": 1, + "perceivedSeverity": "INDETERMINATE", "rootCauseIndicator": false, "specificProblem": "xyz", "correlatedNotifications": [], "backedUpStatus": true, "backUpObject": "xyz", - "trendIndication": "No change", - "thresholdInfo": {}, - "stateChangeDefinition": [], - "monitoredAttributes": [], + "trendIndication": "MORE_SEVERE", + "thresholdInfo": { + "observedMeasurement": "new", + "observedValue": 123 + }, + "stateChangeDefinition": { + }, + "monitoredAttributes": { + "newAtt": "new" + }, "proposedRepairActions": "xyz", "additionalText": "xyz", - "additionalInformation": [], - "alarmId": "xyz", - "alarmType": "Environmental Alarm" + "additionalInformation": { + "addInfo": "new" + }, + "alarmId": "1", + "alarmType": "COMMUNICATIONS_ALARM" }, "stndDefinedFieldsVersion": "1.0" } } -} +}
\ No newline at end of file diff --git a/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_incorrect_schema_ref.json b/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_incorrect_schema_ref.json new file mode 100644 index 00000000..bacc7a51 --- /dev/null +++ b/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_incorrect_schema_ref.json @@ -0,0 +1,54 @@ +{ + "event": { + "commonEventHeader": { + "version": "4.1", + "vesEventListenerVersion": "7.2", + "domain": "stndDefined", + "eventId": "stndDefined-gNB_Nokia000001", + "eventName": "stndDefined-gNB-Nokia-PowerLost", + "stndDefinedNamespace": "3GPP-FaultSupervision", + "startEpochMicrosec": 1413378172000000, + "lastEpochMicrosec": 1413378172000000, + "reportingEntityName": "ibcx0001vm002oam001", + "sourceName": "scfx0001vm002cap001", + "sequence": 1, + "priority": "High" + }, + "stndDefinedFields": { + "schemaReference": "https://forge.3gpp.org/rep/sa5/data-models/blob/REL-16/OpenAPI/invalid-ref.json", + "data": { + "href": 1, + "uri": "1", + "notificationId": 1, + "notificationType": "notifyNewAlarm", + "eventTime": "xyz", + "systemDN": "xyz", + "probableCause": 1, + "perceivedSeverity": "INDETERMINATE", + "rootCauseIndicator": false, + "specificProblem": "xyz", + "correlatedNotifications": [], + "backedUpStatus": true, + "backUpObject": "xyz", + "trendIndication": "MORE_SEVERE", + "thresholdInfo": { + "observedMeasurement": "new", + "observedValue": 123 + }, + "stateChangeDefinition": { + }, + "monitoredAttributes": { + "newAtt": "new" + }, + "proposedRepairActions": "xyz", + "additionalText": "xyz", + "additionalInformation": { + "addInfo": "new" + }, + "alarmId": "1", + "alarmType": "COMMUNICATIONS_ALARM" + }, + "stndDefinedFieldsVersion": "1.0" + } + } +}
\ No newline at end of file diff --git a/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_invalid_data_fields_no_schema_ref.json b/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_invalid_data_fields_no_schema_ref.json new file mode 100644 index 00000000..33342c6c --- /dev/null +++ b/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_invalid_data_fields_no_schema_ref.json @@ -0,0 +1,22 @@ +{ + "event": { + "commonEventHeader": { + "version": "4.1", + "vesEventListenerVersion": "7.2", + "domain": "stndDefined", + "eventId": "stndDefined-gNB_Nokia000001", + "eventName": "stndDefined-gNB-Nokia-PowerLost", + "stndDefinedNamespace": "3GPP-FaultSupervision", + "startEpochMicrosec": 1413378172000000, + "lastEpochMicrosec": 1413378172000000, + "reportingEntityName": "ibcx0001vm002oam001", + "sourceName": "scfx0001vm002cap001", + "sequence": 1, + "priority": "High" + }, + "stndDefinedFields": { + "data": {}, + "stndDefinedFieldsVersion": "1.0" + } + } +}
\ No newline at end of file diff --git a/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_invalid_type_data_field.json b/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_invalid_type_data_field.json new file mode 100644 index 00000000..5e9a8b35 --- /dev/null +++ b/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_invalid_type_data_field.json @@ -0,0 +1,54 @@ +{ + "event": { + "commonEventHeader": { + "version": "4.1", + "vesEventListenerVersion": "7.2", + "domain": "stndDefined", + "eventId": "stndDefined-gNB_Nokia000001", + "eventName": "stndDefined-gNB-Nokia-PowerLost", + "stndDefinedNamespace": "3GPP-FaultSupervision", + "startEpochMicrosec": 1413378172000000, + "lastEpochMicrosec": 1413378172000000, + "reportingEntityName": "ibcx0001vm002oam001", + "sourceName": "scfx0001vm002cap001", + "sequence": 1, + "priority": "High" + }, + "stndDefinedFields": { + "schemaReference": "https://forge.3gpp.org/rep/sa5/data-models/blob/REL-16/OpenAPI/faultMnS.yaml#components/schemas/NotifyNewAlarm", + "data": { + "href": 1, + "uri": "1", + "notificationId": 1, + "notificationType": "notifyNewAlarm", + "eventTime": "xyz", + "systemDN": 123, + "probableCause": 1, + "perceivedSeverity": "INDETERMINATE", + "rootCauseIndicator": "false", + "specificProblem": "xyz", + "correlatedNotifications": 123, + "backedUpStatus": "true", + "backUpObject": 123, + "trendIndication": "MORE_SEVERE", + "thresholdInfo": { + "observedMeasurement": "new", + "observedValue": "123" + }, + "stateChangeDefinition": { + }, + "monitoredAttributes": { + "newAtt": "new" + }, + "proposedRepairActions": "xyz", + "additionalText": "xyz", + "additionalInformation": { + "addInfo": "new" + }, + "alarmId": 1, + "alarmType": "COMMUNICATIONS_ALARM" + }, + "stndDefinedFieldsVersion": "1.0" + } + } +}
\ No newline at end of file diff --git a/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_missing_namespace.json b/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_missing_namespace.json index 230dc54e..a5a16d12 100644 --- a/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_missing_namespace.json +++ b/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_missing_namespace.json @@ -1,44 +1,53 @@ { "event": { "commonEventHeader": { + "version": "4.1", + "vesEventListenerVersion": "7.2", "domain": "stndDefined", "eventId": "stndDefined-gNB_Nokia000001", "eventName": "stndDefined-gNB-Nokia-PowerLost", - "lastEpochMicrosec": 1234567890, - "priority": "Normal", - "reportingEntityName": "Nokia123456", - "sequence": 0, - "sourceName": "Nokia123456", - "startEpochMicrosec": 1234567890, - "version": "4.1", - "vesEventListenerVersion": "7.2" + "startEpochMicrosec": 1413378172000000, + "lastEpochMicrosec": 1413378172000000, + "reportingEntityName": "ibcx0001vm002oam001", + "sourceName": "scfx0001vm002cap001", + "sequence": 1, + "priority": "High" }, "stndDefinedFields": { - "schemaReference": "https://www.3gpp.org/Rel-16/TS28532_generic_fault_supervision.json#definitions/schemas/notifyNewAlarm-NotifType", + "schemaReference": "https://forge.3gpp.org/rep/sa5/data-models/blob/REL-16/OpenAPI/faultMnS.yaml#components/schemas/NotifyNewAlarm", "data": { - "uri": "xyz", - "notificationId": "xyz", + "href": 1, + "uri": "1", + "notificationId": 1, "notificationType": "notifyNewAlarm", "eventTime": "xyz", "systemDN": "xyz", - "probableCause": "xyz", - "perceivedSeverity": "Major", + "probableCause": 1, + "perceivedSeverity": "INDETERMINATE", "rootCauseIndicator": false, "specificProblem": "xyz", "correlatedNotifications": [], "backedUpStatus": true, "backUpObject": "xyz", - "trendIndication": "No change", - "thresholdInfo": {}, - "stateChangeDefinition": [], - "monitoredAttributes": [], + "trendIndication": "MORE_SEVERE", + "thresholdInfo": { + "observedMeasurement": "new", + "observedValue": 123 + }, + "stateChangeDefinition": { + }, + "monitoredAttributes": { + "newAtt": "new" + }, "proposedRepairActions": "xyz", "additionalText": "xyz", - "additionalInformation": [], - "alarmId": "xyz", - "alarmType": "Environmental Alarm" + "additionalInformation": { + "addInfo": "new" + }, + "alarmId": "1", + "alarmType": "COMMUNICATIONS_ALARM" }, "stndDefinedFieldsVersion": "1.0" } } -} +}
\ No newline at end of file diff --git a/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_no_value.json b/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_no_value.json new file mode 100644 index 00000000..4fee7a1e --- /dev/null +++ b/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_no_value.json @@ -0,0 +1,54 @@ +{ + "event": { + "commonEventHeader": { + "version": "4.1", + "vesEventListenerVersion": "7.2", + "domain": "stndDefined", + "eventId": "stndDefined-gNB_Nokia000001", + "eventName": "stndDefined-gNB-Nokia-PowerLost", + "stndDefinedNamespace": "3GPP-FaultSupervision", + "startEpochMicrosec": 1413378172000000, + "lastEpochMicrosec": 1413378172000000, + "reportingEntityName": "ibcx0001vm002oam001", + "sourceName": "scfx0001vm002cap001", + "sequence": 1, + "priority": "High" + }, + "stndDefinedFields": { + "schemaReference": "https://forge.3gpp.org/rep/sa5/data-models/blob/REL-16/OpenAPI/invalid-ref.json", + "data": { + "href": 1, + "uri": "1", + "notificationId": 1, + "notificationType": "notifyNewAlarm", + "eventTime": "xyz", + "systemDN": "xyz", + "probableCause": 1, + "perceivedSeverity": "INDETERMINATE", + "rootCauseIndicator": false, + "specificProblem": "xyz", + "correlatedNotifications": [], + "backedUpStatus": true, + "backUpObject": "xyz", + "trendIndication": "MORE_SEVERE", + "thresholdInfo": { + "observedMeasurement": "new", + "observedValue": 123 + }, + "stateChangeDefinition": { + }, + "monitoredAttributes": { + "newAtt": "new" + }, + "proposedRepairActions": "xyz", + "additionalText": "xyz", + "additionalInformation": { + "addInfo": "new" + }, + "alarmId": , + "alarmType": "COMMUNICATIONS_ALARM" + }, + "stndDefinedFieldsVersion": "1.0" + } + } +}
\ No newline at end of file diff --git a/tests/dcaegen2/testcases/resources/DMaaP.py b/tests/dcaegen2/testcases/resources/DMaaP.py deleted file mode 100644 index 4c245614..00000000 --- a/tests/dcaegen2/testcases/resources/DMaaP.py +++ /dev/null @@ -1,418 +0,0 @@ -''' -Created on Aug 15, 2017 - -@author: sw6830 -''' -import os -import posixpath -import BaseHTTPServer -import urllib -import urlparse -import cgi -import sys -import shutil -import mimetypes -from jsonschema import validate -import jsonschema -import json -import DcaeVariables -import SimpleHTTPServer - -try: - from cStringIO import StringIO -except ImportError: - from StringIO import StringIO - -EvtSchema = None -DMaaPHttpd = None - - -def clean_up_event(): - sz = DcaeVariables.VESEventQ.qsize() - for i in range(sz): - try: - self.evtQueue.get_nowait() - except: - pass - - -def enque_event(evt): - if DcaeVariables.VESEventQ is not None: - try: - DcaeVariables.VESEventQ.put(evt) - return True - except Exception as e: - print (str(e)) - return False - return False - - -def deque_event(wait_sec=25): - if DcaeVariables.IsRobotRun: - pass - try: - evt = DcaeVariables.VESEventQ.get(True, wait_sec) - return evt - except Exception as e: - if DcaeVariables.IsRobotRun: - pass - - else: - print("DMaaP Event dequeue timeout") - return None - - -class DMaaPHandler(BaseHTTPServer.BaseHTTPRequestHandler): - - def do_PUT(self): - self.send_response(405) - return - - def do_POST(self): - resp_code = 0 - # Parse the form data posted - ''' - form = cgi.FieldStorage( - fp=self.rfile, - headers=self.headers, - environ={'REQUEST_METHOD':'POST', - 'CONTENT_TYPE':self.headers['Content-Type'], - }) - - - form = cgi.FieldStorage( - fp=self.rfile, - headers=self.headers, - environ={"REQUEST_METHOD": "POST"}) - - for item in form.list: - print "%s=%s" % (item.name, item.value) - - ''' - - if 'POST' not in self.requestline: - resp_code = 405 - - ''' - if resp_code == 0: - if '/eventlistener/v5' not in self.requestline and '/eventlistener/v5/eventBatch' not in self.requestline and \ - '/eventlistener/v5/clientThrottlingState' not in self.requestline: - resp_code = 404 - - - if resp_code == 0: - if 'Y29uc29sZTpaakprWWpsbE1qbGpNVEkyTTJJeg==' not in str(self.headers): - resp_code = 401 - ''' - - if resp_code == 0: - topic = self.extract_topic_from_path() - content_len = int(self.headers.getheader('content-length', 0)) - post_body = self.rfile.read(content_len) - - indx = post_body.index("{") - if indx != 0: - post_body = post_body[indx:] - - event = "\""+topic+"\":" + post_body - if not enque_event(event): - print "enque event fails" - - global EvtSchema - try: - if EvtSchema is None: - with open(DcaeVariables.CommonEventSchema) as opened_file: - EvtSchema = json.load(opened_file) - decoded_body = json.loads(post_body) - jsonschema.validate(decoded_body, EvtSchema) - except: - resp_code = 400 - - # Begin the response - if not DcaeVariables.IsRobotRun: - print ("Response Message:") - - ''' - { - "200" : { - "description" : "Success", - "schema" : { - "$ref" : "#/definitions/DR_Pub" - } - } - - rspStr = "{'responses' : {'200' : {'description' : 'Success'}}}" - rspStr1 = "{'count': 1, 'serverTimeMs': 3}" - - ''' - - if resp_code == 0: - if 'clientThrottlingState' in self.requestline: - self.send_response(204) - else: - self.send_response(200) - self.send_header('Content-Type', 'application/json') - self.end_headers() - self.wfile.write("{'count': 1, 'serverTimeMs': 3}") - self.wfile.close() - else: - self.send_response(resp_code) - - ''' - self.end_headers() - self.wfile.write('Client: %s\n' % str(self.client_address)) - self.wfile.write('User-agent: %s\n' % str(self.headers['user-agent'])) - self.wfile.write('Path: %s\n' % self.path) - self.wfile.write('Form data:\n') - self.wfile.close() - - # Echo back information about what was posted in the form - for field in form.keys(): - field_item = form[field] - if field_item.filename: - # The field contains an uploaded file - file_data = field_item.file.read() - file_len = len(file_data) - del file_data - self.wfile.write('\tUploaded %s as "%s" (%d bytes)\n' % \ - (field, field_item.filename, file_len)) - else: - # Regular form value - self.wfile.write('\t%s=%s\n' % (field, form[field].value)) - ''' - return - - def extract_topic_from_path(self): - return self.path["/events/".__len__():] - - def do_GET(self): - """Serve a GET request.""" - f = self.send_head() - if f: - try: - self.copyfile(f, self.wfile) - finally: - f.close() - - def do_HEAD(self): - """Serve a HEAD request.""" - f = self.send_head() - if f: - f.close() - - def send_head(self): - """Common code for GET and HEAD commands. - - This sends the response code and MIME headers. - - Return value is either a file object (which has to be copied - to the outputfile by the caller unless the command was HEAD, - and must be closed by the caller under all circumstances), or - None, in which case the caller has nothing further to do. - - """ - path = self.translate_path(self.path) - if os.path.isdir(path): - parts = urlparse.urlsplit(self.path) - if not parts.path.endswith('/'): - # redirect browser - doing basically what apache does - self.send_response(301) - new_parts = (parts[0], parts[1], parts[2] + '/', - parts[3], parts[4]) - new_url = urlparse.urlunsplit(new_parts) - self.send_header("Location", new_url) - self.end_headers() - return None - for index in "index.html", "index.htm": - index = os.path.join(path, index) - if os.path.exists(index): - path = index - break - else: - return self.list_directory(path) - ctype = self.guess_type(path) - try: - # Always read in binary mode. Opening files in text mode may cause - # newline translations, making the actual size of the content - # transmitted *less* than the content-length! - f = open(path, 'rb') - except IOError: - self.send_error(404, "File not found") - return None - try: - self.send_response(200) - self.send_header("Content-type", ctype) - fs = os.fstat(f.fileno()) - self.send_header("Content-Length", str(fs[6])) - self.send_header("Last-Modified", self.date_time_string(fs.st_mtime)) - self.end_headers() - return f - except: - f.close() - raise - - def list_directory(self, path): - """Helper to produce a directory listing (absent index.html). - - Return value is either a file object, or None (indicating an - error). In either case, the headers are sent, making the - interface the same as for send_head(). - - """ - try: - list_dir = os.listdir(path) - except os.error: - self.send_error(404, "No permission to list directory") - return None - list_dir.sort(key=lambda a: a.lower()) - f = StringIO() - displaypath = cgi.escape(urllib.unquote(self.path)) - f.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">') - f.write("<html>\n<title>Directory listing for %s</title>\n" % displaypath) - f.write("<body>\n<h2>Directory listing for %s</h2>\n" % displaypath) - f.write("<hr>\n<ul>\n") - for name in list_dir: - fullname = os.path.join(path, name) - displayname = linkname = name - # Append / for directories or @ for symbolic links - if os.path.isdir(fullname): - displayname = name + "/" - linkname = name + "/" - if os.path.islink(fullname): - displayname = name + "@" - # Note: a link to a directory displays with @ and links with / - f.write('<li><a href="%s">%s</a>\n' - % (urllib.quote(linkname), cgi.escape(displayname))) - f.write("</ul>\n<hr>\n</body>\n</html>\n") - length = f.tell() - f.seek(0) - self.send_response(200) - encoding = sys.getfilesystemencoding() - self.send_header("Content-type", "text/html; charset=%s" % encoding) - self.send_header("Content-Length", str(length)) - self.end_headers() - return f - - @staticmethod - def translate_path(path): - """Translate a /-separated PATH to the local filename syntax. - - Components that mean special things to the local file system - (e.g. drive or directory names) are ignored. (XXX They should - probably be diagnosed.) - - """ - # abandon query parameters - path = path.split('?', 1)[0] - path = path.split('#', 1)[0] - # Don't forget explicit trailing slash when normalizing. Issue17324 - trailing_slash = path.rstrip().endswith('/') - path = posixpath.normpath(urllib.unquote(path)) - words = path.split('/') - words = filter(None, words) - path = os.getcwd() - for word in words: - if os.path.dirname(word) or word in (os.curdir, os.pardir): - # Ignore components that are not a simple file/directory name - continue - path = os.path.join(path, word) - if trailing_slash: - path += '/' - return path - - @staticmethod - def copyfile(source, outputfile): - """Copy all data between two file objects. - - The SOURCE argument is a file object open for reading - (or anything with a read() method) and the DESTINATION - argument is a file object open for writing (or - anything with a write() method). - - The only reason for overriding this would be to change - the block size or perhaps to replace newlines by CRLF - -- note however that this the default server uses this - to copy binary data as well. - - """ - shutil.copyfileobj(source, outputfile) - - def guess_type(self, path): - """Guess the type of a file. - - Argument is a PATH (a filename). - - Return value is a string of the form type/subtype, - usable for a MIME Content-type header. - - The default implementation looks the file's extension - up in the table self.extensions_map, using application/octet-stream - as a default; however it would be permissible (if - slow) to look inside the data to make a better guess. - - """ - - base, ext = posixpath.splitext(path) - if ext in self.extensions_map: - return self.extensions_map[ext] - ext = ext.lower() - if ext in self.extensions_map: - return self.extensions_map[ext] - else: - return self.extensions_map[''] - - if not mimetypes.inited: - mimetypes.init() # try to read system mime.types - extensions_map = mimetypes.types_map.copy() - extensions_map.update({ - '': 'application/octet-stream', # Default - '.py': 'text/plain', - '.c': 'text/plain', - '.h': 'text/plain', - }) - - -def test(handler_class=DMaaPHandler, server_class=BaseHTTPServer.HTTPServer, protocol="HTTP/1.0", port=3904): - print "Load event schema file: " + DcaeVariables.CommonEventSchema - with open(DcaeVariables.CommonEventSchema) as opened_file: - global EvtSchema - EvtSchema = json.load(opened_file) - - server_address = ('', port) - - handler_class.protocol_version = protocol - httpd = server_class(server_address, handler_class) - - global DMaaPHttpd - DMaaPHttpd = httpd - DcaeVariables.HTTPD = httpd - - sa = httpd.socket.getsockname() - print "Serving HTTP on", sa[0], "port", sa[1], "..." - # httpd.serve_forever() - - -def _main_(handler_class=DMaaPHandler, server_class=BaseHTTPServer.HTTPServer, protocol="HTTP/1.0"): - - if sys.argv[1:]: - port = int(sys.argv[1]) - else: - port = 3904 - - print "Load event schema file: " + DcaeVariables.CommonEventSchema - with open(DcaeVariables.CommonEventSchema) as opened_file: - global EvtSchema - EvtSchema = json.load(opened_file) - - server_address = ('', port) - - handler_class.protocol_version = protocol - httpd = server_class(server_address, handler_class) - - sa = httpd.socket.getsockname() - print "Serving HTTP on", sa[0], "port", sa[1], "..." - httpd.serve_forever() - - -if __name__ == '__main__': - _main_() diff --git a/tests/dcaegen2/testcases/resources/DcaeLibrary.py b/tests/dcaegen2/testcases/resources/DcaeLibrary.py deleted file mode 100644 index a9d5def8..00000000 --- a/tests/dcaegen2/testcases/resources/DcaeLibrary.py +++ /dev/null @@ -1,184 +0,0 @@ -''' -Created on Aug 18, 2017 - -@author: sw6830 -''' -from robot.api import logger -from Queue import Queue -import uuid -import time -import datetime -import json -import threading -import os -import platform -import subprocess -import paramiko -import DcaeVariables -import DMaaP - - -class DcaeLibrary(object): - - def __init__(self): - pass - - @staticmethod - def setup_dmaap_server(port_num=3904): - if DcaeVariables.HttpServerThread is not None: - DMaaP.clean_up_event() - logger.console("Clean up event from event queue before test") - logger.info("DMaaP Server already started") - return "true" - - DcaeVariables.IsRobotRun = True - DMaaP.test(port=port_num) - try: - DcaeVariables.VESEventQ = Queue() - DcaeVariables.HttpServerThread = threading.Thread(name='DMAAP_HTTPServer', target=DMaaP.DMaaPHttpd.serve_forever) - DcaeVariables.HttpServerThread.start() - logger.console("DMaaP Mockup Sever started") - time.sleep(2) - return "true" - except Exception as e: - print (str(e)) - return "false" - - @staticmethod - def shutdown_dmaap(): - if DcaeVariables.HTTPD is not None: - DcaeVariables.HTTPD.shutdown() - logger.console("DMaaP Server shut down") - time.sleep(3) - return "true" - else: - return "false" - - @staticmethod - def cleanup_ves_events(): - if DcaeVariables.HttpServerThread is not None: - DMaaP.clean_up_event() - logger.console("DMaaP event queue is cleaned up") - return "true" - logger.console("DMaaP server not started yet") - return "false" - - @staticmethod - def enable_vesc_with_certBasicAuth(): - global client - if 'Windows' in platform.system(): - try: - client = paramiko.SSHClient() - client.load_system_host_keys() - # client.set_missing_host_key_policy(paramiko.WarningPolicy) - client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - - client.connect(os.environ['CSIT_IP'], port=22, username=os.environ['CSIT_USER'], password=os.environ['CSIT_PD']) - stdin, stdout, stderr = client.exec_command('%{WORKSPACE}/tests/dcaegen2/testcases/resources/vesc_enable_https_auth.sh') - logger.console(stdout.read()) - finally: - client.close() - return - ws = os.environ['WORKSPACE'] - script2run = ws + "/tests/dcaegen2/testcases/resources/vesc_enable_https_auth.sh" - logger.info("Running script: " + script2run) - logger.console("Running script: " + script2run) - subprocess.call(script2run) - time.sleep(5) - return - - @staticmethod - def dmaap_message_receive_on_topic(evtobj, topic): - - evt_str = DMaaP.deque_event() - while evt_str != None: - if evtobj in evt_str and topic in evt_str: - logger.info("DMaaP Receive Expected Publish Event:\n" + evt_str) - logger.info("On Expected Topic:\n" + topic) - return 'true' - evt_str = DMaaP.deque_event() - return 'false' - - @staticmethod - def dmaap_message_receive(evtobj, action='contain'): - - evt_str = DMaaP.deque_event() - while evt_str != None: - if action == 'contain': - if evtobj in evt_str: - logger.info("DMaaP Receive Expected Publish Event:\n" + evt_str) - return 'true' - if action == 'sizematch': - if len(evtobj) == len(evt_str): - return 'true' - if action == 'dictmatch': - evt_dict = json.loads(evt_str) - if cmp(evtobj, evt_dict) == 0: - return 'true' - evt_str = DMaaP.deque_event() - return 'false' - - @staticmethod - def is_json_empty(resp): - logger.info("Enter is_json_empty: resp.text: " + resp.text) - if resp.text is None or len(resp.text) < 2: - return 'True' - return 'False' - - @staticmethod - def generate_uuid(): - """generate a uuid""" - return uuid.uuid4() - - @staticmethod - def get_json_value_list(jsonstr, keyval): - logger.info("Enter Get_Json_Key_Value_List") - if jsonstr is None or len(jsonstr) < 2: - logger.info("No Json data found") - return [] - try: - data = json.loads(jsonstr) - nodelist = [] - for item in data: - nodelist.append(item[keyval]) - return nodelist - except Exception as e: - logger.info("Json data parsing fails") - print str(e) - return [] - - @staticmethod - def generate_millitimestamp_uuid(): - """generate a millisecond timestamp uuid""" - then = datetime.datetime.now() - return int(time.mktime(then.timetuple())*1e3 + then.microsecond/1e3) - - @staticmethod - def test(): - import json - from pprint import pprint - - with open('robot/assets/dcae/ves_volte_single_fault_event.json') as data_file: - data = json.load(data_file) - - data['event']['commonEventHeader']['version'] = '5.0' - pprint(data) - - -if __name__ == '__main__': - ''' - dictStr = "action=getTable,Accept=application/json,Content-Type=application/json,X-FromAppId=1234908903284" - cls = DcaeLibrary() - #dict = cls.create_header_from_string(dictStr) - #print str(dict) - jsonStr = "[{'Node': 'onapfcnsl00', 'CheckID': 'serfHealth', 'Name': 'Serf Health Status', 'ServiceName': '', 'Notes': '', 'ModifyIndex': 6, 'Status': 'passing', 'ServiceID': '', 'ServiceTags': [], 'Output': 'Agent alive and reachable', 'CreateIndex': 6}]" - lsObj = cls.get_json_value_list(jsonStr, 'Status') - print lsObj - ''' - - lib = DcaeLibrary() - lib.enable_vesc_https_auth() - - ret = lib.setup_dmaap_server() - print ret - time.sleep(100000) diff --git a/tests/dcaegen2/testcases/resources/collector.properties b/tests/dcaegen2/testcases/resources/collector_basic_auth.properties index 088b6352..cd417635 100755 --- a/tests/dcaegen2/testcases/resources/collector.properties +++ b/tests/dcaegen2/testcases/resources/collector_basic_auth.properties @@ -54,11 +54,11 @@ collector.schema.file={\"v1\":\"./etc/CommonEventFormat_27.2.json\",\"v2\":\"./e ## default no validation checkflag (-1) ## If enabled (1) - schema files locations must be specified, mapping file path must be specified, schema reference path ## in event json must be specified, path to stndDefined data field in event json must be specified -collector.externalSchema.2ndStageValidation=-1 +collector.externalSchema.checkflag=1 collector.externalSchema.schemasLocation=./etc/externalRepo/ collector.externalSchema.mappingFileLocation=./etc/externalRepo/schema-map.json -collector.externalSchema.schemaRefPath=/event/stndDefinedFields/schemaReference -collector.externalSchema.stndDefinedDataPath=/event/stndDefinedFields/data +event.externalSchema.schemaRefPath=/event/stndDefinedFields/schemaReference +event.externalSchema.stndDefinedDataPath=/event/stndDefinedFields/data ## List all streamid per domain to be supported. The streamid should match to channel name on dmaapfile collector.dmaap.streamid=fault=ves-fault|syslog=ves-syslog|heartbeat=ves-heartbeat|measurementsForVfScaling=ves-measurement|mobileFlow=ves-mobileflow|other=ves-other|stateChange=ves-statechange|thresholdCrossingAlert=ves-thresholdCrossingAlert|voiceQuality=ves-voicequality|sipSignaling=ves-sipsignaling|notification=ves-notification|pnfRegistration=ves-pnfRegistration|3GPP-FaultSupervision=ves-3gpp-fault-supervision|3GPP-Heartbeat=ves-3gpp-heartbeat|3GPP-Provisioning=ves-3gpp-provisioning|3GPP-PerformanceAssurance=ves-3gpp-performance-assurance diff --git a/tests/dcaegen2/testcases/resources/collector_stnd_defined.properties b/tests/dcaegen2/testcases/resources/collector_stnd_defined.properties new file mode 100644 index 00000000..9712dff5 --- /dev/null +++ b/tests/dcaegen2/testcases/resources/collector_stnd_defined.properties @@ -0,0 +1,73 @@ +############################################################################### +## +## Collector Server config +## +## - Default values are shown as commented settings. +## +############################################################################### +## +## HTTP(S) service +## +## Normally: +## +## - 8080 is http service +## - https is disabled by default +## +## - At this time, the server always binds to 0.0.0.0 +## +## +collector.service.port=8080 + +## Authentication is only supported via secure port +## When enabled - require valid keystore defined +collector.service.secure.port=8443 + +# auth.method flags: +# +# noAuth - default option - no security (http) +# certBasicAuth - auth by certificate and basic auth username / password (https) +auth.method=certBasicAuth + +## Combination of userid,hashPassword encoded pwd list to be supported +## userid and pwd comma separated; pipe delimitation between each pair +## Password is generated by crypt-password library using BCrypt algorithm stored in dcaegen2/sdk package +## or https://nexus.onap.org/#nexus-search;quick~crypt-password +header.authlist=sample1,$2a$10$0buh.2WeYwN868YMwnNNEuNEAMNYVU9.FSMJGyIKV3dGET/7oGOi6 + +## The keystore must be setup per installation when secure port is configured +collector.keystore.file.location=etc/keystore +collector.keystore.passwordfile=etc/passwordfile + +collector.cert.subject.matcher=etc/certSubjectMatcher.properties + +## The truststore must be setup per installation when mutual tls support is configured +collector.truststore.file.location=etc/truststore +collector.truststore.passwordfile=etc/trustpasswordfile + +## Schema Validation checkflag +## default no validation checkflag (-1) +## If enabled (1) - schemafile location must be specified +collector.schema.checkflag=1 +collector.schema.file={\"v1\":\"./etc/CommonEventFormat_27.2.json\",\"v2\":\"./etc/CommonEventFormat_27.2.json\",\"v3\":\"./etc/CommonEventFormat_27.2.json\",\"v4\":\"./etc/CommonEventFormat_27.2.json\",\"v5\":\"./etc/CommonEventFormat_28.4.1.json\",\"v7\":\"./etc/CommonEventFormat_30.2_ONAP.json\"} + +## Schema StndDefinedFields Validation checkflag +## default no validation checkflag (-1) +## If enabled (1) - schema files locations must be specified, mapping file path must be specified, schema reference path +## in event json must be specified, path to stndDefined data field in event json must be specified +collector.externalSchema.checkflag=-1 +collector.externalSchema.schemasLocation=./etc/externalRepo/ +collector.externalSchema.mappingFileLocation=./etc/externalRepo/schema-map.json +event.externalSchema.schemaRefPath=/event/stndDefinedFields/schemaReference +event.externalSchema.stndDefinedDataPath=/event/stndDefinedFields/data + +## List all streamid per domain to be supported. The streamid should match to channel name on dmaapfile +collector.dmaap.streamid=fault=ves-fault|syslog=ves-syslog|heartbeat=ves-heartbeat|measurementsForVfScaling=ves-measurement|mobileFlow=ves-mobileflow|other=ves-other|stateChange=ves-statechange|thresholdCrossingAlert=ves-thresholdCrossingAlert|voiceQuality=ves-voicequality|sipSignaling=ves-sipsignaling|notification=ves-notification|pnfRegistration=ves-pnfRegistration|3GPP-FaultSupervision=ves-3gpp-fault-supervision|3GPP-Heartbeat=ves-3gpp-heartbeat|3GPP-Provisioning=ves-3gpp-provisioning|3GPP-PerformanceAssurance=ves-3gpp-performance-assurance +collector.dmaapfile=./etc/DmaapConfig.json + +## Event transformation Flag - when set expects configurable transformation +## defined under ./etc/eventTransform.json +## Enabled by default; to disable set to 0 +event.transform.flag=1 + +# Describes at what frequency (measured in minutes) should application try to fetch config from CBS +collector.dynamic.config.update.frequency=5 diff --git a/tests/dcaegen2/testcases/resources/dcae_keywords.robot b/tests/dcaegen2/testcases/resources/dcae_keywords.robot index 52424e63..b45ee57d 100644 --- a/tests/dcaegen2/testcases/resources/dcae_keywords.robot +++ b/tests/dcaegen2/testcases/resources/dcae_keywords.robot @@ -1,13 +1,14 @@ *** Settings *** Documentation The main interface for interacting with DCAE. It handles low level stuff like managing the http request library and DCAE required fields +Library robot_library.DcaeLibrary +Library robot_library.DmaapLibrary +Library robot_library.CertsLibrary Library RequestsLibrary -Library DcaeLibrary Library OperatingSystem Library Collections -Library CertsLibrary -Variables ../resources/DcaeVariables.py +Variables ./robot_library/DcaeVariables.py Resource ../../../common.robot -Resource ../resources/dcae_properties.robot +Resource ./dcae_properties.robot *** Keywords *** Create sessions @@ -140,14 +141,14 @@ Publish Event To VES Collector With Put Method [Return] ${resp} Send Request And Validate Response And Error Message - [Documentation] Post singel event to passed url and validate received response code and content + [Documentation] Post single event to passed url and validate received response code and content [Arguments] ${keyword} ${session} ${evtpath} ${evtjson} ${resp_code} ${msg_content} ${resp}= Send Request And Validate Response ${keyword} ${session} ${evtpath} ${evtjson} ${resp_code} ${error_message}= Set Variable ${resp.json()['requestError']['ServiceException']['text']} Should Be Equal As Strings ${msg_content} ${error_message} Send Request And Validate Response - [Documentation] Post singel event to passed url with passed data and validate received response + [Documentation] Post single event to passed url with passed data and validate received response [Arguments] ${keyword} ${session} ${evtpath} ${evtjson} ${resp_code} ${msg_code}=None ${topic}=None ${evtdata}= Get Data From File ${evtjson} ${resp}= Run Keyword ${keyword} ${session} ${evtpath} ${evtdata} @@ -159,7 +160,7 @@ Send Request And Validate Response [Return] ${resp} Check Whether Message Received - [Documentation] Validare if message has been received + [Documentation] Validate if message has been received [Arguments] ${msg_code} ${topic} ${ret}= Run Keyword If '${topic}' != 'None' DMaaP Message Receive On Topic ${msg_code} ${topic} ... ELSE DMaaP Message Receive ${msg_code} diff --git a/tests/dcaegen2/testcases/resources/dcae_properties.robot b/tests/dcaegen2/testcases/resources/dcae_properties.robot index cab31afa..65eba841 100644 --- a/tests/dcaegen2/testcases/resources/dcae_properties.robot +++ b/tests/dcaegen2/testcases/resources/dcae_properties.robot @@ -46,13 +46,20 @@ ${EVENT_THROTTLING_STATE_DATA_FILE} %{WORKSPACE}/tests/dcaegen2/testcases/a ${EVENT_PNF_REGISTRATION} %{WORKSPACE}/tests/dcaegen2/testcases/assets/json_events/ves_pnf_registration_event.json ${EVENT_PNF_REGISTRATION_V7} %{WORKSPACE}/tests/dcaegen2/testcases/assets/json_events/ves7_pnf_registration_event.json ${DCAE_HEALTH_CHECK_BODY} %{WORKSPACE}/tests/dcae/testcases/assets/json_events/dcae_healthcheck.json -${VES_STDN_DEFINED_EMMPTY_NAMESPACE} %{WORKSPACE}/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_empty_namespace.json -${VES_STDN_DEFINED_MISSING_NAMESPACE} %{WORKSPACE}/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_missing_namespace.json +${VES_STND_DEFINED_EMPTY_NAMESPACE} %{WORKSPACE}/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_empty_namespace.json +${VES_STND_DEFINED_MISSING_NAMESPACE} %{WORKSPACE}/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_missing_namespace.json ${VES_NAMESPACE_3GPP_PROVISIONING_MISSING_SOURCENAME} %{WORKSPACE}/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_3GPP-Provisioning_missing_sourceName.json -${VES_STDN_DEFINED_3GPP_PROVISIONING} %{WORKSPACE}/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_3GPP-Provisioning.json -${VES_STDN_DEFINED_3GPP_HEARTBEAT} %{WORKSPACE}/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_3GPP-Heartbeat.json -${VES_STDN_DEFINED_3GPP_FAULTSUPERVISION} %{WORKSPACE}/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_3GPP-FaultSupervision.json -${VES_STDN_DEFINED_3GPP_PERFORMANCE_ASSURANCE} %{WORKSPACE}/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_3GPP-PerformanceAssurance.json +${VES_STND_DEFINED_3GPP_PROVISIONING} %{WORKSPACE}/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_3GPP-Provisioning.json +${VES_STND_DEFINED_3GPP_HEARTBEAT} %{WORKSPACE}/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_3GPP-Heartbeat.json +${VES_STND_DEFINED_3GPP_FAULTSUPERVISION} %{WORKSPACE}/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_3GPP-FaultSupervision.json +${VES_STND_DEFINED_3GPP_PERFORMANCE_ASSURANCE} %{WORKSPACE}/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_3GPP-PerformanceAssurance.json +${VES_STND_DEFINED_EMPTY_DATA} %{WORKSPACE}/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_empty_data_fields.json +${VES_STND_DEFINED_INVALID_DATA_NO_SCHEMA_REF} %{WORKSPACE}/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_invalid_data_fields_no_schema_ref.json +${VES_STND_DEFINED_INCORRECT_SCHEMA_REF} %{WORKSPACE}/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_incorrect_schema_ref.json +${VES_STND_DEFINED_NO_VALUE} %{WORKSPACE}/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_no_value.json +${VES_STND_DEFINED_INVALID_TYPE_DATA} %{WORKSPACE}/tests/dcaegen2/testcases/assets/json_events/ves_stdnDefined_invalid_type_data_field.json +${VES_CERT_BASIC_AUTH_COLLECTOR_PROPERTIES} %{WORKSPACE}/tests/dcaegen2/testcases/resources/collector_basic_auth.properties +${VES_DISABLED_STNDDEFINED_COLLECTOR_PROPERTIES} %{WORKSPACE}/tests/dcaegen2/testcases/resources/collector_stnd_defined.properties #DCAE Health Check ${CONFIG_BINDING_URL} http://localhost:8443 diff --git a/tests/dcaegen2/testcases/resources/vesc_enable_https_auth.sh b/tests/dcaegen2/testcases/resources/override_collector_properties.sh index 29700bc5..f6a46e13 100755 --- a/tests/dcaegen2/testcases/resources/vesc_enable_https_auth.sh +++ b/tests/dcaegen2/testcases/resources/override_collector_properties.sh @@ -13,11 +13,21 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +if [ $# -ne 1 ]; then + echo "Incorrect number of parameters" + exit 1 +fi -docker exec vesc /opt/app/VESCollector/bin/appController.sh stop +LOCAL_COLLECTOR_PROPERTIES_PATH=$1 +FILENAME=$(basename $LOCAL_COLLECTOR_PROPERTIES_PATH) +ETC_PATH=/opt/app/VESCollector/etc +APP_CONTROLLER_PATH=/opt/app/VESCollector/bin/appController.sh + +docker exec vesc $APP_CONTROLLER_PATH stop sleep 2 -docker cp ${WORKSPACE}/tests/dcaegen2/testcases/resources/collector.properties vesc:/opt/app/VESCollector/etc +docker cp $LOCAL_COLLECTOR_PROPERTIES_PATH vesc:$ETC_PATH sleep 10 -docker exec vesc /opt/app/VESCollector/bin/appController.sh start +docker exec vesc mv $ETC_PATH/$FILENAME $ETC_PATH/collector.properties +docker exec vesc $APP_CONTROLLER_PATH start sleep 5 -echo "VES Collector Restarted with certBasicAuth" +echo "VES Collector Restarted with overridden collector.properties" diff --git a/tests/dcaegen2/testcases/resources/CertsLibrary.py b/tests/dcaegen2/testcases/resources/robot_library/CertsLibrary.py index b8189422..b8189422 100644 --- a/tests/dcaegen2/testcases/resources/CertsLibrary.py +++ b/tests/dcaegen2/testcases/resources/robot_library/CertsLibrary.py diff --git a/tests/dcaegen2/testcases/resources/robot_library/DcaeLibrary.py b/tests/dcaegen2/testcases/resources/robot_library/DcaeLibrary.py new file mode 100644 index 00000000..d5dd9721 --- /dev/null +++ b/tests/dcaegen2/testcases/resources/robot_library/DcaeLibrary.py @@ -0,0 +1,112 @@ +''' +Created on Aug 18, 2017 + +@author: sw6830 +''' +from robot.api import logger +import uuid +import time +import datetime +import json +import os +import platform +import subprocess +import paramiko + + +class DcaeLibrary(object): + + def __init__(self): + pass + + @staticmethod + def override_collector_properties(properties_path): + global client + if 'Windows' in platform.system(): + try: + DcaeLibrary.change_properties_for_windows_platform_system(properties_path) + finally: + client.close() + return + DcaeLibrary.change_properties_for_non_windows_platform_system(properties_path) + return + + @staticmethod + def change_properties_for_non_windows_platform_system(properties_path): + ws = os.environ['WORKSPACE'] + script2run = ws + '/tests/dcaegen2/testcases/resources/override_collector_properties.sh' + logger.info("Running script: " + script2run) + logger.console("Running script: " + script2run) + subprocess.call([script2run, properties_path]) + time.sleep(5) + + @staticmethod + def change_properties_for_windows_platform_system(properties_path): + global client + client = paramiko.SSHClient() + client.load_system_host_keys() + client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + client.connect(os.environ['CSIT_IP'], port=22, username=os.environ['CSIT_USER'], password=os.environ['CSIT_PD']) + stdin, stdout, stderr = client.exec_command( + '%{WORKSPACE}' + '/tests/dcaegen2/testcases/resources/override_collector_properties.sh', properties_path) + logger.console(stdout.read()) + + @staticmethod + def is_json_empty(resp): + logger.info("Enter is_json_empty: resp.text: " + resp.text) + if resp.text is None or len(resp.text) < 2: + return 'True' + return 'False' + + @staticmethod + def generate_uuid(): + """generate a uuid""" + return uuid.uuid4() + + @staticmethod + def get_json_value_list(jsonstr, keyval): + logger.info("Enter Get_Json_Key_Value_List") + if jsonstr is None or len(jsonstr) < 2: + logger.info("No Json data found") + return [] + try: + return DcaeLibrary.extract_list_of_items_from_json_string(jsonstr, keyval) + except Exception as e: + logger.info("Json data parsing fails") + print str(e) + return [] + + @staticmethod + def extract_list_of_items_from_json_string(jsonstr, keyval): + data = json.loads(jsonstr) + nodelist = [] + for item in data: + nodelist.append(item[keyval]) + return nodelist + + @staticmethod + def generate_millitimestamp_uuid(): + """generate a millisecond timestamp uuid""" + then = datetime.datetime.now() + return int(time.mktime(then.timetuple())*1e3 + then.microsecond/1e3) + + @staticmethod + def test(): + import json + from pprint import pprint + + with open('robot/assets/dcae/ves_volte_single_fault_event.json') as data_file: + data = json.load(data_file) + + data['event']['commonEventHeader']['version'] = '5.0' + pprint(data) + + +if __name__ == '__main__': + + lib = DcaeLibrary() + lib.enable_vesc_https_auth() + + ret = lib.setup_dmaap_server() + print ret + time.sleep(100000) diff --git a/tests/dcaegen2/testcases/resources/DcaeVariables.py b/tests/dcaegen2/testcases/resources/robot_library/DcaeVariables.py index 1617714a..47d169f1 100644 --- a/tests/dcaegen2/testcases/resources/DcaeVariables.py +++ b/tests/dcaegen2/testcases/resources/robot_library/DcaeVariables.py @@ -10,8 +10,4 @@ DCAE_HEALTH_CHECK_URL1 = "http://135.205.228.170:8500" CommonEventSchema = get_environment_variable('WORKSPACE') + "/tests/dcaegen2/testcases/assets/json_events/CommonEventFormat_30.2_ONAP.json" -HttpServerThread = None -HTTPD = None -VESEventQ = None IsRobotRun = False - diff --git a/tests/dcaegen2/testcases/resources/robot_library/DmaapLibrary.py b/tests/dcaegen2/testcases/resources/robot_library/DmaapLibrary.py new file mode 100644 index 00000000..c9a0ff7b --- /dev/null +++ b/tests/dcaegen2/testcases/resources/robot_library/DmaapLibrary.py @@ -0,0 +1,79 @@ +from Queue import Queue + +import robot.api.logger as logger +import threading +import time + +import DcaeVariables +from robot_library.dmaap_simulator import DMaaPServer +from robot_library.dmaap_simulator.DMaaPQueue import DMaaPQueue + +class DmaapLibrary(object): + + dmaap_queue = None + dmaap_server = None + server_thread = None + + def __init__(self): + pass + + @staticmethod + def setup_dmaap_server(port_num=3904): + try: + DmaapLibrary.start_dmaap_server_on_new_thread(port_num) + return "true" + except Exception as e: + print (str(e)) + return "false" + + @staticmethod + def start_dmaap_server_on_new_thread(port_num): + DmaapLibrary.dmaap_queue = DMaaPQueue(Queue()) + DmaapLibrary.dmaap_server = DMaaPServer.create_dmaap_server(DmaapLibrary.dmaap_queue, port=port_num) + DmaapLibrary.server_thread = threading.Thread(name='DMAAP_HTTPServer', + target=DmaapLibrary.dmaap_server.serve_forever) + DmaapLibrary.server_thread.start() + logger.console("DMaaP Mockup Sever started") + DcaeVariables.IsRobotRun = True + time.sleep(2) + + @staticmethod + def shutdown_dmaap(): + if DmaapLibrary.dmaap_server is not None: + DmaapLibrary.dmaap_server.shutdown() + logger.console("DMaaP Server shut down") + time.sleep(3) + return "true" + else: + return "false" + + @staticmethod + def cleanup_ves_events(): + if DmaapLibrary.server_thread is not None: + DmaapLibrary.dmaap_queue.clean_up_event() + logger.console("DMaaP event queue is cleaned up") + return "true" + logger.console("DMaaP server not started yet") + return "false" + + @staticmethod + def dmaap_message_receive_on_topic(evtobj, topic): + + evt_str = DmaapLibrary.dmaap_queue.deque_event() + while evt_str != None: + if evtobj in evt_str and topic in evt_str: + logger.info("DMaaP Receive Expected Publish Event:\n" + evt_str) + logger.info("On Expected Topic:\n" + topic) + return 'true' + evt_str = DmaapLibrary.dmaap_queue.deque_event() + return 'false' + + @staticmethod + def dmaap_message_receive(evtobj): + evt_str = DmaapLibrary.dmaap_queue.deque_event() + while evt_str != None: + if evtobj in evt_str: + logger.info("DMaaP Receive Expected Publish Event:\n" + evt_str) + return 'true' + evt_str = DmaapLibrary.dmaap_queue.deque_event() + return 'false' diff --git a/tests/dcaegen2/testcases/resources/robot_library/README.md b/tests/dcaegen2/testcases/resources/robot_library/README.md new file mode 100644 index 00000000..ac432f79 --- /dev/null +++ b/tests/dcaegen2/testcases/resources/robot_library/README.md @@ -0,0 +1,14 @@ +# Robot Library +This catalog contains python files used in Robot tests for dcaegen2.ves. + +# DMaaP Simulator +Catalog dmaap_simulator contains python implementation of DMaaP simulator. It uses python BaseHTTPServer to expose endpoints. + +# DMaaP Tests +Catalog dmaap_test contains tests that are used to validate DMaaP simulator. Test are using "pytest" and "MagicMock". + +### In order to run tests: +1. create virtual environemnt with Python 2.7; +2. install requirements from file requirements.txt located in dmaap_test; +3. set environement variable WORKSPACE to point root csit catalog +4. run py.test command in catalog dmaap_test diff --git a/tests/dcaegen2/testcases/resources/robot_library/__init__.py b/tests/dcaegen2/testcases/resources/robot_library/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/dcaegen2/testcases/resources/robot_library/__init__.py diff --git a/tests/dcaegen2/testcases/resources/robot_library/dmaap_simulator/DMaaPHandler.py b/tests/dcaegen2/testcases/resources/robot_library/dmaap_simulator/DMaaPHandler.py new file mode 100644 index 00000000..f1c46e19 --- /dev/null +++ b/tests/dcaegen2/testcases/resources/robot_library/dmaap_simulator/DMaaPHandler.py @@ -0,0 +1,73 @@ +''' +Created on Aug 15, 2017 + +@author: sw6830 +''' +import os +import posixpath +import BaseHTTPServer +import urllib +import urlparse +import cgi +import sys +import shutil +import mimetypes +from robot_library import DcaeVariables + +try: + from cStringIO import StringIO +except ImportError: + from StringIO import StringIO + + +class DMaaPHandler(BaseHTTPServer.BaseHTTPRequestHandler): + + def __init__(self, dmaap_simulator, *args): + self.dmaap_simulator = dmaap_simulator + BaseHTTPServer.BaseHTTPRequestHandler.__init__(self, *args) + + def do_POST(self): + if 'POST' not in self.requestline: + resp_code = 405 + else: + resp_code = self.parse_the_posted_data() + + if resp_code == 0: + self.send_successful_response() + else: + self.send_response(resp_code) + + def parse_the_posted_data(self): + topic = self.extract_topic_from_path() + content_len = self.get_content_length() + post_body = self.rfile.read(content_len) + post_body = self.get_json_part_of_post_body(post_body) + event = "{\"" + topic + "\":" + post_body + "}" + if self.dmaap_simulator.enque_event(event): + resp_code = 0 + else: + print "enque event fails" + resp_code = 500 + return resp_code + + def get_json_part_of_post_body(self, post_body): + indx = post_body.index("{") + if indx != 0: + post_body = post_body[indx:] + return post_body + + def extract_topic_from_path(self): + return self.path["/events/".__len__():] + + def get_content_length(self): + return int(self.headers.getheader('content-length', 0)) + + def send_successful_response(self): + if 'clientThrottlingState' in self.requestline: + self.send_response(204) + else: + self.send_response(200) + self.send_header('Content-Type', 'application/json') + self.end_headers() + self.wfile.write("{'count': 1, 'serverTimeMs': 3}") + self.wfile.close() diff --git a/tests/dcaegen2/testcases/resources/robot_library/dmaap_simulator/DMaaPQueue.py b/tests/dcaegen2/testcases/resources/robot_library/dmaap_simulator/DMaaPQueue.py new file mode 100644 index 00000000..3d3a81fa --- /dev/null +++ b/tests/dcaegen2/testcases/resources/robot_library/dmaap_simulator/DMaaPQueue.py @@ -0,0 +1,48 @@ +class DMaaPQueue(object): + + def __init__(self, event_queue, wait_timeout_sec=25): + self.event_queue = event_queue + self.wait_timeout_sec = wait_timeout_sec + + def set_deque_event_timeout(self, wait_timeout_sec): + self.wait_timeout_sec = wait_timeout_sec + + def clean_up_event(self): + if self.queue_is_valid(): + with self.event_queue.mutex: + try: + self.event_queue.queue.clear() + except: + pass + + def enque_event(self, event): + event_placed_on_queue = False + if self.queue_is_valid(): + event_placed_on_queue = self._enque_event(event, event_placed_on_queue) + return event_placed_on_queue + + def _enque_event(self, event, event_placed_on_queue): + try: + self.event_queue.put(event) + event_placed_on_queue = True + except Exception as e: + print (str(e)) + return event_placed_on_queue + + def deque_event(self, wait_sec=None): + if wait_sec is None: + wait_sec = self.wait_timeout_sec + event_from_queue = None + if self.queue_is_valid(): + event_from_queue = self._deque_event(event_from_queue, wait_sec) + return event_from_queue + + def _deque_event(self, event_from_queue, wait_sec): + try: + event_from_queue = self.event_queue.get(True, wait_sec) + except Exception as e: + print("DMaaP Event dequeue timeout") + return event_from_queue + + def queue_is_valid(self): + return self.event_queue is not None diff --git a/tests/dcaegen2/testcases/resources/robot_library/dmaap_simulator/DMaaPServer.py b/tests/dcaegen2/testcases/resources/robot_library/dmaap_simulator/DMaaPServer.py new file mode 100644 index 00000000..37499be8 --- /dev/null +++ b/tests/dcaegen2/testcases/resources/robot_library/dmaap_simulator/DMaaPServer.py @@ -0,0 +1,22 @@ +import BaseHTTPServer +import DMaaPHandler + + +class DMaaPServer(BaseHTTPServer.HTTPServer): + + def __init__(self, server_address, protocol, dmaap_simulator): + + def handler_class_constructor(*args): + DMaaPHandler.DMaaPHandler(dmaap_simulator, *args) + DMaaPHandler.protocol_version = protocol + BaseHTTPServer.HTTPServer.__init__(self, server_address, handler_class_constructor) + + serer_address = self.socket.getsockname() + print "Serving HTTP on", serer_address[0], "port", serer_address[1], "..." + + +def create_dmaap_server(dmaap_simulator, protocol="HTTP/1.0", port=3904): + server_address = ('', port) + httpd = DMaaPServer(server_address, protocol, dmaap_simulator) + + return httpd diff --git a/tests/dcaegen2/testcases/resources/robot_library/dmaap_simulator/__init__.py b/tests/dcaegen2/testcases/resources/robot_library/dmaap_simulator/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/dcaegen2/testcases/resources/robot_library/dmaap_simulator/__init__.py diff --git a/tests/dcaegen2/testcases/resources/robot_library/dmaap_test/__init__.py b/tests/dcaegen2/testcases/resources/robot_library/dmaap_test/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/dcaegen2/testcases/resources/robot_library/dmaap_test/__init__.py diff --git a/tests/dcaegen2/testcases/resources/robot_library/dmaap_test/requirements.txt b/tests/dcaegen2/testcases/resources/robot_library/dmaap_test/requirements.txt new file mode 100644 index 00000000..7a687204 --- /dev/null +++ b/tests/dcaegen2/testcases/resources/robot_library/dmaap_test/requirements.txt @@ -0,0 +1,23 @@ +atomicwrites==1.4.0 +attrs==19.3.0 +backports.functools-lru-cache==1.6.1 +configparser==4.0.2 +contextlib2==0.6.0.post1 +funcsigs==1.0.2 +httplib2==0.18.1 +importlib-metadata==1.7.0 +magicmock==0.3 +mock==3.0.5 +mocker==1.1.1 +more-itertools==5.0.0 +packaging==20.4 +pathlib2==2.3.5 +pluggy==0.13.1 +py==1.9.0 +pyparsing==2.4.7 +pytest==4.6.11 +pytest-mock==2.0.0 +scandir==1.10.0 +six==1.15.0 +wcwidth==0.2.5 +zipp==1.2.0 diff --git a/tests/dcaegen2/testcases/resources/robot_library/dmaap_test/test_DMaaPSQueue.py b/tests/dcaegen2/testcases/resources/robot_library/dmaap_test/test_DMaaPSQueue.py new file mode 100644 index 00000000..f278a391 --- /dev/null +++ b/tests/dcaegen2/testcases/resources/robot_library/dmaap_test/test_DMaaPSQueue.py @@ -0,0 +1,52 @@ +from Queue import Queue +import pytest +from robot_library.dmaap_simulator.DMaaPQueue import DMaaPQueue + +wait_sec_for_dequeing_event = 0.1 +test_event = "\"topic\":{\"test\":123}" + + +class TestDMaaPQueue: + + dmaap_simulator = None + + @pytest.fixture(autouse=True, scope="function") + def initiate_dmaap_simulator(self): + TestDMaaPQueue.dmaap_simulator = DMaaPQueue(Queue()) + TestDMaaPQueue.dmaap_simulator.set_deque_event_timeout(wait_sec_for_dequeing_event) + yield + + def test_when_queue_is_empty_then_deque_returns_none(self): + # when + event = TestDMaaPQueue.dmaap_simulator.deque_event() + + # then + assert event is None + + def test_when_enque_event_then_dequeue_return_same_event(self): + # when + TestDMaaPQueue.dmaap_simulator.enque_event(test_event) + event = TestDMaaPQueue.dmaap_simulator.deque_event() + + # then + assert event == test_event + + def test_when_enque_and_dequeue_event_then_deque_return_none(self): + # when + TestDMaaPQueue.dmaap_simulator.enque_event(test_event) + TestDMaaPQueue.dmaap_simulator.deque_event() + event = TestDMaaPQueue.dmaap_simulator.deque_event() + + # then + assert event is None + + def test_when_enque_few_events_and_clean_up_then_dequeu_return_none(self): + # when + TestDMaaPQueue.dmaap_simulator.enque_event(test_event) + TestDMaaPQueue.dmaap_simulator.enque_event(test_event) + TestDMaaPQueue.dmaap_simulator.enque_event(test_event) + TestDMaaPQueue.dmaap_simulator.clean_up_event() + event = TestDMaaPQueue.dmaap_simulator.deque_event() + + # then + assert event is None diff --git a/tests/dcaegen2/testcases/resources/robot_library/dmaap_test/test_DMaaPSimulator.py b/tests/dcaegen2/testcases/resources/robot_library/dmaap_test/test_DMaaPSimulator.py new file mode 100644 index 00000000..82f95ff8 --- /dev/null +++ b/tests/dcaegen2/testcases/resources/robot_library/dmaap_test/test_DMaaPSimulator.py @@ -0,0 +1,62 @@ +import sys +import pytest +from mock import MagicMock + +sys.modules['robot'] = MagicMock() +sys.modules['robot.api'] = MagicMock() +sys.modules['robot.api.logger'] = MagicMock() +from robot_library.DmaapLibrary import DmaapLibrary + +wait_sec_for_dequeing_event = 0.1 +test_event = "{\"test\":\"123\"}" +test_topic = "topic" +test_message = "\"" + test_topic + "\":" + test_event + + +class TestDMaaPSimulator: + + @pytest.fixture(autouse=True, scope="class") + def initiate_dmaap_simulator(self): + DmaapLibrary.setup_dmaap_server() + DmaapLibrary.dmaap_queue.set_deque_event_timeout(wait_sec_for_dequeing_event) + yield + assert DmaapLibrary.shutdown_dmaap() == "true" + + @pytest.fixture(autouse=True, scope="function") + def clear_dmaap_simulator(self): + yield + DmaapLibrary.cleanup_ves_events() + + def test_start_stop_dmaap_server(self): + # when / then + assert DmaapLibrary.dmaap_queue is not None + assert DmaapLibrary.dmaap_server is not None + assert DmaapLibrary.server_thread is not None + + def test_dmaap_server_returns_true_when_event_is_present_on_queue(self): + # when + DmaapLibrary.dmaap_queue.enque_event(test_message) + + # then + assert DmaapLibrary.dmaap_message_receive(test_event) == 'true' + + def test_dmaap_server_returns_true_when_event_is_present_on_given_topic_on_queue(self): + # when + DmaapLibrary.dmaap_queue.enque_event(test_message) + + # then + assert DmaapLibrary.dmaap_message_receive_on_topic(test_event, test_topic) == 'true' + + def test_dmaap_server_returns_timeout_when_event_is_not_present_on_queue(self): + # when / then + assert DmaapLibrary.dmaap_message_receive(test_event) == 'false' + + def test_dmaap_server_returns_false_when_queue_was_cleared(self): + # when + DmaapLibrary.dmaap_queue.enque_event(test_message) + DmaapLibrary.dmaap_queue.enque_event(test_message) + DmaapLibrary.dmaap_queue.enque_event(test_message) + DmaapLibrary.cleanup_ves_events() + + # then + assert DmaapLibrary.dmaap_message_receive_on_topic(test_event, test_topic) == 'false' diff --git a/tests/policy/api/api-test.robot b/tests/policy/api/api-test.robot index d3df9cc9..c229bcf5 100644 --- a/tests/policy/api/api-test.robot +++ b/tests/policy/api/api-test.robot @@ -41,7 +41,7 @@ RetrievePolicyTypes CreateTCAPolicyTypeV1 [Documentation] Create TCA Policy Type Version 1. Trying to create an existing policy type with any change and same version should cause error. ${auth}= Create List healthcheck zb!XztG34 - ${postjson}= Get file ${CURDIR}/data/onap.policy.monitoring.cdap.tca.hi.lo.app.v1.json + ${postjson}= Get file ${CURDIR}/data/onap.policy.monitoring.tcagen2.v1.json Log Creating session https://${POLICY_API_IP}:6969 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth} ${headers}= Create Dictionary Accept=application/json Content-Type=application/json @@ -52,7 +52,7 @@ CreateTCAPolicyTypeV1 CreateTCAPolicyTypeV2 [Documentation] Create TCA Policy Type Version 2 ${auth}= Create List healthcheck zb!XztG34 - ${postjson}= Get file ${CURDIR}/data/onap.policy.monitoring.cdap.tca.hi.lo.app.v2.json + ${postjson}= Get file ${CURDIR}/data/onap.policy.monitoring.tcagen2.v2.json Log Creating session https://${POLICY_API_IP}:6969 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth} ${headers}= Create Dictionary Accept=application/json Content-Type=application/json @@ -82,7 +82,7 @@ CreateNewMonitoringPolicyV1 Log Creating session https://${POLICY_API_IP}:6969 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth} ${headers}= Create Dictionary Accept=application/json Content-Type=application/json - ${resp}= Post Request policy /policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0/policies data=${postjson} headers=${headers} + ${resp}= Post Request policy /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0/policies data=${postjson} headers=${headers} Log Received response from policy ${resp.text} ${postjsonobject} To Json ${postjson} Should Be Equal As Strings ${resp.status_code} 200 @@ -121,7 +121,7 @@ RetrievePoliciesOfType Log Creating session https://${POLICY_API_IP}:6969 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth} ${headers}= Create Dictionary Accept=application/json Content-Type=application/json - ${resp}= Get Request policy /policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0/policies headers=${headers} + ${resp}= Get Request policy /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0/policies headers=${headers} Log Received response from policy ${resp.text} ${expjsonobject} To Json ${expjson} Should Be Equal As Strings ${resp.status_code} 200 @@ -173,10 +173,10 @@ DeleteSpecificPolicyV2 Log Creating session https://${POLICY_API_IP}:6969 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth} ${headers}= Create Dictionary Accept=application/json Content-Type=application/json - ${resp}= Delete Request policy /policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0/policies/onap.restart.tca/versions/2.0.0 headers=${headers} + ${resp}= Delete Request policy /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0/policies/onap.restart.tca/versions/2.0.0 headers=${headers} Log Received response from policy ${resp.text} Should Be Equal As Strings ${resp.status_code} 200 - ${resp}= Delete Request policy /policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0/policies/onap.restart.tca/versions/2.0.0 headers=${headers} + ${resp}= Delete Request policy /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0/policies/onap.restart.tca/versions/2.0.0 headers=${headers} Should Be Equal As Strings ${resp.status_code} 404 DeleteSpecificPolicyTypeV1 @@ -185,10 +185,10 @@ DeleteSpecificPolicyTypeV1 Log Creating session https://${POLICY_API_IP}:6969 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth} ${headers}= Create Dictionary Accept=application/json Content-Type=application/json - ${resp}= Delete Request policy /policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0 headers=${headers} + ${resp}= Delete Request policy /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0 headers=${headers} Log Received response from policy ${resp.text} Should Be Equal As Strings ${resp.status_code} 200 - ${resp}= Delete Request policy /policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0 headers=${headers} + ${resp}= Delete Request policy /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0 headers=${headers} Should Be Equal As Strings ${resp.status_code} 404 DeleteSpecificPolicyTypeV2 @@ -197,8 +197,8 @@ DeleteSpecificPolicyTypeV2 Log Creating session https://${POLICY_API_IP}:6969 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth} ${headers}= Create Dictionary Accept=application/json Content-Type=application/json - ${resp}= Delete Request policy /policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/2.0.0 headers=${headers} + ${resp}= Delete Request policy /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/2.0.0 headers=${headers} Log Received response from policy ${resp.text} Should Be Equal As Strings ${resp.status_code} 200 - ${resp}= Delete Request policy /policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/2.0.0 headers=${headers} + ${resp}= Delete Request policy /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/2.0.0 headers=${headers} Should Be Equal As Strings ${resp.status_code} 404 diff --git a/tests/policy/api/data/onap.policy.monitoring.cdap.tca.hi.lo.app.v1.json b/tests/policy/api/data/onap.policy.monitoring.tcagen2.v1.json index 15c20458..a2e2ddc9 100644 --- a/tests/policy/api/data/onap.policy.monitoring.cdap.tca.hi.lo.app.v1.json +++ b/tests/policy/api/data/onap.policy.monitoring.tcagen2.v1.json @@ -6,11 +6,11 @@ "version": "1.0.0", "description": "a base policy type for all policies that governs monitoring provisioning" }, - "onap.policies.monitoring.cdap.tca.hi.lo.app": { + "onap.policies.monitoring.tcagen2": { "derived_from": "onap.policies.Monitoring", "version": "1.0.0", "properties": { - "tca_policy": { + "tca.policy": { "type": "onap.datatypes.monitoring.tca_policy", "description": "TCA Policy JSON" } diff --git a/tests/policy/api/data/onap.policy.monitoring.cdap.tca.hi.lo.app.v2.json b/tests/policy/api/data/onap.policy.monitoring.tcagen2.v2.json index a7a801a8..d86749ef 100644 --- a/tests/policy/api/data/onap.policy.monitoring.cdap.tca.hi.lo.app.v2.json +++ b/tests/policy/api/data/onap.policy.monitoring.tcagen2.v2.json @@ -1,11 +1,11 @@ { "tosca_definitions_version": "tosca_simple_yaml_1_1_0", "policy_types": { - "onap.policies.monitoring.cdap.tca.hi.lo.app": { + "onap.policies.monitoring.tcagen2": { "derived_from": "onap.policies.Monitoring", "version": "2.0.0", "properties": { - "tca_policy": { + "tca.policy": { "type": "onap.datatypes.monitoring.tca_policy", "description": "TCA Policy JSON" } diff --git a/tests/policy/api/data/vCPE.policy.monitoring.input.tosca.v1.json b/tests/policy/api/data/vCPE.policy.monitoring.input.tosca.v1.json index 1079c7c1..d57a64cb 100644 --- a/tests/policy/api/data/vCPE.policy.monitoring.input.tosca.v1.json +++ b/tests/policy/api/data/vCPE.policy.monitoring.input.tosca.v1.json @@ -4,14 +4,14 @@ "policies": [ { "onap.restart.tca": { - "type": "onap.policies.monitoring.cdap.tca.hi.lo.app", + "type": "onap.policies.monitoring.tcagen2", "version": "1.0.0", "type_version": "1.0.0", "metadata": { "policy-id": "onap.restart.tca" }, "properties": { - "tca_policy" : { + "tca.policy" : { "domain": "measurementsForVfScaling", "metricsPerEventName": [ { diff --git a/tests/policy/api/data/vCPE.policy.monitoring.input.tosca.v1_2.json b/tests/policy/api/data/vCPE.policy.monitoring.input.tosca.v1_2.json index 35ad3c54..12e066ea 100644 --- a/tests/policy/api/data/vCPE.policy.monitoring.input.tosca.v1_2.json +++ b/tests/policy/api/data/vCPE.policy.monitoring.input.tosca.v1_2.json @@ -4,7 +4,7 @@ "policies": [ { "onap.restart.tca": { - "type": "onap.policies.monitoring.cdap.tca.hi.lo.app", + "type": "onap.policies.monitoring.tcagen2", "version": "1.0.0", "type_version": "1.0.0", "description": "monitoring policy", @@ -12,7 +12,7 @@ "policy-id": "onap.restart.tca" }, "properties": { - "tca_policy" : { + "tca.policy" : { "domain": "measurementsForVfScaling", "metricsPerEventName": [ { diff --git a/tests/policy/api/data/vCPE.policy.monitoring.input.tosca.v2.json b/tests/policy/api/data/vCPE.policy.monitoring.input.tosca.v2.json index c6b2ad2d..cd4be203 100644 --- a/tests/policy/api/data/vCPE.policy.monitoring.input.tosca.v2.json +++ b/tests/policy/api/data/vCPE.policy.monitoring.input.tosca.v2.json @@ -4,14 +4,14 @@ "policies": [ { "onap.restart.tca": { - "type": "onap.policies.monitoring.cdap.tca.hi.lo.app", + "type": "onap.policies.monitoring.tcagen2", "version": "2.0.0", "type_version": "1.0.0", "metadata": { "policy-id": "onap.restart.tca" }, "properties": { - "tca_policy" : { + "tca.policy" : { "domain": "measurementsForVfScaling", "metricsPerEventName": [ { diff --git a/tests/policy/pap/data/create.group.request.json b/tests/policy/pap/data/create.group.request.json index ea04c0e5..1b63563f 100644 --- a/tests/policy/pap/data/create.group.request.json +++ b/tests/policy/pap/data/create.group.request.json @@ -13,7 +13,7 @@ "properties": {}, "supportedPolicyTypes": [ { - "name": "onap.policies.monitoring.cdap.tca.hi.lo.app", + "name": "onap.policies.monitoring.tcagen2", "version": "1.0.0" } ], @@ -25,7 +25,7 @@ "properties": {}, "supportedPolicyTypes": [ { - "name": "onap.policies.monitoring.cdap.tca.hi.lo.app", + "name": "onap.policies.monitoring.tcagen2", "version": "1.0.0" } ], diff --git a/tests/policy/pap/data/vCPE.policy.monitoring.input.tosca.json b/tests/policy/pap/data/vCPE.policy.monitoring.input.tosca.json index 3003d9a8..8ec03fe5 100644 --- a/tests/policy/pap/data/vCPE.policy.monitoring.input.tosca.json +++ b/tests/policy/pap/data/vCPE.policy.monitoring.input.tosca.json @@ -4,14 +4,14 @@ "policies": [ { "onap.restart.tca": { - "type": "onap.policies.monitoring.cdap.tca.hi.lo.app", + "type": "onap.policies.monitoring.tcagen2", "version": "1.0.0", "type_version": "1.0.0", "metadata": { "policy-id": "onap.restart.tca" }, "properties": { - "tca_policy": { + "tca.policy": { "domain": "measurementsForVfScaling", "metricsPerEventName": [ { diff --git a/tests/policy/pap/pap-test.robot b/tests/policy/pap/pap-test.robot index 67a57828..5387e85f 100644 --- a/tests/policy/pap/pap-test.robot +++ b/tests/policy/pap/pap-test.robot @@ -12,7 +12,7 @@ LoadPolicy ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth} ${headers}= Create Dictionary Accept=application/json Content-Type=application/json ${postjson}= Get file ${CURDIR}/data/vCPE.policy.monitoring.input.tosca.json - ${resp}= Post Request policy /policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0/policies data=${postjson} headers=${headers} + ${resp}= Post Request policy /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0/policies data=${postjson} headers=${headers} Log Received response from API ${resp.text} Should Be Equal As Strings ${resp.status_code} 200 diff --git a/tests/policy/xacml-pdp/data/vCPE.policy.monitoring.input.tosca.json b/tests/policy/xacml-pdp/data/vCPE.policy.monitoring.input.tosca.json index 3003d9a8..8ec03fe5 100644 --- a/tests/policy/xacml-pdp/data/vCPE.policy.monitoring.input.tosca.json +++ b/tests/policy/xacml-pdp/data/vCPE.policy.monitoring.input.tosca.json @@ -4,14 +4,14 @@ "policies": [ { "onap.restart.tca": { - "type": "onap.policies.monitoring.cdap.tca.hi.lo.app", + "type": "onap.policies.monitoring.tcagen2", "version": "1.0.0", "type_version": "1.0.0", "metadata": { "policy-id": "onap.restart.tca" }, "properties": { - "tca_policy": { + "tca.policy": { "domain": "measurementsForVfScaling", "metricsPerEventName": [ { diff --git a/tests/policy/xacml-pdp/xacml-pdp-test.robot b/tests/policy/xacml-pdp/xacml-pdp-test.robot index 6e2fa008..150c97e6 100644 --- a/tests/policy/xacml-pdp/xacml-pdp-test.robot +++ b/tests/policy/xacml-pdp/xacml-pdp-test.robot @@ -52,7 +52,7 @@ CreateMonitorPolicy Log Creating session https://${POLICY_API_IP}:6969 ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth} ${headers}= Create Dictionary Accept=application/json Content-Type=application/json - ${resp}= Post Request policy /policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0/policies data=${postjson} headers=${headers} + ${resp}= Post Request policy /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0/policies data=${postjson} headers=${headers} Log Received response from policy4 ${resp.text} ${postjsonobject} To Json ${postjson} Should Be Equal As Strings ${resp.status_code} 200 |