diff options
author | Bartosz Gardziejewski <bartosz.gardziejewski@nokia.com> | 2020-07-29 11:13:36 +0200 |
---|---|---|
committer | Bartosz Gardziejewski <bartosz.gardziejewski@nokia.com> | 2020-07-29 12:19:21 +0200 |
commit | a926d94469780de763da510c9cc01b768df2e444 (patch) | |
tree | 1f25b961784672c3f1f7ac71f2829743fcbc8e41 /tests/dcaegen2/testcases | |
parent | 7a51eafe2231b2719cb842e6407ce3178d617268 (diff) |
Add topic validation for dcaegen2 VES tests
Issue-ID: DCAEGEN2-1771
Signed-off-by: Bartosz Gardziejewski <bartosz.gardziejewski@nokia.com>
Change-Id: Ifb4f0f01ef3dcda366147d32c98a9be7890b6f56
Diffstat (limited to 'tests/dcaegen2/testcases')
4 files changed, 25 insertions, 7 deletions
diff --git a/tests/dcaegen2/testcases/01__no_auth_tests.robot b/tests/dcaegen2/testcases/01__no_auth_tests.robot index f05c0cef..7e7f9767 100644 --- a/tests/dcaegen2/testcases/01__no_auth_tests.robot +++ b/tests/dcaegen2/testcases/01__no_auth_tests.robot @@ -14,7 +14,7 @@ Publish Single VES VNF Measurement Event API V7 Publish Single VES VNF Measurement Event with Standard Defined Fields API V7 [Tags] DCAE-VESC-R1 [Documentation] Post single event with valid data with Standard Defined Fields to /eventListener/v7 endpoint and expect 202 Response Status Code - Send Request And Validate Response Publish Event To VES Collector ${http_session} ${VES_EVENTLISTENER_V7} ${VES_VALID_JSON_V7_STND_DEF_FIELDS} 202 stndDefined-gNB-Nokia-PowerLost + Send Request And Validate Response Publish Event To VES Collector ${http_session} ${VES_EVENTLISTENER_V7} ${VES_VALID_JSON_V7_STND_DEF_FIELDS} 202 stndDefined-gNB-Nokia-PowerLost unauthenticated.SEC_OTHER_OUTPUT Publish Single VES VNF Measurement Event with wrong JSON [Tags] DCAE-VESC-R1 diff --git a/tests/dcaegen2/testcases/resources/DMaaP.py b/tests/dcaegen2/testcases/resources/DMaaP.py index 500afd5d..4c245614 100644 --- a/tests/dcaegen2/testcases/resources/DMaaP.py +++ b/tests/dcaegen2/testcases/resources/DMaaP.py @@ -106,14 +106,16 @@ class DMaaPHandler(BaseHTTPServer.BaseHTTPRequestHandler): ''' 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 @@ class DMaaPHandler(BaseHTTPServer.BaseHTTPRequestHandler): ''' 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 6b96826c..a9d5def8 100644 --- a/tests/dcaegen2/testcases/resources/DcaeLibrary.py +++ b/tests/dcaegen2/testcases/resources/DcaeLibrary.py @@ -88,6 +88,18 @@ class DcaeLibrary(object): 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 0735ce8e..059372fb 100644 --- a/tests/dcaegen2/testcases/resources/dcae_keywords.robot +++ b/tests/dcaegen2/testcases/resources/dcae_keywords.robot @@ -141,19 +141,20 @@ Publish Event To VES Collector With Put Method 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 |