Commit 73e7cbdf authored by Federico Sismondi's avatar Federico Sismondi

updated messages lib

parent 1af9e401
...@@ -37,13 +37,13 @@ def publish_tun_start(exchange, channel, agent_id, ipv6_host, ipv6_prefix, ipv6_ ...@@ -37,13 +37,13 @@ def publish_tun_start(exchange, channel, agent_id, ipv6_host, ipv6_prefix, ipv6_
def publish_tun_bootrap_success(exchange, channel, agent_id): def publish_tun_bootrap_success(exchange, channel, agent_id):
msg = MsgAgentConfigured( msg = MsgAgentTunStart(
name=agent_id, name=agent_id,
) )
channel.basic_publish( channel.basic_publish(
exchange=exchange, exchange=exchange,
routing_key=MsgAgentConfigured.routing_key.replace('*', agent_id), routing_key=MsgAgentTunStarted.routing_key.replace('*', agent_id),
mandatory=True, mandatory=True,
properties=pika.BasicProperties( properties=pika.BasicProperties(
content_type='application/json', content_type='application/json',
...@@ -80,7 +80,7 @@ def bootstrap(amqp_url, amqp_exchange, agent_id, ipv6_host, ipv6_prefix, ipv6_no ...@@ -80,7 +80,7 @@ def bootstrap(amqp_url, amqp_exchange, agent_id, ipv6_host, ipv6_prefix, ipv6_no
channel.queue_bind(exchange=amqp_exchange, channel.queue_bind(exchange=amqp_exchange,
queue=callback_queue, queue=callback_queue,
routing_key=MsgAgentConfigured.routing_key.replace('*', agent_id) routing_key=MsgAgentTunStarted.routing_key.replace('*', agent_id)
) )
try: try:
......
...@@ -26,7 +26,7 @@ Usage: ...@@ -26,7 +26,7 @@ Usage:
------ ------
>>> m = MsgTestCaseSkip(testcase_id = 'some_testcase_id') >>> m = MsgTestCaseSkip(testcase_id = 'some_testcase_id')
>>> m >>> m
MsgTestCaseSkip(_api_version = 1.0.11, description = Skip testcase, node = someNode, testcase_id = some_testcase_id, ) MsgTestCaseSkip(_api_version = 1.0.12, description = Skip testcase, node = someNode, testcase_id = some_testcase_id, )
>>> m.routing_key >>> m.routing_key
'testsuite.testcase.skip' 'testsuite.testcase.skip'
>>> m.message_id # doctest: +SKIP >>> m.message_id # doctest: +SKIP
...@@ -37,24 +37,24 @@ MsgTestCaseSkip(_api_version = 1.0.11, description = Skip testcase, node = someN ...@@ -37,24 +37,24 @@ MsgTestCaseSkip(_api_version = 1.0.11, description = Skip testcase, node = someN
# also we can modify some of the fields (rewrite the default ones) # also we can modify some of the fields (rewrite the default ones)
>>> m = MsgTestCaseSkip(testcase_id = 'TD_COAP_CORE_03') >>> m = MsgTestCaseSkip(testcase_id = 'TD_COAP_CORE_03')
>>> m >>> m
MsgTestCaseSkip(_api_version = 1.0.11, description = Skip testcase, node = someNode, testcase_id = TD_COAP_CORE_03, ) MsgTestCaseSkip(_api_version = 1.0.12, description = Skip testcase, node = someNode, testcase_id = TD_COAP_CORE_03, )
>>> m.testcase_id >>> m.testcase_id
'TD_COAP_CORE_03' 'TD_COAP_CORE_03'
# and even export the message in json format (for example for sending the message though the amqp event bus) # and even export the message in json format (for example for sending the message though the amqp event bus)
>>> m.to_json() >>> m.to_json()
'{"_api_version": "1.0.11", "description": "Skip testcase", "node": "someNode", "testcase_id": "TD_COAP_CORE_03"}' '{"_api_version": "1.0.12", "description": "Skip testcase", "node": "someNode", "testcase_id": "TD_COAP_CORE_03"}'
# We can use the Message class to import json into Message objects: # We can use the Message class to import json into Message objects:
>>> m=MsgTestSuiteStart() >>> m=MsgTestSuiteStart()
>>> m.routing_key >>> m.routing_key
'testsuite.start' 'testsuite.start'
>>> m.to_json() >>> m.to_json()
'{"_api_version": "1.0.11", "description": "Test suite START command"}' '{"_api_version": "1.0.12", "description": "Test suite START command"}'
>>> json_message = m.to_json() >>> json_message = m.to_json()
>>> obj=Message.load(json_message,'testsuite.start', None ) >>> obj=Message.load(json_message,'testsuite.start', None )
>>> obj >>> obj
MsgTestSuiteStart(_api_version = 1.0.11, description = Test suite START command, ) MsgTestSuiteStart(_api_version = 1.0.12, description = Test suite START command, )
>>> type(obj) # doctest: +SKIP >>> type(obj) # doctest: +SKIP
<class 'messages.MsgTestSuiteStart'> <class 'messages.MsgTestSuiteStart'>
...@@ -66,7 +66,7 @@ MsgTestSuiteStart(_api_version = 1.0.11, description = Test suite START command, ...@@ -66,7 +66,7 @@ MsgTestSuiteStart(_api_version = 1.0.11, description = Test suite START command,
# the error reply (note that we pass the message of the request to build the reply): # the error reply (note that we pass the message of the request to build the reply):
>>> err = MsgErrorReply(m) >>> err = MsgErrorReply(m)
>>> err >>> err
MsgErrorReply(_api_version = 1.0.11, error_code = None, error_message = None, ok = False, ) MsgErrorReply(_api_version = 1.0.12, error_code = None, error_message = None, ok = False, )
# properties of the message are auto-generated: # properties of the message are auto-generated:
>>> m.reply_to >>> m.reply_to
...@@ -91,7 +91,7 @@ import time ...@@ -91,7 +91,7 @@ import time
import json import json
import uuid import uuid
API_VERSION = '1.0.11' API_VERSION = '1.0.12'
class NonCompliantMessageFormatError(Exception): class NonCompliantMessageFormatError(Exception):
...@@ -117,7 +117,7 @@ class Message(object): ...@@ -117,7 +117,7 @@ class Message(object):
self._properties = dict( self._properties = dict(
content_type="application/json", content_type="application/json",
message_id=str(uuid.uuid4()), message_id=str(uuid.uuid4()),
timestamp=time.time() timestamp=int(time.time())
) )
try: try:
...@@ -201,10 +201,10 @@ class Message(object): ...@@ -201,10 +201,10 @@ class Message(object):
>>> m.routing_key >>> m.routing_key
'sniffing.getcapture.request' 'sniffing.getcapture.request'
>>> m.to_json() >>> m.to_json()
'{"_api_version": "1.0.11", "capture_id": "TD_COAP_CORE_01"}' '{"_api_version": "1.0.12", "capture_id": "TD_COAP_CORE_01"}'
>>> json_message = m.to_json() >>> json_message = m.to_json()
>>> json_message >>> json_message
'{"_api_version": "1.0.11", "capture_id": "TD_COAP_CORE_01"}' '{"_api_version": "1.0.12", "capture_id": "TD_COAP_CORE_01"}'
>>> obj=Message.load(json_message,'testsuite.start', None ) >>> obj=Message.load(json_message,'testsuite.start', None )
>>> type(obj) # doctest >>> type(obj) # doctest
<class 'messages.MsgTestSuiteStart'> <class 'messages.MsgTestSuiteStart'>
...@@ -1221,25 +1221,6 @@ class MsgSessionConfiguration(Message): ...@@ -1221,25 +1221,6 @@ class MsgSessionConfiguration(Message):
} }
class MsgAgentConfigured(Message):
"""
Requirements: Testing Tool SHOULD publish event
Type: Event
Pub/Sub: Testing Tool -> GUI
Description: The goal is to notify GUI when agents are ready to start the session
"""
routing_key = "fromAgent.*.configured"
_msg_data_template = {
"description": "Agent successfully CONFIGURED",
'name': 'agent_TT'
}
class MsgTestingToolConfigured(Message): class MsgTestingToolConfigured(Message):
""" """
Requirements: TT MUST publish event once session.configuration message has been processed. Requirements: TT MUST publish event once session.configuration message has been processed.
...@@ -2716,7 +2697,6 @@ rk_pattern_to_message_type_map = RoutingKeyToMessageMap( ...@@ -2716,7 +2697,6 @@ rk_pattern_to_message_type_map = RoutingKeyToMessageMap(
"fromAgent.*.ip.tun.started": MsgAgentTunStarted, # Agent -> TestingTool "fromAgent.*.ip.tun.started": MsgAgentTunStarted, # Agent -> TestingTool
"toAgent.*.802154.serial.start": MsgAgentSerialStart, # TestingTool -> Agent "toAgent.*.802154.serial.start": MsgAgentSerialStart, # TestingTool -> Agent
"fromAgent.*.802154.serial.started": MsgAgentSerialStarted, # Agent -> TestingTool "fromAgent.*.802154.serial.started": MsgAgentSerialStarted, # Agent -> TestingTool
"fromAgent.*.configured": MsgAgentConfigured, # TestingTool -> GUI
# ioppytest API: TT signals # ioppytest API: TT signals
"testingtool.ready": MsgTestingToolReady, # Testing Tool -> GUI "testingtool.ready": MsgTestingToolReady, # Testing Tool -> GUI
......
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