aboutsummaryrefslogtreecommitdiffstats
path: root/test/csit
diff options
context:
space:
mode:
Diffstat (limited to 'test/csit')
-rw-r--r--test/csit/tests/dcaegen2/prh-testcases/resources/PrhLibrary.py34
-rw-r--r--test/csit/tests/dcaegen2/prh-testcases/resources/simulator/AAI.py11
-rw-r--r--test/csit/tests/dcaegen2/prh-testcases/resources/simulator/DMaaP.py12
3 files changed, 31 insertions, 26 deletions
diff --git a/test/csit/tests/dcaegen2/prh-testcases/resources/PrhLibrary.py b/test/csit/tests/dcaegen2/prh-testcases/resources/PrhLibrary.py
index e12816a2e..7ecfb8b1c 100644
--- a/test/csit/tests/dcaegen2/prh-testcases/resources/PrhLibrary.py
+++ b/test/csit/tests/dcaegen2/prh-testcases/resources/PrhLibrary.py
@@ -8,7 +8,8 @@ class PrhLibrary(object):
def __init__(self):
pass
- def check_for_log(self, search_for):
+ @staticmethod
+ def check_for_log(search_for):
client = docker.from_env()
container = client.containers.get('prh')
for line in container.logs(stream=True):
@@ -17,20 +18,23 @@ class PrhLibrary(object):
else:
return False
- def create_pnf_ready_notification(self, json_file):
- jsonToPython = json.loads(json_file)
- ipv4 = jsonToPython["event"]["otherFields"]["pnfOamIpv4Address"]
- ipv6 = jsonToPython["event"]["otherFields"]["pnfOamIpv6Address"]
- pnfName = _create_pnf_name(json_file)
- strJson = '{"pnf-name":"' + pnfName + '","ipaddress-v4-oam":"' + ipv4 + '","ipaddress-v6-oam":"' + ipv6 +'"}'
- pythonToJson = json.dumps(strJson)
- return pythonToJson.replace("\\", "")[1:-1]
-
- def create_pnf_name(self, json_file):
+ @staticmethod
+ def create_pnf_ready_notification(json_file):
+ json_to_python = json.loads(json_file)
+ ipv4 = json_to_python["event"]["otherFields"]["pnfOamIpv4Address"]
+ ipv6 = json_to_python["event"]["otherFields"]["pnfOamIpv6Address"]
+ pnf_name = _create_pnf_name(json_file)
+ str_json = '{"pnf-name":"' + pnf_name + '","ipaddress-v4-oam":"' + ipv4 + '","ipaddress-v6-oam":"' + ipv6 + '"}'
+ python_to_json = json.dumps(str_json)
+ return python_to_json.replace("\\", "")[1:-1]
+
+ @staticmethod
+ def create_pnf_name(json_file):
return _create_pnf_name(json_file)
+
def _create_pnf_name(json_file):
- jsonToPython = json.loads(json_file)
- vendor = jsonToPython["event"]["otherFields"]["pnfVendorName"]
- serialNumber = jsonToPython["event"]["otherFields"]["pnfSerialNumber"]
- return vendor[:3].upper() + serialNumber
+ json_to_python = json.loads(json_file)
+ vendor = json_to_python["event"]["otherFields"]["pnfVendorName"]
+ serial_number = json_to_python["event"]["otherFields"]["pnfSerialNumber"]
+ return vendor[:3].upper() + serial_number
diff --git a/test/csit/tests/dcaegen2/prh-testcases/resources/simulator/AAI.py b/test/csit/tests/dcaegen2/prh-testcases/resources/simulator/AAI.py
index a0dd814b8..d5deacaa9 100644
--- a/test/csit/tests/dcaegen2/prh-testcases/resources/simulator/AAI.py
+++ b/test/csit/tests/dcaegen2/prh-testcases/resources/simulator/AAI.py
@@ -2,10 +2,9 @@ import BaseHTTPServer
import re
import sys
-from robot.api import logger
-
pnfs = 'Empty'
+
class AAIHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_PUT(self):
if re.search('/set_pnfs', self.path):
@@ -38,7 +37,8 @@ class AAIHandler(BaseHTTPServer.BaseHTTPRequestHandler):
return
-def _main_ (HandlerClass = AAIHandler, ServerClass = BaseHTTPServer.HTTPServer, protocol="HTTP/1.0"):
+
+def _main_(handler_class=AAIHandler, server_class=BaseHTTPServer.HTTPServer, protocol="HTTP/1.0"):
if sys.argv[1:]:
port = int(sys.argv[1])
@@ -47,12 +47,13 @@ def _main_ (HandlerClass = AAIHandler, ServerClass = BaseHTTPServer.HTTPServer,
server_address = ('', port)
- HandlerClass.protocol_version = protocol
- httpd = ServerClass(server_address, HandlerClass)
+ 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/test/csit/tests/dcaegen2/prh-testcases/resources/simulator/DMaaP.py b/test/csit/tests/dcaegen2/prh-testcases/resources/simulator/DMaaP.py
index 167867842..b5382826b 100644
--- a/test/csit/tests/dcaegen2/prh-testcases/resources/simulator/DMaaP.py
+++ b/test/csit/tests/dcaegen2/prh-testcases/resources/simulator/DMaaP.py
@@ -2,16 +2,14 @@ import BaseHTTPServer
import re
import sys
-from robot.api import logger
-
posted_event_from_prh = 'Empty'
received_event_to_get_method = 'Empty'
+
class DMaaPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_PUT(self):
if re.search('/set_get_event', self.path):
global received_event_to_get_method
- posted_event_from_prh = 'Empty'
content_length = int(self.headers['Content-Length'])
received_event_to_get_method = self.rfile.read(content_length)
self.send_response(200)
@@ -53,7 +51,8 @@ class DMaaPHandler(BaseHTTPServer.BaseHTTPRequestHandler):
return
-def _main_ (HandlerClass = DMaaPHandler, ServerClass = BaseHTTPServer.HTTPServer, protocol="HTTP/1.0"):
+
+def _main_(handler_class=DMaaPHandler, server_class=BaseHTTPServer.HTTPServer, protocol="HTTP/1.0"):
if sys.argv[1:]:
port = int(sys.argv[1])
@@ -62,12 +61,13 @@ def _main_ (HandlerClass = DMaaPHandler, ServerClass = BaseHTTPServer.HTTPServer
server_address = ('', port)
- HandlerClass.protocol_version = protocol
- httpd = ServerClass(server_address, HandlerClass)
+ 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_()