aboutsummaryrefslogtreecommitdiffstats
path: root/tests/dcaegen2/prh-testcases/resources
diff options
context:
space:
mode:
Diffstat (limited to 'tests/dcaegen2/prh-testcases/resources')
-rw-r--r--tests/dcaegen2/prh-testcases/resources/PrhLibrary.py42
-rw-r--r--tests/dcaegen2/prh-testcases/resources/docker-compose.yml6
-rw-r--r--tests/dcaegen2/prh-testcases/resources/prh_library.robot13
-rw-r--r--tests/dcaegen2/prh-testcases/resources/simulator/AAI.py5
-rw-r--r--tests/dcaegen2/prh-testcases/resources/simulator/AAI_simulator10
-rw-r--r--tests/dcaegen2/prh-testcases/resources/simulator/DMaaP.py72
-rw-r--r--tests/dcaegen2/prh-testcases/resources/simulator/DMaaP_simulator13
7 files changed, 109 insertions, 52 deletions
diff --git a/tests/dcaegen2/prh-testcases/resources/PrhLibrary.py b/tests/dcaegen2/prh-testcases/resources/PrhLibrary.py
index 656f6fc3..dc589369 100644
--- a/tests/dcaegen2/prh-testcases/resources/PrhLibrary.py
+++ b/tests/dcaegen2/prh-testcases/resources/PrhLibrary.py
@@ -1,6 +1,7 @@
import json
import docker
+import time
class PrhLibrary(object):
@@ -35,10 +36,45 @@ class PrhLibrary(object):
return correlation_id
@staticmethod
- def stop_aai():
+ def ensure_container_is_running(name):
client = docker.from_env()
- container = client.containers.get('aai_simulator')
- container.stop()
+
+ if not PrhLibrary.is_in_status(client, name, "running"):
+ print ("starting container", name)
+ container = client.containers.get(name)
+ container.start()
+ PrhLibrary.wait_for_status(client, name, "running")
+
+ PrhLibrary.print_status(client)
+
+ @staticmethod
+ def ensure_container_is_exited(name):
+ client = docker.from_env()
+
+ if not PrhLibrary.is_in_status(client, name, "exited"):
+ print ("stopping container", name)
+ container = client.containers.get(name)
+ container.stop()
+ PrhLibrary.wait_for_status(client, name, "exited")
+
+ PrhLibrary.print_status(client)
+
+ @staticmethod
+ def print_status(client):
+ print("containers status")
+ for c in client.containers.list(all=True):
+ print(c.name, " ", c.status)
+
+ @staticmethod
+ def wait_for_status(client, name, status):
+ while not PrhLibrary.is_in_status(client, name, status):
+ print ("waiting for container: ", name, "to be in status: ", status)
+ time.sleep(3)
+
+ @staticmethod
+ def is_in_status(client, name, status):
+ return len(client.containers.list(all=True, filters={"name": "^/"+name+"$", "status": status})) == 1
+
def create_invalid_notification(self, json_file):
return self.create_pnf_ready_notification(json_file).replace("\":", "\": ")\
diff --git a/tests/dcaegen2/prh-testcases/resources/docker-compose.yml b/tests/dcaegen2/prh-testcases/resources/docker-compose.yml
index 04d5763f..6d646801 100644
--- a/tests/dcaegen2/prh-testcases/resources/docker-compose.yml
+++ b/tests/dcaegen2/prh-testcases/resources/docker-compose.yml
@@ -31,9 +31,9 @@ services:
--dmaap.dmaapConsumerConfiguration.dmaapPortNumber=2222
--dmaap.dmaapProducerConfiguration.dmaapHostName=dmaap
--dmaap.dmaapProducerConfiguration.dmaapPortNumber=2222
- --aai.aaiClientConfiguration.aaiHostPortNumber=3334
+ --aai.aaiClientConfiguration.aaiHostPortNumber=3333
--aai.aaiClientConfiguration.aaiHost=aai
- --aai.aaiClientConfiguration.aaiProtocol=https
+ --aai.aaiClientConfiguration.aaiProtocol=http
entrypoint:
- java
- -Dspring.profiles.active=dev
@@ -54,6 +54,8 @@ services:
dockerfile: DMaaP_simulator
ports:
- "2222:2222"
+ - "2223:2223"
+ - "2224:2224"
container_name: dmaap_simulator
aai:
diff --git a/tests/dcaegen2/prh-testcases/resources/prh_library.robot b/tests/dcaegen2/prh-testcases/resources/prh_library.robot
index b7653671..71753875 100644
--- a/tests/dcaegen2/prh-testcases/resources/prh_library.robot
+++ b/tests/dcaegen2/prh-testcases/resources/prh_library.robot
@@ -10,13 +10,14 @@ Create header
Set Suite Variable ${suite_headers} ${headers}
Create sessions
- Create Session dmaap_session ${DMAAP_SIMULATOR_URL}
- Set Suite Variable ${suite_dmaap_session} dmaap_session
+ Create Session dmaap_setup_session ${DMAAP_SIMULATOR_SETUP_URL}
+ Set Suite Variable ${dmaap_setup_session} dmaap_setup_session
Create Session aai_setup_session ${AAI_SIMULATOR_SETUP_URL}
Set Suite Variable ${aai_setup_session} aai_setup_session
Reset Simulators
Reset AAI simulator
+ Reset DMaaP simulator
Invalid event processing
[Arguments] ${input_invalid_event_in_dmaap}
@@ -44,7 +45,7 @@ Check PRH log
Check PNF_READY notification
[Arguments] ${posted_event_to_dmaap}
- ${resp}= Get Request ${suite_dmaap_session} /events/pnfReady headers=${suite_headers}
+ ${resp}= Get Request ${dmaap_setup_session} /events/pnfReady headers=${suite_headers}
Should Be Equal ${resp.text} ${posted_event_to_dmaap}
Set PNF name in AAI
@@ -55,9 +56,13 @@ Set PNF name in AAI
Set event in DMaaP
[Arguments] ${event_in_dmaap}
- ${resp}= Put Request ${suite_dmaap_session} /set_get_event headers=${suite_headers} data=${event_in_dmaap}
+ ${resp}= Put Request ${dmaap_setup_session} /set_get_event headers=${suite_headers} data=${event_in_dmaap}
Should Be Equal As Strings ${resp.status_code} 200
Reset AAI simulator
${resp}= Post Request ${aai_setup_session} /reset
Should Be Equal As Strings ${resp.status_code} 200
+
+Reset DMaaP simulator
+ ${resp}= Post Request ${dmaap_setup_session} /reset
+ Should Be Equal As Strings ${resp.status_code} 200 \ No newline at end of file
diff --git a/tests/dcaegen2/prh-testcases/resources/simulator/AAI.py b/tests/dcaegen2/prh-testcases/resources/simulator/AAI.py
index b6c9c0f9..76823b0d 100644
--- a/tests/dcaegen2/prh-testcases/resources/simulator/AAI.py
+++ b/tests/dcaegen2/prh-testcases/resources/simulator/AAI.py
@@ -1,6 +1,9 @@
+import _thread
+import re
+import ssl
+import time
from http.server import BaseHTTPRequestHandler
from http.server import HTTPServer
-import _thread, ssl, time, re
pnfs = 'Empty'
diff --git a/tests/dcaegen2/prh-testcases/resources/simulator/AAI_simulator b/tests/dcaegen2/prh-testcases/resources/simulator/AAI_simulator
index b44add60..7364769f 100644
--- a/tests/dcaegen2/prh-testcases/resources/simulator/AAI_simulator
+++ b/tests/dcaegen2/prh-testcases/resources/simulator/AAI_simulator
@@ -1,12 +1,4 @@
-FROM alpine:3.8
-
-RUN apk add --no-cache python3 && \
- python3 -m ensurepip && \
- rm -r /usr/lib/python*/ensurepip && \
- pip3 install --upgrade pip setuptools && \
- if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi && \
- if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi && \
- rm -r /root/.cache
+FROM python:3-alpine
ADD AAI.py /
COPY certs/* /certs/
diff --git a/tests/dcaegen2/prh-testcases/resources/simulator/DMaaP.py b/tests/dcaegen2/prh-testcases/resources/simulator/DMaaP.py
index 85c36109..3ff951e8 100644
--- a/tests/dcaegen2/prh-testcases/resources/simulator/DMaaP.py
+++ b/tests/dcaegen2/prh-testcases/resources/simulator/DMaaP.py
@@ -1,13 +1,15 @@
+import _thread
+import re
+import ssl
+import time
from http.server import BaseHTTPRequestHandler
from http.server import HTTPServer
-import re
-import sys
posted_event_from_prh = b'Empty'
received_event_to_get_method = b'Empty'
-class DMaaPHandler(BaseHTTPRequestHandler):
+class DmaapSetup(BaseHTTPRequestHandler):
def do_PUT(self):
if re.search('/set_get_event', self.path):
@@ -15,25 +17,42 @@ class DMaaPHandler(BaseHTTPRequestHandler):
content_length = int(self.headers['Content-Length'])
received_event_to_get_method = self.rfile.read(content_length)
_header_200_and_json(self)
-
+
+ return
+
+ def do_GET(self):
+ if re.search('/events/pnfReady', self.path):
+ _header_200_and_json(self)
+ self.wfile.write(posted_event_from_prh)
+
return
def do_POST(self):
+ if re.search('/reset', self.path):
+ global posted_event_from_prh
+ global received_event_to_get_method
+ posted_event_from_prh = b'Empty'
+ received_event_to_get_method = b'Empty'
+ _header_200_and_json(self)
+
+ return
+
+
+class DMaaPHandler(BaseHTTPRequestHandler):
+
+ def do_POST(self):
if re.search('/events/unauthenticated.PNF_READY', self.path):
global posted_event_from_prh
content_length = int(self.headers['Content-Length'])
posted_event_from_prh = self.rfile.read(content_length)
_header_200_and_json(self)
-
+
return
def do_GET(self):
if re.search('/events/unauthenticated.VES_PNFREG_OUTPUT/OpenDcae-c12/c12', self.path):
_header_200_and_json(self)
self.wfile.write(received_event_to_get_method)
- elif re.search('/events/pnfReady', self.path):
- _header_200_and_json(self)
- self.wfile.write(posted_event_from_prh)
return
@@ -44,21 +63,30 @@ def _header_200_and_json(self):
self.end_headers()
-def _main_(handler_class=DMaaPHandler, server_class=HTTPServer, protocol="HTTP/1.0"):
-
- if sys.argv[1:]:
- port = int(sys.argv[1])
- else:
- port = 2222
-
- server_address = ('', port)
-
+def _main_(handler_class=DMaaPHandler, protocol="HTTP/1.0"):
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()
+ _thread.start_new_thread(_init_http_endpoints, (2222, DMaaPHandler))
+ _thread.start_new_thread(_init_https_endpoints, (2223, DMaaPHandler))
+ _thread.start_new_thread(_init_http_endpoints, (2224, DmaapSetup))
+ while 1:
+ time.sleep(10)
+
+
+def _init_http_endpoints(port, handler_class, server_class=HTTPServer):
+ server = server_class(('', port), handler_class)
+ sa = server.socket.getsockname()
+ print("Serving HTTP on", sa[0], "port", sa[1], "for", handler_class, "...")
+ server.serve_forever()
+
+
+def _init_https_endpoints(port, handler_class, server_class=HTTPServer):
+ server = server_class(('', port), handler_class)
+ server.socket = ssl.wrap_socket(server.socket,
+ keyfile="certs/server.key", certfile="certs/server.crt",
+ ca_certs="certs/client.crt", server_side=True)
+ sa = server.socket.getsockname()
+ print("Serving HTTPS on", sa[0], "port", sa[1], "for", handler_class, "...")
+ server.serve_forever()
if __name__ == '__main__':
diff --git a/tests/dcaegen2/prh-testcases/resources/simulator/DMaaP_simulator b/tests/dcaegen2/prh-testcases/resources/simulator/DMaaP_simulator
index 9cf21dc9..40e1af09 100644
--- a/tests/dcaegen2/prh-testcases/resources/simulator/DMaaP_simulator
+++ b/tests/dcaegen2/prh-testcases/resources/simulator/DMaaP_simulator
@@ -1,15 +1,6 @@
-FROM alpine:3.8
-
-RUN apk add --no-cache python3 && \
- python3 -m ensurepip && \
- rm -r /usr/lib/python*/ensurepip && \
- pip3 install --upgrade pip setuptools && \
- if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi && \
- if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi && \
- rm -r /root/.cache
+FROM python:3-alpine
ADD DMaaP.py /
-
-EXPOSE 2222
+COPY certs/* /certs/
CMD [ "python", "./DMaaP.py" ]