diff options
Diffstat (limited to 'tests/dcaegen2')
17 files changed, 139 insertions, 87 deletions
diff --git a/tests/dcaegen2/prh-testcases/assets/json_events/event_with_IPV4.json b/tests/dcaegen2/prh-testcases/assets/json_events/event_with_IPV4.json index cdcab678..ac7c3090 100644 --- a/tests/dcaegen2/prh-testcases/assets/json_events/event_with_IPV4.json +++ b/tests/dcaegen2/prh-testcases/assets/json_events/event_with_IPV4.json @@ -6,12 +6,10 @@ "pnfRegistrationFields": { "oamV4IpAddress":"10.17.123.234", "oamV6IpAddress":"", - "serial-number":"NOkkaaa123", - "equip-vendor":"equipVendor", - "equip-model":"equipModel", - "equip-type":"equipType", - "nf-role":"nf-role", - "sw-version":"swVersion" + "serialNumber":"NOkkaaa123", + "vendorName":"equipVendor", + "modelNumber":"equipModel", + "unitType":"equipType" } } } diff --git a/tests/dcaegen2/prh-testcases/assets/json_events/event_with_IPV6.json b/tests/dcaegen2/prh-testcases/assets/json_events/event_with_IPV6.json index f5ec23d0..5a67dfe1 100644 --- a/tests/dcaegen2/prh-testcases/assets/json_events/event_with_IPV6.json +++ b/tests/dcaegen2/prh-testcases/assets/json_events/event_with_IPV6.json @@ -6,12 +6,10 @@ "pnfRegistrationFields": { "oamV4IpAddress":"", "oamV6IpAddress":"2001:0db8:85a3:0000:0000:8b2e:0370:7334", - "serial-number":"NOkkaaa123", - "equip-vendor":"equipVendor", - "equip-model":"equipModel", - "equip-type":"equipType", - "nf-role":"nf-role", - "sw-version":"swVersion" + "serialNumber":"NOkkaaa123", + "vendorName":"equipVendor", + "modelNumber":"equipModel", + "unitType":"equipType" } } } diff --git a/tests/dcaegen2/prh-testcases/assets/json_events/event_with_all_fields.json b/tests/dcaegen2/prh-testcases/assets/json_events/event_with_all_fields.json index bc9cb1d3..f55b2f9c 100644 --- a/tests/dcaegen2/prh-testcases/assets/json_events/event_with_all_fields.json +++ b/tests/dcaegen2/prh-testcases/assets/json_events/event_with_all_fields.json @@ -1,17 +1,16 @@ { "event": { "commonEventHeader": { - "sourceName":"NOK6061ZW1" + "sourceName":"NOK6061ZW1", + "nfNamingCode": "nfNamingCode" }, "pnfRegistrationFields": { "oamV4IpAddress":"10.16.123.234", "oamV6IpAddress":"2001:0db8:85a3:0000:0000:8a2e:0370:7334", - "serial-number":"NOkkaaa123", - "equip-vendor":"equipVendor", - "equip-model":"equipModel", - "equip-type":"equipType", - "nf-role":"nf-role", - "sw-version":"swVersion" + "serialNumber":"serialNumber", + "vendorName":"vendorName", + "modelNumber":"modelNumber", + "unitType":"unitType" } } } diff --git a/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_IPV4_and_IPV6.json b/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_IPV4_and_IPV6.json index 4942a3d5..6a14bfd4 100644 --- a/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_IPV4_and_IPV6.json +++ b/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_IPV4_and_IPV6.json @@ -6,12 +6,10 @@ "pnfRegistrationFields": { "oamV4IpAddress":"", "oamV6IpAddress":"", - "serial-number":"NOkkaaa123", - "equip-vendor":"equipVendor", - "equip-model":"equipModel", - "equip-type":"equipType", - "nf-role":"nf-role", - "sw-version":"swVersion" + "serialNumber":"", + "vendorName":"", + "modelNumber":"", + "unitType":"" } } } diff --git a/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName.json b/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName.json index 5e2a6121..74425ec2 100644 --- a/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName.json +++ b/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName.json @@ -6,12 +6,10 @@ "pnfRegistrationFields": { "oamV4IpAddress":"10.18.123.234", "oamV6IpAddress":"2001:0db8:85a3:0000:0000:8a2a:0370:7334", - "serial-number":"NOkkaaa123", - "equip-vendor":"equipVendor", - "equip-model":"equipModel", - "equip-type":"equipType", - "nf-role":"nf-role", - "sw-version":"swVersion" + "serialNumber":"", + "vendorName":"", + "modelNumber":"", + "unitType":"" } } } diff --git a/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_IPV4_and_IPV6.json b/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_IPV4_and_IPV6.json index a6a6f364..de1f576c 100644 --- a/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_IPV4_and_IPV6.json +++ b/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_IPV4_and_IPV6.json @@ -5,13 +5,7 @@ }, "pnfRegistrationFields": { "oamV4IpAddress":"", - "oamV6IpAddress":"", - "serial-number":"NOkkaaa123", - "equip-vendor":"equipVendor", - "equip-model":"equipModel", - "equip-type":"equipType", - "nf-role":"nf-role", - "sw-version":"swVersion" + "oamV6IpAddress":"" } } } diff --git a/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_and_IPV4.json b/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_and_IPV4.json index 6d9eadfe..4838f1b0 100644 --- a/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_and_IPV4.json +++ b/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_and_IPV4.json @@ -5,13 +5,7 @@ }, "pnfRegistrationFields": { "oamV4IpAddress":"", - "oamV6IpAddress":"2001:0db8:85a3:0000:0000:8b2f:0370:7334", - "serial-number":"NOkkaaa123", - "equip-vendor":"equipVendor", - "equip-model":"equipModel", - "equip-type":"equipType", - "nf-role":"nf-role", - "sw-version":"swVersion" + "oamV6IpAddress":"2001:0db8:85a3:0000:0000:8b2f:0370:7334" } } } diff --git a/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_and_IPV6.json b/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_and_IPV6.json index 9fac5b19..253869ac 100644 --- a/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_and_IPV6.json +++ b/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_and_IPV6.json @@ -5,13 +5,8 @@ }, "pnfRegistrationFields": { "oamV4IpAddress":"10.17.163.234", - "oamV6IpAddress":"", - "serial-number":"NOkkaaa123", - "equip-vendor":"equipVendor", - "equip-model":"equipModel", - "equip-type":"equipType", - "nf-role":"nf-role", - "sw-version":"swVersion" + "oamV6IpAddress":"" + } } } diff --git a/tests/dcaegen2/prh-testcases/assets/json_events/event_with_optional_registration_fields_all_filled.json b/tests/dcaegen2/prh-testcases/assets/json_events/event_with_optional_registration_fields_all_filled.json new file mode 100644 index 00000000..492d6071 --- /dev/null +++ b/tests/dcaegen2/prh-testcases/assets/json_events/event_with_optional_registration_fields_all_filled.json @@ -0,0 +1,17 @@ +{ + "event": { + "commonEventHeader": { + "sourceName":"NOK6061ZW4", + "nfNamingCode": "nfNamingCode", + "nfcNamingCode": "nfcNamingCode" + }, + "pnfRegistrationFields": { + "oamV4IpAddress":"ipv4", + "oamV6IpAddress":"", + "serialNumber":"sn1234", + "vendorName":"vendorName", + "modelNumber":"modelNumber", + "unitType":"unitType" + } + } +} diff --git a/tests/dcaegen2/prh-testcases/assets/json_events/event_with_empty_addtional_fields.json b/tests/dcaegen2/prh-testcases/assets/json_events/event_with_optional_registration_fields_empty.json index 7ca4d0c6..48363a47 100644 --- a/tests/dcaegen2/prh-testcases/assets/json_events/event_with_empty_addtional_fields.json +++ b/tests/dcaegen2/prh-testcases/assets/json_events/event_with_optional_registration_fields_empty.json @@ -1,17 +1,16 @@ { "event": { "commonEventHeader": { - "sourceName":"NOK6061ZW1" + "sourceName":"NOK6061ZW1", + "nfNamingCode": "" }, "pnfRegistrationFields": { "oamV4IpAddress":"10.16.123.234", "oamV6IpAddress":"2001:0db8:85a3:0000:0000:8a2e:0370:7334", - "serial-number":"", - "equip-vendor":"", - "equip-model":"", - "equip-type":"", - "nf-role":"", - "sw-version":"" + "serialNumber":"", + "vendorName":"", + "modelNumber":"", + "unitType":"" } } } diff --git a/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_additional_fields.json b/tests/dcaegen2/prh-testcases/assets/json_events/event_with_optional_registration_fields_missing_all.json index 16963e1b..16963e1b 100644 --- a/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_additional_fields.json +++ b/tests/dcaegen2/prh-testcases/assets/json_events/event_with_optional_registration_fields_missing_all.json diff --git a/tests/dcaegen2/prh-testcases/assets/json_events/event_with_optional_registration_fields_missing_partial.json b/tests/dcaegen2/prh-testcases/assets/json_events/event_with_optional_registration_fields_missing_partial.json new file mode 100644 index 00000000..ede956f5 --- /dev/null +++ b/tests/dcaegen2/prh-testcases/assets/json_events/event_with_optional_registration_fields_missing_partial.json @@ -0,0 +1,14 @@ +{ + "event": { + "commonEventHeader": { + "sourceName":"NOK6061ZW4" + }, + "pnfRegistrationFields": { + "oamV4IpAddress":"", + "oamV6IpAddress":"", + "serialNumber":"123", + "modelNumber":"sn123243", + "unitType": "unitType" + } + } +} diff --git a/tests/dcaegen2/prh-testcases/assets/json_events/event_without_IPV6_field.json b/tests/dcaegen2/prh-testcases/assets/json_events/event_without_IPV6_field.json index a416bb7e..02f01370 100644 --- a/tests/dcaegen2/prh-testcases/assets/json_events/event_without_IPV6_field.json +++ b/tests/dcaegen2/prh-testcases/assets/json_events/event_without_IPV6_field.json @@ -5,12 +5,10 @@ }, "pnfRegistrationFields": { "oamV4IpAddress":"10.17.123.24", - "serial-number":"NOkkaaa123", - "equip-vendor":"equipVendor", - "equip-model":"equipModel", - "equip-type":"equipType", - "nf-role":"nf-role", - "sw-version":"swVersion" + "serialNumber":"NOkkaaa123", + "vendorName":"equipVendor", + "modelNumber":"equipModel", + "unitType":"equipType" } } } diff --git a/tests/dcaegen2/prh-testcases/assets/json_events/not_json_format.json b/tests/dcaegen2/prh-testcases/assets/json_events/not_json_format.json index 08d9a49c..f6afb1d3 100644 --- a/tests/dcaegen2/prh-testcases/assets/json_events/not_json_format.json +++ b/tests/dcaegen2/prh-testcases/assets/json_events/not_json_format.json @@ -6,12 +6,10 @@ "pnfRegistrationFields": { "oamV4IpAddress":"10.16.123.234", "oamV6IpAddress":"2001:0db8:85a3:0000:0000:8a2e:0370:7334", - "serial-number":"NOkkaaa123", - "equip-vendor":"equipVendor", - "equip-model":"equipModel", - "equip-type":"equipType", - "nf-role":"nf-role", - "sw-version":"swVersion", + "serialNumber":"NOkkaaa123", + "vendorName":"equipVendor", + "modelNumber":"equipModel", + "unitType":"equipType", } } } diff --git a/tests/dcaegen2/prh-testcases/prh_tests.robot b/tests/dcaegen2/prh-testcases/prh_tests.robot index 4ecc9c89..77278d47 100644 --- a/tests/dcaegen2/prh-testcases/prh_tests.robot +++ b/tests/dcaegen2/prh-testcases/prh_tests.robot @@ -19,6 +19,10 @@ ${EVENT_WITH_MISSING_SOURCENAME} %{WORKSPACE}/tests/dcaegen2/prh-testcases/as ${EVENT_WITH_MISSING_SOURCENAME_AND_IPV4} %{WORKSPACE}/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_and_IPV4.json ${EVENT_WITH_MISSING_SOURCENAME_AND_IPV6} %{WORKSPACE}/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_and_IPV6.json ${EVENT_WITH_MISSING_SOURCENAME_IPV4_AND_IPV6} %{WORKSPACE}/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_IPV4_and_IPV6.json +${EVENT_WITH_OPTIONAL_REGISTRATION_FIELDS_ALL_FILLED} %{WORKSPACE}/tests/dcaegen2/prh-testcases/assets/json_events/event_with_optional_registration_fields_all_filled.json +${EVENT_WITH_OPTIONAL_REGISTRATION_FIELDS_EMPTY} %{WORKSPACE}/tests/dcaegen2/prh-testcases/assets/json_events/event_with_optional_registration_fields_empty.json +${EVENT_WITH_OPTIONAL_REGISTRATION_FIELDS_MISSING_ALL} %{WORKSPACE}/tests/dcaegen2/prh-testcases/assets/json_events/event_with_optional_registration_fields_missing_all.json +${EVENT_WITH_OPTIONAL_REGISTRATION_FIELDS_MISSING_PARTIAL} %{WORKSPACE}/tests/dcaegen2/prh-testcases/assets/json_events/event_with_optional_registration_fields_missing_partial.json ${EVENT_WITHOUT_IPV6_FILED} %{WORKSPACE}/tests/dcaegen2/prh-testcases/assets/json_events/event_without_IPV6_field.json ${Not_json_format} %{WORKSPACE}/tests/dcaegen2/prh-testcases/assets/json_events/not_json_format.json diff --git a/tests/dcaegen2/prh-testcases/resources/PrhLibrary.py b/tests/dcaegen2/prh-testcases/resources/PrhLibrary.py index d413be58..1a3875b9 100644 --- a/tests/dcaegen2/prh-testcases/resources/PrhLibrary.py +++ b/tests/dcaegen2/prh-testcases/resources/PrhLibrary.py @@ -13,29 +13,75 @@ class PrhLibrary(object): def check_for_log(search_for): client = docker.from_env() container = client.containers.get('prh') + #print ("Check for log searches for pattern: ", search_for ) for line in container.logs(stream=True): + #print ("Check for log analysis line: ", line ) if search_for in line.strip(): return True else: return False @staticmethod - def create_pnf_ready_notification(json_file): + def create_pnf_ready_notification_from_ves(json_file): json_to_python = json.loads(json_file) - ipv4 = json_to_python.get("event").get("pnfRegistrationFields").get("oamV4IpAddress") - ipv6 = json_to_python.get("event").get("pnfRegistrationFields").get("oamV6IpAddress") if "oamV6IpAddress" in json_to_python["event"]["pnfRegistrationFields"] else "" - serial_number = json_to_python.get("event").get("pnfRegistrationFields").get("serial-number") if "serial-number" in json_to_python["event"]["pnfRegistrationFields"] else "" - equip_vendor = json_to_python.get("event").get("pnfRegistrationFields").get("equip-vendor") if "equip-vendor" in json_to_python["event"]["pnfRegistrationFields"] else "" - equip_model = json_to_python.get("event").get("pnfRegistrationFields").get("equip-model") if "equip-model" in json_to_python["event"]["pnfRegistrationFields"] else "" - equip_type = json_to_python.get("event").get("pnfRegistrationFields").get("equip-type") if "equip-type" in json_to_python["event"]["pnfRegistrationFields"] else "" - nf_role = json_to_python.get("event").get("pnfRegistrationFields").get("nf-role") if "nf-role" in json_to_python["event"]["pnfRegistrationFields"] else "" - sw_version = json_to_python.get("event").get("pnfRegistrationFields").get("sw-version") if "sw-version" in json_to_python["event"]["pnfRegistrationFields"] else "" - correlation_id = json_to_python.get("event").get("commonEventHeader").get("sourceName") - str_json = '{"correlationId":"' + correlation_id + '","ipaddress-v4-oam":"' + ipv4 + '","ipaddress-v6-oam":"' + ipv6 + '","serial-number":"' + serial_number + '","equip-vendor":"' + equip_vendor + '","equip-model":"' + equip_model + '","equip-type":"' + equip_type + '","nf-role":"' + nf_role + '","sw-version":"' + sw_version + '"}' + ipv4 = PrhLibrary.extract_ip_v4(json_to_python) + ipv6 = PrhLibrary.extract_ip_v6(json_to_python) + correlation_id = PrhLibrary.extract_correlation_id(json_to_python) + serial_number = PrhLibrary.extract_serial_number(json_to_python) + vendor_name = PrhLibrary.extract_vendor_name(json_to_python) + model_number = PrhLibrary.extract_model_number(json_to_python) + unit_type = PrhLibrary.extract_unit_type(json_to_python) + + str_json = '{"correlationId":"' + correlation_id + '","ipaddress-v4-oam":"' + ipv4 + '","ipaddress-v6-oam":"' + ipv6 + '","serialNumber":"' + serial_number + '","vendorName":"' + vendor_name + '","modelNumber":"' + model_number + '","unitType":"' + unit_type + '"}' python_to_json = json.dumps(str_json) return python_to_json.replace("\\", "")[1:-1] @staticmethod + def create_pnf_ready_notification_as_pnf_ready(json_file): + json_to_python = json.loads(json_file) + ipv4 = PrhLibrary.extract_ip_v4(json_to_python) + ipv6 = PrhLibrary.extract_ip_v6(json_to_python) + correlation_id = PrhLibrary.extract_correlation_id(json_to_python) + serial_number = PrhLibrary.extract_serial_number(json_to_python) + vendor_name = PrhLibrary.extract_vendor_name(json_to_python) + model_number = PrhLibrary.extract_model_number(json_to_python) + unit_type = PrhLibrary.extract_unit_type(json_to_python) + + nf_role = json_to_python.get("event").get("commonEventHeader").get("nfNamingCode") if "nfNamingCode" in json_to_python["event"]["commonEventHeader"] else "" + + str_json = '{"correlationId":"' + correlation_id + '","ipaddress-v4-oam":"' + ipv4 + '","ipaddress-v6-oam":"' + ipv6 + '","serial-number":"' + serial_number + '","equip-vendor":"' + vendor_name + '","equip-model":"' + model_number + '","equip-type":"' + unit_type + '","nf-role":"' + nf_role + '","sw-version":""}' + python_to_json = json.dumps(str_json) + return python_to_json.replace("\\", "")[1:-1] + + @staticmethod + def extract_ip_v4(content): + return content.get("event").get("pnfRegistrationFields").get("oamV4IpAddress") if "oamV4IpAddress" in content["event"]["pnfRegistrationFields"] else "" + + @staticmethod + def extract_ip_v6(content): + return content.get("event").get("pnfRegistrationFields").get("oamV6IpAddress") if "oamV6IpAddress" in content["event"]["pnfRegistrationFields"] else "" + + @staticmethod + def extract_correlation_id(content): + return content.get("event").get("commonEventHeader").get("sourceName") if "sourceName" in content["event"]["commonEventHeader"] else "" + + @staticmethod + def extract_serial_number(content): + return content.get("event").get("pnfRegistrationFields").get("serialNumber") if "serialNumber" in content["event"]["pnfRegistrationFields"] else "" + + @staticmethod + def extract_vendor_name(content): + return content.get("event").get("pnfRegistrationFields").get("vendorName") if "vendorName" in content["event"]["pnfRegistrationFields"] else "" + + @staticmethod + def extract_model_number(content): + return content.get("event").get("pnfRegistrationFields").get("modelNumber") if "modelNumber" in content["event"]["pnfRegistrationFields"] else "" + + @staticmethod + def extract_unit_type(content): + return content.get("event").get("pnfRegistrationFields").get("unitType") if "unitType" in content["event"]["pnfRegistrationFields"] else "" + + @staticmethod def create_pnf_name(json_file): json_to_python = json.loads(json_file) correlation_id = json_to_python.get("sourceName") @@ -83,6 +129,7 @@ class PrhLibrary(object): def create_invalid_notification(self, json_file): - return self.create_pnf_ready_notification(json_file).replace("\":", "\": ")\ - .replace("ipaddress-v4-oam", "oamV4IpAddress").replace("ipaddress-v6-oam", "oamV6IpAddress")\ - .replace("}", "\\n}") + invalidate_input = self.create_pnf_ready_notification_from_ves(json_file).replace("\":", "\": ") \ + .replace("ipaddress-v4-oam", "oamV4IpAddress").replace("ipaddress-v6-oam","oamV6IpAddress").replace("}",'') + invalidate_input__and_add_additional_fields = invalidate_input + ',"nfNamingCode": ""' + "," + '"softwareVersion": ""' +"\\n" + return invalidate_input__and_add_additional_fields diff --git a/tests/dcaegen2/prh-testcases/resources/prh_library.robot b/tests/dcaegen2/prh-testcases/resources/prh_library.robot index 71753875..105365c3 100644 --- a/tests/dcaegen2/prh-testcases/resources/prh_library.robot +++ b/tests/dcaegen2/prh-testcases/resources/prh_library.robot @@ -32,11 +32,12 @@ Valid event processing [Arguments] ${input_valid_event_in_dmaap} [Timeout] 30s ${data}= Get Data From File ${input_valid_event_in_dmaap} - ${posted_event_to_dmaap}= Create PNF_Ready notification ${data} + ${posted_event_to_dmaap}= create pnf ready notification from ves ${data} ${pnf_name}= Create PNF name ${data} Set PNF name in AAI ${pnf_name} Set event in DMaaP ${data} - Wait Until Keyword Succeeds 100x 300ms Check PNF_READY notification ${posted_event_to_dmaap} + ${expected_event_pnf_ready_in_dpaap}= create pnf ready_notification as pnf ready ${data} + Wait Until Keyword Succeeds 100x 300ms Check PNF_READY notification ${expected_event_pnf_ready_in_dpaap} Check PRH log [Arguments] ${searched_log} |