Commit 28657d6b authored by Federico Sismondi's avatar Federico Sismondi

update message synch calls and messaging library

parent 4619562e
......@@ -3,9 +3,7 @@
import pika
import time
from coap_testing_tool import AMQP_URL, AMQP_EXCHANGE
from coap_testing_tool.utils.event_bus_messages import *
from .messages import *
def publish_message(channel, message):
""" Published which uses message object metadata
......@@ -25,23 +23,29 @@ def publish_message(channel, message):
)
def amqp_request(request_message: Message, component_id: str):
def amqp_request(channel, request_message: Message, component_id: str):
"""
NOTE: channel must be a pika channel
"""
global AMQP_EXCHANGE
# check first that sender didnt forget about reply to and corr id
assert request_message.reply_to
assert request_message.correlation_id
# setup blocking connection, do not reuse the conection from coord, it needs to be a new one
connection = pika.BlockingConnection(pika.URLParameters(AMQP_URL))
if AMQP_EXCHANGE is None:
AMQP_EXCHANGE = 'default'
response = None
channel = connection.channel()
reply_queue_name = 'amqp_rpc_%s@%s' % (str(uuid.uuid4())[:8], component_id)
result = channel.queue_declare(queue=reply_queue_name, auto_delete=True)
callback_queue = result.method.queue
# by convention routing key of answer is routing_key + .reply
# bind and listen to reply_to topic
channel.queue_bind(
exchange=AMQP_EXCHANGE,
queue=callback_queue,
......@@ -80,9 +84,9 @@ def amqp_request(request_message: Message, component_id: str):
)
)
# cleaning up
# clean up
channel.queue_delete(reply_queue_name)
connection.close()
return response
......
......@@ -68,7 +68,7 @@ import json
import uuid
import logging
API_VERSION = '0.1.11'
API_VERSION = '0.1.12'
# TODO use metaclasses instead?
......@@ -449,6 +449,22 @@ class MsgTestCaseFinish(Message):
'_type': 'testcoordination.testcase.finish',
}
class MsgTestCaseFinished(Message):
"""
Testing Tool MUST-implement notification.
Testing Tool -> GUI
This message is followed by a verdict
"""
routing_key = 'control.testcoordination'
_msg_data_template = {
'_type': 'testcoordination.testcase.finished',
'testcase_id' : 'TD_COAP_CORE_01',
'message' : 'Testcase finished'
}
class MsgTestCaseSkip(Message):
"""
......@@ -976,6 +992,7 @@ message_types_dict = {
"testcoordination.testcase.skip": MsgTestCaseSkip, # GUI -> TestingTool
"testcoordination.testcase.select": MsgTestCaseSelect, # GUI -> TestingTool
"testcoordination.testcase.finish": MsgTestCaseFinish, # GUI -> TestingTool
"testcoordination.testcase.finished": MsgTestCaseFinished, # TestingTool -> GUI
"testcoordination.testcase.verdict": MsgTestCaseVerdict, # TestingTool -> GUI
"testcoordination.testsuite.abort": MsgTestSuiteAbort, # GUI -> TestingTool
"testcoordination.testsuite.getstatus": MsgTestSuiteGetStatus, # GUI -> TestingTool
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment