Commit bbdcd088 authored by Federico Sismondi's avatar Federico Sismondi

updates on messages lib, better doc, updated auto doc generation script,...

updates on messages lib, better doc, updated auto doc generation script, better tests on messages metadata
parent e06d228f
Pipeline #2317 passed with stage
in 0 seconds
# Contact
Federico Sismondi
Contact address: federicosismondi(AT)gmail(DOT)com
# Utils # Utils
This repo provides some libs and snippets in the form of python modules This repo provides some libs and snippets in the form of python modules
used by several F-Interop components. used by several ioppytest components and F-Interop components.
## Installing CLI, lib and other components:
pip install
## Using the libs ## For contributing or directly using the source code:
Libraries in this repo are all self contained what makes it easy to Libraries in this repo are all self contained what makes it easy to
import. import.
There are several approaches for doing so: There are several approaches for doing so:
......
...@@ -461,6 +461,29 @@ def enter_debug_context(): ...@@ -461,6 +461,29 @@ def enter_debug_context():
cli.add_command(c) cli.add_command(c)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# TODO group cmds
@cli.command()
@click.option('-s', '--step-id', default='TD_COAP_CORE_01_step_01', help="step id of the STIMULI")
@click.option('-ta', '--target-address', default=None, help="taget address")
@click.option('-n', '--node', default='coap_client', help="Node id (related to the IUT role)")
def _execute_stimuli_step(step_id, target_address, node):
"""
Stimuli to be executed by IUT1, targeting IUT2
"""
_echo_input("Executing debug message %s" % sys._getframe().f_code.co_name)
msg = MsgStepStimuliExecute(
node=node,
step_id=step_id,
target_address=target_address,
description="",
step_type="stimuli",
step_info=[""],
testcase_id="",
testcase_ref="",
)
_publish_message(msg)
# TODO group cmds # TODO group cmds
@cli.command() @cli.command()
@click.option('-tc', '--testcase-id', default=None, help="testcase id") @click.option('-tc', '--testcase-id', default=None, help="testcase id")
......
...@@ -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.15, description = Skip testcase, node = someNode, testcase_id = some_testcase_id, ) MsgTestCaseSkip(_api_version = 1.0.17, 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.15, description = Skip testcase, node = someN ...@@ -37,24 +37,24 @@ MsgTestCaseSkip(_api_version = 1.0.15, 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.15, description = Skip testcase, node = someNode, testcase_id = TD_COAP_CORE_03, ) MsgTestCaseSkip(_api_version = 1.0.17, 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.15", "description": "Skip testcase", "node": "someNode", "testcase_id": "TD_COAP_CORE_03"}' '{"_api_version": "1.0.17", "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.15", "description": "Test suite START command"}' '{"_api_version": "1.0.17", "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.15, description = Test suite START command, ) MsgTestSuiteStart(_api_version = 1.0.17, 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.15, description = Test suite START command, ...@@ -66,7 +66,7 @@ MsgTestSuiteStart(_api_version = 1.0.15, 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.15, error_code = None, error_message = None, ok = False, ) MsgErrorReply(_api_version = 1.0.17, 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.15' API_VERSION = '1.0.17'
class NonCompliantMessageFormatError(Exception): class NonCompliantMessageFormatError(Exception):
...@@ -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.15", "capture_id": "TD_COAP_CORE_01"}' '{"_api_version": "1.0.17", "capture_id": "TD_COAP_CORE_01"}'
>>> json_message = m.to_json() >>> json_message = m.to_json()
>>> json_message >>> json_message
'{"_api_version": "1.0.15", "capture_id": "TD_COAP_CORE_01"}' '{"_api_version": "1.0.17", "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'>
...@@ -777,6 +777,28 @@ class MsgUiSessionConfigurationReply(MsgUiReply): ...@@ -777,6 +777,28 @@ class MsgUiSessionConfigurationReply(MsgUiReply):
routing_key = "ui.core.session.get.reply" routing_key = "ui.core.session.get.reply"
_msg_data_template = { _msg_data_template = {
"amqp_url": "amqp://WX9D3L5A:5S68CRDC@mq.dev.f-interop.eu:443/277704a1-03c0-467c-b00d-c984976692d7",
"logs": [
{
"date": "2018-05-07T12:50:47.224000+00:00",
"message": "Session created locally",
"type": "info"
},
],
"resources": [
{}
],
"shared": True,
"slice_id": "urn:publicid:IDN+finterop:project1+slice+testing",
"start_date": "2018-05-07T12:50:48.128000+00:00",
"status": "open",
"testSuite": "http://orchestrator.dev.f-interop.eu:8181/tests/f-interop/dummy-tool-shared",
"testSuiteType": "interoperability",
"users": [
"federico_sismondiojxu",
"myslice",
"federicosismondiparu"
]
} }
...@@ -1582,7 +1604,7 @@ class MsgStepStimuliExecute(Message): ...@@ -1582,7 +1604,7 @@ class MsgStepStimuliExecute(Message):
"node_execution_mode": "user_assisted", "node_execution_mode": "user_assisted",
"testcase_id": "TBD", "testcase_id": "TBD",
"testcase_ref": "TBD", "testcase_ref": "TBD",
"target_address": "TBD" "target_address": None
} }
......
...@@ -5,7 +5,7 @@ import inspect ...@@ -5,7 +5,7 @@ import inspect
import logging import logging
from messages import * from messages import *
gitlab_url = 'https://gitlab.f-interop.eu/f-interop-contributors/utils/blob/master/messages.py' gitlab_url = 'https://gitlab.f-interop.eu/f-interop-contributors/utils/blob/master/messages/messages.py'
doc_parser = 'https://gitlab.f-interop.eu/f-interop-contributors/utils/blob/master/messages_doc.py' doc_parser = 'https://gitlab.f-interop.eu/f-interop-contributors/utils/blob/master/messages_doc.py'
header = """Events (core API) header = """Events (core API)
...@@ -25,7 +25,8 @@ events = [] ...@@ -25,7 +25,8 @@ events = []
def message_amqp_section(file, message_instance): def message_amqp_section(file, message_instance):
file.write("\n\n```amqp") #file.write("\n\n```amqp")
file.write("\n\n```")
try: try:
file.write("\n %s" % str(message_instance)) file.write("\n %s" % str(message_instance))
except Exception as e: except Exception as e:
...@@ -36,7 +37,8 @@ def message_amqp_section(file, message_instance): ...@@ -36,7 +37,8 @@ def message_amqp_section(file, message_instance):
def message_json_section(file, message_instance): def message_json_section(file, message_instance):
file.write("\n\n```json") #file.write("\n\n```json")
file.write("\n\n```")
try: try:
file.write("\n %s" % json.dumps(message_instance.to_dict(), indent=4, )) file.write("\n %s" % json.dumps(message_instance.to_dict(), indent=4, ))
except Exception as e: except Exception as e:
......
# Author: # Author:
# Federico Sismondi <federico.sismondi@gmail.com> # Federico Sismondi <federicosismondi@gmail.com>
#
# License: see LICENSE document
import io import io
from setuptools import setup, find_packages from setuptools import setup, find_packages
...@@ -18,17 +16,13 @@ CLASSIFIERS = [ ...@@ -18,17 +16,13 @@ CLASSIFIERS = [
"Development Status :: 3 - Alpha", "Development Status :: 3 - Alpha",
"Intended Audience :: Science/Research", "Intended Audience :: Science/Research",
"Intended Audience :: Developers", "Intended Audience :: Developers",
"Intended Audience :: Testers",
"Intended Audience :: Network Testers",
# "License :: OSI Approved :: BSD License",
"Programming Language :: Python", "Programming Language :: Python",
"Programming Language :: Python :: 3", "Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.6",
"Topic :: Networks", "Topic :: Internet",
"Topic :: Interoperability testing", "Topic :: Software Development :: Testing",
"Topic :: Scientific/Engineering", "Topic :: Scientific/Engineering",
# "Operating System :: Microsoft :: Windows", not there yet..
"Operating System :: POSIX", "Operating System :: POSIX",
"Operating System :: Unix", "Operating System :: Unix",
"Operating System :: MacOS" "Operating System :: MacOS"
...@@ -43,9 +37,10 @@ setup( ...@@ -43,9 +37,10 @@ setup(
author_email="federicosismondi@gmail.com", author_email="federicosismondi@gmail.com",
maintainer='Federico Sismondi', maintainer='Federico Sismondi',
maintainer_email="federicosismondi@gmail.com", maintainer_email="federicosismondi@gmail.com",
url='https://gitlab.f-interop.eu/f-interop-contributors/utils',
description=description, description=description,
version=VERSION, version=VERSION,
license="??", license='GPLv3+',
classifiers=CLASSIFIERS, classifiers=CLASSIFIERS,
packages=find_packages(exclude=["tests"]), packages=find_packages(exclude=["tests"]),
py_modules=['tabulate', 'event_bus_utils'], py_modules=['tabulate', 'event_bus_utils'],
...@@ -57,8 +52,5 @@ setup( ...@@ -57,8 +52,5 @@ setup(
'prompt_toolkit==1.0.15', 'prompt_toolkit==1.0.15',
'wcwidth==0.1.7', 'wcwidth==0.1.7',
], ],
entry_points={'console_scripts': [ entry_points={'console_scripts': ['ioppytest-cli=ioppytest_cli.ioppytest_cli:main']},
'ioppytest-cli=ioppytest_cli.ioppytest_cli:main',
],
},
) )
...@@ -73,7 +73,7 @@ class MessagesLibraryTests(unittest.TestCase): ...@@ -73,7 +73,7 @@ class MessagesLibraryTests(unittest.TestCase):
while method: while method:
message_count += 1 message_count += 1
logging.info('parsing message %s, number: %s' % (method.routing_key,message_count)) logging.info('parsing message %s, number: %s' % (method.routing_key, message_count))
self.channel.basic_ack(method.delivery_tag) self.channel.basic_ack(method.delivery_tag)
# api call 1 - load w/o properties # api call 1 - load w/o properties
...@@ -104,7 +104,14 @@ class MessagesLibraryTests(unittest.TestCase): ...@@ -104,7 +104,14 @@ class MessagesLibraryTests(unittest.TestCase):
properties=props_dict, properties=props_dict,
) )
assert message, 'load WITH properties didnt work for %s' % (body.decode('utf-8'), method.routing_key) assert message, 'load WITH properties didnt work for %s:\n%s)' % \
(method.routing_key, body.decode('utf-8'))
assert message.message_id, 'load WITH properties - no message id field- for %s:\n%s)' % \
(method.routing_key, body.decode('utf-8'))
assert message.content_type, 'load WITH properties - no content type field- for %s:\n%s)' % \
(method.routing_key, body.decode('utf-8'))
assert message.timestamp, 'load WITH properties - no timestamp field- for %s:\n%s)' % \
(method.routing_key, body.decode('utf-8'))
# api call 3 - load using pika dependent api call # api call 3 - load using pika dependent api call
message = Message.load_from_pika( message = Message.load_from_pika(
...@@ -112,8 +119,14 @@ class MessagesLibraryTests(unittest.TestCase): ...@@ -112,8 +119,14 @@ class MessagesLibraryTests(unittest.TestCase):
props, props,
body, body,
) )
#print(repr(message)) assert message, 'load from pika didnt work for %s:\n%s)' % \
assert message, 'load pika properties didnt work for %s' % (body.decode('utf-8'), method.routing_key) (method.routing_key, body.decode('utf-8'))
assert message.message_id, 'load from pika didnt work for - no message id field- for %s:\n%s)' % \
(method.routing_key, body.decode('utf-8'))
assert message.content_type, 'load from pika didnt work for - no content type field- for %s:\n%s)' % \
(method.routing_key, body.decode('utf-8'))
assert message.timestamp, 'load from pika didnt work for - no timestamp field- for %s:\n%s)' % \
(method.routing_key, body.decode('utf-8'))
method, props, body = self.channel.basic_get(self.queue_for_post_validation) method, props, body = self.channel.basic_get(self.queue_for_post_validation)
......
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