aboutsummaryrefslogtreecommitdiffstats
path: root/tests/dcaegen2/prh-testcases/resources/PrhLibrary.py
diff options
context:
space:
mode:
authorMarcin Migdal <marcin.migdal@nokia.com>2019-02-13 15:43:12 +0100
committerMarcin Migdal <marcin.migdal@nokia.com>2019-02-15 17:24:10 +0100
commit183c896e0cb6d5126c06149a529aa17ee86ff6cf (patch)
tree3cbb622a1acf02b27bfb94c338bc54ce62f3a2c5 /tests/dcaegen2/prh-testcases/resources/PrhLibrary.py
parentfd967387f666cdf7f7e57c7ee7ac4947c0dd0535 (diff)
Add new json events to PRH CSIT
Change-Id: Ide0ee411eb05fa3243a77cf399c6889e73f2d4b3 Issue-ID: INT-871 Signed-off-by: Marcin Migdal <marcin.migdal@nokia.com>
Diffstat (limited to 'tests/dcaegen2/prh-testcases/resources/PrhLibrary.py')
-rw-r--r--tests/dcaegen2/prh-testcases/resources/PrhLibrary.py75
1 files changed, 61 insertions, 14 deletions
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