X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=tests%2Fdcaegen2%2Ftestcases%2Fresources%2FDMaaP.py;h=4c245614065d57d1437ad3ef45099a58deb9e52d;hb=bbd96bd93c8d3c773aee53a69c44b3ac9cc3696d;hp=779397e4bf742ae112d9e580b9bfae7149ba7289;hpb=4d973c3b9bc1ddccee5eb33c14231065cfabab46;p=integration%2Fcsit.git diff --git a/tests/dcaegen2/testcases/resources/DMaaP.py b/tests/dcaegen2/testcases/resources/DMaaP.py index 779397e4..4c245614 100644 --- a/tests/dcaegen2/testcases/resources/DMaaP.py +++ b/tests/dcaegen2/testcases/resources/DMaaP.py @@ -106,20 +106,22 @@ 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 try: if EvtSchema is None: - with open(DcaeVariables.CommonEventSchemaV5) as opened_file: + with open(DcaeVariables.CommonEventSchema) as opened_file: EvtSchema = json.load(opened_file) decoded_body = json.loads(post_body) jsonschema.validate(decoded_body, 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() @@ -368,8 +373,8 @@ class DMaaPHandler(BaseHTTPServer.BaseHTTPRequestHandler): def test(handler_class=DMaaPHandler, server_class=BaseHTTPServer.HTTPServer, protocol="HTTP/1.0", port=3904): - print "Load event schema file: " + DcaeVariables.CommonEventSchemaV5 - with open(DcaeVariables.CommonEventSchemaV5) as opened_file: + print "Load event schema file: " + DcaeVariables.CommonEventSchema + with open(DcaeVariables.CommonEventSchema) as opened_file: global EvtSchema EvtSchema = json.load(opened_file) @@ -394,8 +399,8 @@ def _main_(handler_class=DMaaPHandler, server_class=BaseHTTPServer.HTTPServer, p else: port = 3904 - print "Load event schema file: " + DcaeVariables.CommonEventSchemaV5 - with open(DcaeVariables.CommonEventSchemaV5) as opened_file: + print "Load event schema file: " + DcaeVariables.CommonEventSchema + with open(DcaeVariables.CommonEventSchema) as opened_file: global EvtSchema EvtSchema = json.load(opened_file)