Add topic validation for dcaegen2 VES tests
Issue-ID: DCAEGEN2-1771
Signed-off-by: Bartosz Gardziejewski <bartosz.gardziejewski@nokia.com>
Change-Id: Ifb4f0f01ef3dcda366147d32c98a9be7890b6f56
diff --git a/tests/dcaegen2/testcases/resources/DMaaP.py b/tests/dcaegen2/testcases/resources/DMaaP.py
index 500afd5..4c24561 100644
--- a/tests/dcaegen2/testcases/resources/DMaaP.py
+++ b/tests/dcaegen2/testcases/resources/DMaaP.py
@@ -106,14 +106,16 @@
'''
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:]
-
- if not enque_event(post_body):
+
+ event = "\""+topic+"\":" + post_body
+ if not enque_event(event):
print "enque event fails"
global EvtSchema
@@ -180,6 +182,9 @@
'''
return
+ def extract_topic_from_path(self):
+ return self.path["/events/".__len__():]
+
def do_GET(self):
"""Serve a GET request."""
f = self.send_head()
diff --git a/tests/dcaegen2/testcases/resources/DcaeLibrary.py b/tests/dcaegen2/testcases/resources/DcaeLibrary.py
index 6b96826..a9d5def 100644
--- a/tests/dcaegen2/testcases/resources/DcaeLibrary.py
+++ b/tests/dcaegen2/testcases/resources/DcaeLibrary.py
@@ -88,6 +88,18 @@
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()
diff --git a/tests/dcaegen2/testcases/resources/dcae_keywords.robot b/tests/dcaegen2/testcases/resources/dcae_keywords.robot
index 0735ce8..059372f 100644
--- a/tests/dcaegen2/testcases/resources/dcae_keywords.robot
+++ b/tests/dcaegen2/testcases/resources/dcae_keywords.robot
@@ -141,19 +141,20 @@
Send Request And Validate Response
[Documentation] Post singel event to passed url with passed data and validate received response
- [Arguments] ${keyword} ${session} ${evtpath} ${evtjson} ${resp_code} ${msg_code}=None
+ [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}
Log Receive HTTPS Status code ${resp.status_code}
Should Be Equal As Strings ${resp.status_code} ${resp_code}
${isEmpty}= Is Json Empty ${resp}
Run Keyword If '${isEmpty}' == False Log ${resp.json()}
- Run Keyword If '${msg_code}' != 'None' Check Whether Message Received ${msg_code}
+ Run Keyword If '${msg_code}' != 'None' Check Whether Message Received ${msg_code} ${topic}
Check Whether Message Received
[Documentation] Validare if message has been received
- [Arguments] ${msg_code}
- ${ret}= DMaaP Message Receive ${msg_code}
+ [Arguments] ${msg_code} ${topic}
+ ${ret}= Run Keyword If '${topic}' != 'None' DMaaP Message Receive On Topic ${msg_code} ${topic}
+ ... ELSE DMaaP Message Receive ${msg_code}
Should Be Equal As Strings ${ret} true
Send Request And Expect Error